Skip to content

Commit

Permalink
fix: elements should be optional (#17424) (#17509)
Browse files Browse the repository at this point in the history
A bug was reported, where an applicationset with an empty elements
array, when created with `argocd appset create <filename>.yaml` gets a
`...list.elements: Required value` error.

My hypothesis is that when calling the K8s API, golang JSON marshalling
mangles the empty `elements` array to `nil`, rather than creating an
empty array when submitting the `POST`.

Still need to figure out why the same setup seemingly works fine when
the same appset is in an app-of-apps.

Signed-off-by: Blake Pettersson <[email protected]>
Co-authored-by: Blake Pettersson <[email protected]>
Co-authored-by: Ishita Sequeira <[email protected]>
  • Loading branch information
3 people authored May 8, 2024
1 parent d774c42 commit f8c2e48
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 24 deletions.
1 change: 1 addition & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7396,6 +7396,7 @@
"properties": {
"elements": {
"type": "array",
"title": "+kubebuilder:validation:Optional",
"items": {
"$ref": "#/definitions/v1JSON"
}
Expand Down
6 changes: 0 additions & 6 deletions manifests/core-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7202,8 +7202,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -9514,8 +9512,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -14477,8 +14473,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down
6 changes: 0 additions & 6 deletions manifests/crds/applicationset-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2338,8 +2338,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -4650,8 +4648,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -9613,8 +9609,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down
6 changes: 0 additions & 6 deletions manifests/ha/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7202,8 +7202,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -9514,8 +9512,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -14477,8 +14473,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down
6 changes: 0 additions & 6 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7202,8 +7202,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -9514,8 +9512,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -14477,8 +14473,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/application/v1alpha1/applicationset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func (g ApplicationSetTerminalGenerators) toApplicationSetNestedGenerators() []A

// ListGenerator include items info
type ListGenerator struct {
// +kubebuilder:validation:Optional
Elements []apiextensionsv1.JSON `json:"elements" protobuf:"bytes,1,name=elements"`
Template ApplicationSetTemplate `json:"template,omitempty" protobuf:"bytes,2,name=template"`
ElementsYaml string `json:"elementsYaml,omitempty" protobuf:"bytes,3,opt,name=elementsYaml"`
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/application/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f8c2e48

Please sign in to comment.