Skip to content

Commit

Permalink
Removes componentParameterOverrides. Closes argoproj#1372 (argoproj#1378
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alexec authored Apr 5, 2019
1 parent a15ca72 commit 4ac062d
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 566 deletions.
22 changes: 0 additions & 22 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2381,13 +2381,6 @@
"description": "ApplicationSource contains information about github repository, path within repository and target application environment.",
"type": "object",
"properties": {
"componentParameterOverrides": {
"type": "array",
"title": "ComponentParameterOverrides are a list of parameter override values\nDEPRECATED: use app source specific config instead",
"items": {
"$ref": "#/definitions/v1alpha1ComponentParameter"
}
},
"directory": {
"$ref": "#/definitions/v1alpha1ApplicationSourceDirectory"
},
Expand Down Expand Up @@ -2687,21 +2680,6 @@
}
}
},
"v1alpha1ComponentParameter": {
"type": "object",
"title": "ComponentParameter contains information about component parameter value",
"properties": {
"component": {
"type": "string"
},
"name": {
"type": "string"
},
"value": {
"type": "string"
}
}
},
"v1alpha1ConnectionState": {
"type": "object",
"title": "ConnectionState contains information about remote resource connection state",
Expand Down
6 changes: 0 additions & 6 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,6 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
}
}
}
if len(app.Spec.Source.Ksonnet.Parameters) == 0 {
app.Spec.Source.ComponentParameterOverrides = nil
}
}
if app.Spec.Source.Helm != nil {
for _, paramStr := range parameters {
Expand All @@ -536,9 +533,6 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
}
}
}
if len(app.Spec.Source.Helm.Parameters) == 0 {
app.Spec.Source.ComponentParameterOverrides = nil
}
specValueFiles := app.Spec.Source.Helm.ValueFiles
for _, valuesFile := range valuesFiles {
for i, vf := range specValueFiles {
Expand Down
649 changes: 298 additions & 351 deletions pkg/apis/application/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions pkg/apis/application/v1alpha1/generated.proto

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

4 changes: 0 additions & 4 deletions pkg/apis/application/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ type ApplicationSource struct {
// TargetRevision defines the commit, tag, or branch in which to sync the application to.
// If omitted, will sync to HEAD
TargetRevision string `json:"targetRevision,omitempty" protobuf:"bytes,4,opt,name=targetRevision"`
// ComponentParameterOverrides are a list of parameter override values
// DEPRECATED: use app source specific config instead
ComponentParameterOverrides []ComponentParameter `json:"componentParameterOverrides,omitempty" protobuf:"bytes,5,opt,name=componentParameterOverrides"`
// Helm holds helm specific options
Helm *ApplicationSourceHelm `json:"helm,omitempty" protobuf:"bytes,7,opt,name=helm"`
// Kustomize holds kustomize specific options
Expand All @@ -85,7 +82,6 @@ func (a ApplicationSource) IsZero() bool {
return a.RepoURL == "" &&
a.Path == "" &&
a.TargetRevision == "" &&
len(a.ComponentParameterOverrides) == 0 &&
a.Helm.IsZero() &&
a.Kustomize.IsZero() &&
a.Ksonnet.IsZero() &&
Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/application/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ func (in *ApplicationList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ApplicationSource) DeepCopyInto(out *ApplicationSource) {
*out = *in
if in.ComponentParameterOverrides != nil {
in, out := &in.ComponentParameterOverrides, &out.ComponentParameterOverrides
*out = make([]ComponentParameter, len(*in))
copy(*out, *in)
}
if in.Helm != nil {
in, out := &in.Helm, &out.Helm
if *in == nil {
Expand Down
74 changes: 0 additions & 74 deletions util/argo/argo.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,80 +454,6 @@ func NormalizeApplicationSpec(spec *argoappv1.ApplicationSpec, sourceType argoap
if spec.Project == "" {
spec.Project = common.DefaultAppProjectName
}
// 1. carry over legacy componentParameterOverride field (v0.11 and below) into
// ksonnet, helm, kustomize specific fields. Only do this if source specific config is empty
// since this is a one-time conversion.
if len(spec.Source.ComponentParameterOverrides) > 0 {
switch sourceType {
case argoappv1.ApplicationSourceTypeKsonnet:
if spec.Source.Ksonnet == nil {
spec.Source.Ksonnet = &argoappv1.ApplicationSourceKsonnet{}
}
if len(spec.Source.Ksonnet.Parameters) == 0 {
for _, p := range spec.Source.ComponentParameterOverrides {
spec.Source.Ksonnet.Parameters = append(spec.Source.Ksonnet.Parameters, argoappv1.KsonnetParameter(p))

}
}
case argoappv1.ApplicationSourceTypeHelm:
if spec.Source.Helm == nil {
spec.Source.Helm = &argoappv1.ApplicationSourceHelm{}
}
if len(spec.Source.Helm.Parameters) == 0 {
for _, p := range spec.Source.ComponentParameterOverrides {
spec.Source.Helm.Parameters = append(spec.Source.Helm.Parameters, argoappv1.HelmParameter{
Name: p.Name,
Value: p.Value,
})
}
}
case argoappv1.ApplicationSourceTypeKustomize:
if spec.Source.Kustomize == nil {
spec.Source.Kustomize = &argoappv1.ApplicationSourceKustomize{}
}
if len(spec.Source.Kustomize.ImageTags) == 0 {
for _, p := range spec.Source.ComponentParameterOverrides {
if p.Component != "imagetag" {
continue
}
spec.Source.Kustomize.ImageTags = append(spec.Source.Kustomize.ImageTags, argoappv1.KustomizeImageTag{
Name: p.Name,
Value: p.Value,
})
}
}
}
}

// 2. duplicate the preferred fields into legacy componentParameterOverride field so that they
// are always in-sync.
// NOTE: this step effectively ignore any changes which made only to the legacy fields. This
// *should* be OK since older CLIs are blocked, and the UI will be using the new fields. This
// may break custom REST API clients
var cpo []argoappv1.ComponentParameter
if spec.Source.Ksonnet != nil {
for _, p := range spec.Source.Ksonnet.Parameters {
cpo = append(cpo, argoappv1.ComponentParameter(p))
}
}
if spec.Source.Helm != nil {
for _, p := range spec.Source.Helm.Parameters {
cpo = append(cpo, argoappv1.ComponentParameter{
Name: p.Name,
Value: p.Value,
})
}
}
if spec.Source.Kustomize != nil {
for _, p := range spec.Source.Kustomize.ImageTags {
cpo = append(cpo, argoappv1.ComponentParameter{
Component: "imagetag",
Name: p.Name,
Value: p.Value,
})
}
}
spec.Source.ComponentParameterOverrides = cpo

// 3. If any app sources are their zero values, then nil out the pointers to the source spec.
// This makes it easier for users to switch between app source types if they are not using
Expand Down
100 changes: 0 additions & 100 deletions util/argo/argo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,106 +105,6 @@ func TestContainsSyncResource(t *testing.T) {
}
}

func TestNormalizeApplicationSpec(t *testing.T) {
{
// Verify we normalize project name
spec := NormalizeApplicationSpec(&argoappv1.ApplicationSpec{}, argoappv1.ApplicationSourceTypeKustomize)
assert.Equal(t, spec.Project, "default")
}

{
// Verify we copy over legacy componentParameterOverride to ksonnet field
spec := NormalizeApplicationSpec(&argoappv1.ApplicationSpec{
Source: argoappv1.ApplicationSource{
Ksonnet: &argoappv1.ApplicationSourceKsonnet{
Environment: "foo",
},
ComponentParameterOverrides: []argoappv1.ComponentParameter{{Component: "foo", Name: "bar", Value: "baz"}},
},
}, argoappv1.ApplicationSourceTypeKsonnet)
assert.Equal(t, spec.Source.Ksonnet.Parameters[0].Component, "foo")
assert.Equal(t, spec.Source.Ksonnet.Parameters[0].Name, "bar")
assert.Equal(t, spec.Source.Ksonnet.Parameters[0].Value, "baz")
_, err := spec.Source.ExplicitType()
assert.NoError(t, err)
}

{
// Verify we sync ksonnet.parameters field to legacy field
spec := NormalizeApplicationSpec(&argoappv1.ApplicationSpec{
Source: argoappv1.ApplicationSource{
Ksonnet: &argoappv1.ApplicationSourceKsonnet{
Environment: "foo",
Parameters: []argoappv1.KsonnetParameter{{Component: "foo", Name: "bar", Value: "baz"}},
},
},
}, argoappv1.ApplicationSourceTypeKsonnet)
assert.Equal(t, spec.Source.ComponentParameterOverrides[0].Component, "foo")
assert.Equal(t, spec.Source.ComponentParameterOverrides[0].Name, "bar")
assert.Equal(t, spec.Source.ComponentParameterOverrides[0].Value, "baz")
_, err := spec.Source.ExplicitType()
assert.NoError(t, err)
}

{
// Verify we copy over legacy componentParameterOverride to helm.parameters
spec := NormalizeApplicationSpec(&argoappv1.ApplicationSpec{
Source: argoappv1.ApplicationSource{
ComponentParameterOverrides: []argoappv1.ComponentParameter{{Name: "bar", Value: "baz"}},
},
}, argoappv1.ApplicationSourceTypeHelm)
assert.Equal(t, spec.Source.Helm.Parameters[0].Name, "bar")
assert.Equal(t, spec.Source.Helm.Parameters[0].Value, "baz")
_, err := spec.Source.ExplicitType()
assert.NoError(t, err)
}

{
// Verify we sync helm.parameters field to legacy componentParameterOverride field
spec := NormalizeApplicationSpec(&argoappv1.ApplicationSpec{
Source: argoappv1.ApplicationSource{
Helm: &argoappv1.ApplicationSourceHelm{
Parameters: []argoappv1.HelmParameter{{Name: "bar", Value: "baz"}},
},
},
}, argoappv1.ApplicationSourceTypeHelm)
assert.Equal(t, spec.Source.ComponentParameterOverrides[0].Component, "")
assert.Equal(t, spec.Source.ComponentParameterOverrides[0].Name, "bar")
assert.Equal(t, spec.Source.ComponentParameterOverrides[0].Value, "baz")
_, err := spec.Source.ExplicitType()
assert.NoError(t, err)
}

{
// Verify we copy over legacy componentParameterOverride to kustomize.imageTags
spec := NormalizeApplicationSpec(&argoappv1.ApplicationSpec{
Source: argoappv1.ApplicationSource{
ComponentParameterOverrides: []argoappv1.ComponentParameter{{Component: "imagetag", Name: "bar", Value: "baz"}},
},
}, argoappv1.ApplicationSourceTypeKustomize)
assert.Equal(t, spec.Source.Kustomize.ImageTags[0].Name, "bar")
assert.Equal(t, spec.Source.Kustomize.ImageTags[0].Value, "baz")
_, err := spec.Source.ExplicitType()
assert.NoError(t, err)
}

{
// Verify we sync kustomize.imageTags field to legacy componentParameterOverride field
spec := NormalizeApplicationSpec(&argoappv1.ApplicationSpec{
Source: argoappv1.ApplicationSource{
Kustomize: &argoappv1.ApplicationSourceKustomize{
ImageTags: []argoappv1.KustomizeImageTag{{Name: "bar", Value: "baz"}},
},
},
}, argoappv1.ApplicationSourceTypeHelm)
assert.Equal(t, spec.Source.ComponentParameterOverrides[0].Component, "imagetag")
assert.Equal(t, spec.Source.ComponentParameterOverrides[0].Name, "bar")
assert.Equal(t, spec.Source.ComponentParameterOverrides[0].Value, "baz")
_, err := spec.Source.ExplicitType()
assert.NoError(t, err)
}
}

// TestNilOutZerValueAppSources verifies we will nil out app source specs when they are their zero-value
func TestNilOutZerValueAppSources(t *testing.T) {
var spec *argoappv1.ApplicationSpec
Expand Down

0 comments on commit 4ac062d

Please sign in to comment.