Skip to content

Commit

Permalink
fix: elements should be optional (#17424) (#17510)
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]>
  • Loading branch information
1 parent f5d63a5 commit 47d5861
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 @@ -7405,6 +7405,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 @@ -7310,8 +7310,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -9654,8 +9652,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -14681,8 +14677,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 @@ -2370,8 +2370,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -4714,8 +4712,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -9741,8 +9737,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 @@ -7310,8 +7310,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -9654,8 +9652,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -14681,8 +14677,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 @@ -7310,8 +7310,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -9654,8 +9652,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -14681,8 +14677,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 @@ -260,6 +260,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 47d5861

Please sign in to comment.