Skip to content

Commit

Permalink
fix: elements should be optional (argoproj#17424)
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 <blake.pettersson@gmail.com>
  • Loading branch information
blakepettersson authored and Hariharasuthan99 committed Jun 16, 2024
1 parent ea5a5bc commit ec347a2
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 @@ -7413,6 +7413,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 @@ -7394,8 +7394,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -9754,8 +9752,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -14813,8 +14809,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 @@ -2386,8 +2386,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -4746,8 +4744,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -9805,8 +9801,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 @@ -7394,8 +7394,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -9754,8 +9752,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -14813,8 +14809,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 @@ -7394,8 +7394,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
properties:
Expand Down Expand Up @@ -9754,8 +9752,6 @@ spec:
- metadata
- spec
type: object
required:
- elements
type: object
matrix:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -14813,8 +14809,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 ec347a2

Please sign in to comment.