Skip to content

Commit 410bba5

Browse files
committed
Vibe coded some things I don't understand
1 parent a521736 commit 410bba5

20 files changed

Lines changed: 1407 additions & 5 deletions

File tree

vertical-pod-autoscaler/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
k8s.io/code-generator v0.35.0-rc.0
2020
k8s.io/component-base v0.35.0-rc.0
2121
k8s.io/klog/v2 v2.130.1
22+
k8s.io/kube-openapi v0.0.0-20251125145642-4e65d59e963e
2223
k8s.io/metrics v0.35.0-rc.0
2324
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
2425
sigs.k8s.io/structured-merge-diff/v6 v6.3.1
@@ -77,7 +78,6 @@ require (
7778
gopkg.in/inf.v0 v0.9.1 // indirect
7879
gopkg.in/yaml.v3 v3.0.1 // indirect
7980
k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b // indirect
80-
k8s.io/kube-openapi v0.0.0-20251125145642-4e65d59e963e // indirect
8181
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
8282
sigs.k8s.io/randfill v1.0.0 // indirect
8383
sigs.k8s.io/yaml v1.6.0 // indirect

vertical-pod-autoscaler/hack/update-codegen.sh

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,54 @@ REPO_ROOT="$(git rev-parse --show-toplevel)"
2929
# shellcheck source=/dev/null
3030
source "${CODEGEN_PKG}/kube_codegen.sh"
3131

32+
# Ensure openapi-gen is installed
33+
OPENAPI_PKG=$($GO_CMD list -m -mod=readonly -f "{{.Dir}}" k8s.io/kube-openapi)
34+
$GO_CMD install "${OPENAPI_PKG}/cmd/openapi-gen"
35+
3236
kube::codegen::gen_helpers \
3337
"$(dirname ${BASH_SOURCE})/../pkg/apis" \
3438
--boilerplate "${REPO_ROOT}/hack/boilerplate/boilerplate.generatego.txt"
3539

36-
echo "Ran gen helpers, moving on to generating client code..."
40+
echo "Ran gen helpers, moving on to generating openapi definitions..."
41+
42+
# Generate OpenAPI definitions
43+
OPENAPI_OUTPUT_DIR="$(dirname ${BASH_SOURCE})/../pkg/generated/openapi"
44+
mkdir -p "${OPENAPI_OUTPUT_DIR}"
45+
46+
openapi-gen \
47+
--go-header-file "${REPO_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
48+
--output-dir "${OPENAPI_OUTPUT_DIR}" \
49+
--output-pkg "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/generated/openapi" \
50+
--output-file "zz_generated.openapi.go" \
51+
--report-filename "${OPENAPI_OUTPUT_DIR}/violation_exceptions.list" \
52+
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" \
53+
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1" \
54+
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2" \
55+
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1" \
56+
"k8s.io/api/core/v1" \
57+
"k8s.io/api/autoscaling/v1" \
58+
"k8s.io/apimachinery/pkg/api/resource" \
59+
"k8s.io/apimachinery/pkg/apis/meta/v1" \
60+
"k8s.io/apimachinery/pkg/runtime" \
61+
"k8s.io/apimachinery/pkg/version"
62+
63+
echo "Generated openapi definitions, moving on to generating client code..."
64+
65+
# Generate OpenAPI schema JSON for applyconfiguration-gen
66+
OPENAPI_SCHEMA_FILE=$(mktemp)
67+
trap "rm -f ${OPENAPI_SCHEMA_FILE}" EXIT
68+
$GO_CMD run "$(dirname ${BASH_SOURCE})/../pkg/generated/openapi/cmd/models-schema" > "${OPENAPI_SCHEMA_FILE}"
3769

3870
kube::codegen::gen_client \
3971
"$(dirname ${BASH_SOURCE})/../pkg/apis" \
4072
--output-pkg k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client \
4173
--output-dir "$(dirname ${BASH_SOURCE})/../pkg/client" \
4274
--boilerplate "${REPO_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
4375
--with-watch \
44-
--with-applyconfig
76+
--with-applyconfig \
77+
--applyconfig-openapi-schema "${OPENAPI_SCHEMA_FILE}"
4578

46-
echo "Generated client code, running `go mod tidy`..."
79+
echo "Generated client code, running \`go mod tidy\`..."
4780

4881
# We need to clean up the go.mod file since code-generator adds temporary library to the go.mod file.
4982
"${GO_CMD}" mod tidy

vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
// +k8s:deepcopy-gen=package,register
1818

1919
// Package v1 contains definitions of Vertical Pod Autoscaler related objects.
20+
// +k8s:openapi-gen=true
2021
// +groupName=autoscaling.k8s.io
2122
// +kubebuilder:object:generate=true
2223
package v1

vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ type HistogramCheckpoint struct {
438438
// Map from bucket index to bucket weight.
439439
// +kubebuilder:validation:Type=object
440440
// +kubebuilder:validation:XPreserveUnknownFields
441+
// +k8s:openapi-gen=false
441442
BucketWeights map[int]uint32 `json:"bucketWeights,omitempty" protobuf:"bytes,2,opt,name=bucketWeights"`
442443

443444
// Sum of samples to be used as denominator for weights from BucketWeights.

vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
// +k8s:deepcopy-gen=package,register
1818

1919
// Package v1beta1 contains definitions of Vertical Pod Autoscaler related objects.
20+
// +k8s:openapi-gen=true
2021
// +groupName=autoscaling.k8s.io
2122
// +kubebuilder:skip
2223
package v1beta1

vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ type HistogramCheckpoint struct {
315315
ReferenceTimestamp metav1.Time `json:"referenceTimestamp,omitempty" protobuf:"bytes,1,opt,name=referenceTimestamp"`
316316

317317
// Map from bucket index to bucket weight.
318+
// +k8s:openapi-gen=false
318319
BucketWeights map[int]uint32 `json:"bucketWeights,omitempty" protobuf:"bytes,2,opt,name=bucketWeights"`
319320

320321
// Sum of samples to be used as denominator for weights from BucketWeights.

vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
// +k8s:deepcopy-gen=package,register
1818

1919
// Package v1beta2 contains definitions of Vertical Pod Autoscaler related objects.
20+
// +k8s:openapi-gen=true
2021
// +groupName=autoscaling.k8s.io
2122
// +kubebuilder:object:generate=true
2223
package v1beta2

vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ type HistogramCheckpoint struct {
348348
// Map from bucket index to bucket weight.
349349
// +kubebuilder:validation:Type=object
350350
// +kubebuilder:validation:XPreserveUnknownFields
351+
// +k8s:openapi-gen=false
351352
BucketWeights map[int]uint32 `json:"bucketWeights,omitempty" protobuf:"bytes,2,opt,name=bucketWeights"`
352353

353354
// Sum of samples to be used as denominator for weights from BucketWeights.

vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
// +k8s:deepcopy-gen=package,register
1818

1919
// Package v1alpha1 contains definitions of Vertical Pod Autoscaler related objects.
20+
// +k8s:openapi-gen=true
2021
// +groupName=poc.autoscaling.k8s.io
2122
// +kubebuilder:skip
2223
package v1alpha1

vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ type HistogramCheckpoint struct {
306306
ReferenceTimestamp metav1.Time `json:"referenceTimestamp,omitempty" protobuf:"bytes,1,opt,name=referenceTimestamp"`
307307

308308
// Map from bucket index to bucket weight.
309+
// +k8s:openapi-gen=false
309310
BucketWeights map[int]uint32 `json:"bucketWeights,omitempty" protobuf:"bytes,2,opt,name=bucketWeights"`
310311

311312
// Sum of samples to be used as denominator for weights from BucketWeights.

0 commit comments

Comments
 (0)