diff --git a/api/go.mod b/api/go.mod index 178243386..bef981cf6 100644 --- a/api/go.mod +++ b/api/go.mod @@ -3,6 +3,7 @@ module github.com/fluxcd/helm-controller/api go 1.15 require ( + github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203170140-c9274a8cd235 github.com/fluxcd/pkg/apis/meta v0.7.0 github.com/fluxcd/pkg/runtime v0.6.2 k8s.io/apiextensions-apiserver v0.20.2 diff --git a/api/go.sum b/api/go.sum index 320941b71..08c2594b9 100644 --- a/api/go.sum +++ b/api/go.sum @@ -113,6 +113,10 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203162456-8b60f01eda32 h1:1aMt0EQ7Wd6sJhH/VjNo2l9JvC24zNFi00XF7Hw/A6Q= +github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203162456-8b60f01eda32/go.mod h1:JAFPfnRmcrAoG1gNiA8kmEXsnOBuDyZ/F5X4DAQcVV0= +github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203170140-c9274a8cd235 h1:IBxiuFeaECdJKqBTEHPkQs4wybA9b3rSbRe7w2FAOvk= +github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203170140-c9274a8cd235/go.mod h1:JAFPfnRmcrAoG1gNiA8kmEXsnOBuDyZ/F5X4DAQcVV0= github.com/fluxcd/pkg/apis/meta v0.5.0/go.mod h1:aEUuZIawboAAFLlYz/juVJ7KNmlWbBtJFYkOWWmGUR4= github.com/fluxcd/pkg/apis/meta v0.7.0 h1:5e8gm4OLqjuKWdrOIY5DEEsjcwzyJFK8rCDesJ+V8IY= github.com/fluxcd/pkg/apis/meta v0.7.0/go.mod h1:yHuY8kyGHYz22I0jQzqMMGCcHViuzC/WPdo9Gisk8Po= diff --git a/api/v2beta1/helmrelease_types.go b/api/v2beta1/helmrelease_types.go index afc1485cd..11f590675 100644 --- a/api/v2beta1/helmrelease_types.go +++ b/api/v2beta1/helmrelease_types.go @@ -25,6 +25,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "github.com/fluxcd/pkg/apis/kustomize" "github.com/fluxcd/pkg/apis/meta" "github.com/fluxcd/pkg/runtime/dependency" ) @@ -32,15 +33,6 @@ import ( const HelmReleaseKind = "HelmRelease" const HelmReleaseFinalizer = "finalizers.fluxcd.io" -// PatchJSON6902 contains a JSON patch and the target it applies to. -type PatchJSON6902 struct { - // Patch is the YAML content of a patch. - Patch []apiextensionsv1.JSON `json:"patch,omitempty" yaml:"patch,omitempty"` - - // Target points to the resources that the patch is applied to. - Target Selector `json:"target,omitempty" yaml:"target,omitempty"` -} - // Kustomize Helm PostRenderer specification. type Kustomize struct { // Strategic merge patches, defined as inline YAML objects. @@ -49,13 +41,13 @@ type Kustomize struct { // JSON 6902 patches, defined as inline YAML objects. // +optional - PatchesJSON6902 []PatchJSON6902 `json:"patchesJson6902,omitempty"` + PatchesJSON6902 []kustomize.JSON6902Patch `json:"patchesJson6902,omitempty"` // Images is a list of (image name, new name, new tag or digest) // for changing image names, tags or digests. This can also be achieved with a // patch, but this operator is simpler to specify. // +optional - Images []Image `json:"images,omitempty" yaml:"images,omitempty"` + Images []kustomize.Image `json:"images,omitempty" yaml:"images,omitempty"` } // PostRenderer contains a Helm PostRenderer specification. diff --git a/api/v2beta1/kustomization_types.go b/api/v2beta1/kustomization_types.go deleted file mode 100644 index 9f480a892..000000000 --- a/api/v2beta1/kustomization_types.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2020 The Flux authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v2beta1 - -// Image contains an image name, a new name, a new tag or digest, -// which will replace the original name and tag. -type Image struct { - // Name is a tag-less image name. - Name string `json:"name,omitempty" yaml:"name,omitempty"` - - // NewName is the value used to replace the original name. - NewName string `json:"newName,omitempty" yaml:"newName,omitempty"` - - // NewTag is the value used to replace the original tag. - NewTag string `json:"newTag,omitempty" yaml:"newTag,omitempty"` - - // Digest is the value used to replace the original image tag. - // If digest is present NewTag value is ignored. - Digest string `json:"digest,omitempty" yaml:"digest,omitempty"` -} - -// Gvk identifies a Kubernetes API type. -// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md -type Gvk struct { - Group string `json:"group,omitempty" yaml:"group,omitempty"` - - Version string `json:"version,omitempty" yaml:"version,omitempty"` - - Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` -} - -// Selector specifies a set of resources. -// Any resource that matches intersection of all conditions -// is included in this set. -type Selector struct { - Gvk `json:",inline,omitempty" yaml:",inline,omitempty"` - - Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` - - Name string `json:"name,omitempty" yaml:"name,omitempty"` - - // AnnotationSelector is a string that follows the label selection expression - // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api - // It matches with the resource annotations. - AnnotationSelector string `json:"annotationSelector,omitempty" yaml:"annotationSelector,omitempty"` - - // LabelSelector is a string that follows the label selection expression - // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api - // It matches with the resource labels. - LabelSelector string `json:"labelSelector,omitempty" yaml:"labelSelector,omitempty"` -} diff --git a/api/v2beta1/zz_generated.deepcopy.go b/api/v2beta1/zz_generated.deepcopy.go index 96d4a8956..cd64b6346 100644 --- a/api/v2beta1/zz_generated.deepcopy.go +++ b/api/v2beta1/zz_generated.deepcopy.go @@ -1,7 +1,7 @@ // +build !ignore_autogenerated /* -Copyright 2020 The Flux authors +Copyright 2021 The Flux authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ limitations under the License. package v2beta1 import ( + "github.com/fluxcd/pkg/apis/kustomize" "github.com/fluxcd/pkg/runtime/dependency" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -42,21 +43,6 @@ func (in *CrossNamespaceObjectReference) DeepCopy() *CrossNamespaceObjectReferen return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Gvk) DeepCopyInto(out *Gvk) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Gvk. -func (in *Gvk) DeepCopy() *Gvk { - if in == nil { - return nil - } - out := new(Gvk) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HelmChartTemplate) DeepCopyInto(out *HelmChartTemplate) { *out = *in @@ -255,21 +241,6 @@ func (in *HelmReleaseStatus) DeepCopy() *HelmReleaseStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Image) DeepCopyInto(out *Image) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Image. -func (in *Image) DeepCopy() *Image { - if in == nil { - return nil - } - out := new(Image) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Install) DeepCopyInto(out *Install) { *out = *in @@ -348,14 +319,14 @@ func (in *Kustomize) DeepCopyInto(out *Kustomize) { } if in.PatchesJSON6902 != nil { in, out := &in.PatchesJSON6902, &out.PatchesJSON6902 - *out = make([]PatchJSON6902, len(*in)) + *out = make([]kustomize.JSON6902Patch, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } if in.Images != nil { in, out := &in.Images, &out.Images - *out = make([]Image, len(*in)) + *out = make([]kustomize.Image, len(*in)) copy(*out, *in) } } @@ -370,29 +341,6 @@ func (in *Kustomize) DeepCopy() *Kustomize { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PatchJSON6902) DeepCopyInto(out *PatchJSON6902) { - *out = *in - if in.Patch != nil { - in, out := &in.Patch, &out.Patch - *out = make([]v1.JSON, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - out.Target = in.Target -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PatchJSON6902. -func (in *PatchJSON6902) DeepCopy() *PatchJSON6902 { - if in == nil { - return nil - } - out := new(PatchJSON6902) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PostRenderer) DeepCopyInto(out *PostRenderer) { *out = *in @@ -433,22 +381,6 @@ func (in *Rollback) DeepCopy() *Rollback { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Selector) DeepCopyInto(out *Selector) { - *out = *in - out.Gvk = in.Gvk -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Selector. -func (in *Selector) DeepCopy() *Selector { - if in == nil { - return nil - } - out := new(Selector) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Test) DeepCopyInto(out *Test) { *out = *in diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml index 08106de1c..51e9b3815 100644 --- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml +++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml @@ -250,22 +250,46 @@ spec: description: NewTag is the value used to replace the original tag. type: string + required: + - name type: object type: array patchesJson6902: description: JSON 6902 patches, defined as inline YAML objects. items: - description: PatchJSON6902 contains a JSON patch and the - target it applies to. + description: JSON6902Patch contains a JSON6902 patch and + the target the patch should be applied to. properties: patch: - description: Patch is the YAML content of a patch. + description: Patch contains the JSON6902 patch document + with an array of operation objects. items: - x-kubernetes-preserve-unknown-fields: true + description: JSON6902 is a JSON6902 operation object. + https://tools.ietf.org/html/rfc6902#section-4 + properties: + from: + type: string + op: + enum: + - test + - remove + - add + - replace + - move + - copy + type: string + path: + type: string + value: + x-kubernetes-preserve-unknown-fields: true + required: + - op + - path + type: object type: array target: description: Target points to the resources that the - patch is applied to. + patch document should be applied to. properties: annotationSelector: description: AnnotationSelector is a string that @@ -273,8 +297,16 @@ spec: It matches with the resource annotations. type: string group: + description: Group is the API group to select + resources from. Together with Version and Kind + it is capable of unambiguously identifying and/or + selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md type: string kind: + description: Kind of the API Group to select resources + from. Together with Group and Version it is + capable of unambiguously identifying and/or + selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md type: string labelSelector: description: LabelSelector is a string that follows @@ -282,12 +314,21 @@ spec: It matches with the resource labels. type: string name: + description: Name to match resources with. type: string namespace: + description: Namespace to select resources from. type: string version: + description: Version of the API Group to select + resources from. Together with Group and Kind + it is capable of unambiguously identifying and/or + selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md type: string type: object + required: + - patch + - target type: object type: array patchesStrategicMerge: diff --git a/controllers/helmrelease_types_test.go b/controllers/helmrelease_types_test.go index ab50e4733..ac2d7d65a 100644 --- a/controllers/helmrelease_types_test.go +++ b/controllers/helmrelease_types_test.go @@ -1,14 +1,32 @@ +/* +Copyright 2021 The Flux authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package controllers import ( "encoding/json" "testing" + "github.com/fluxcd/pkg/apis/kustomize" + v2 "github.com/fluxcd/helm-controller/api/v2beta1" ) func TestHelmReleaseTypes_unmarshal_PatchJSON6902(t *testing.T) { - var p v2.PatchJSON6902 + var p kustomize.JSON6902Patch err := json.Unmarshal([]byte(`{"target": {"namespace": "ns", "name": "x", "kind": "k", "version": "v"},"patch": [{"op": "add", "path": "/some/new/path", "value": "value"}]}`), &p) if err != nil { t.Error(err) diff --git a/docs/api/helmrelease.md b/docs/api/helmrelease.md index 431355bbe..2b4d52fca 100644 --- a/docs/api/helmrelease.md +++ b/docs/api/helmrelease.md @@ -422,58 +422,6 @@ string

DeploymentAction

DeploymentAction defines a consistent interface for Install and Upgrade.

-

Gvk -

-

-(Appears on: -Selector) -

-

Gvk identifies a Kubernetes API type. -https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md

-
-
- - - - - - - - - - - - - - - - - - - - - -
FieldDescription
-group
- -string - -
-
-version
- -string - -
-
-kind
- -string - -
-
-
-

HelmChartTemplate

@@ -1114,73 +1062,6 @@ state. It is reset after a successful reconciliation.

-

Image -

-

-(Appears on: -Kustomize) -

-

Image contains an image name, a new name, a new tag or digest, -which will replace the original name and tag.

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescription
-name
- -string - -
-

Name is a tag-less image name.

-
-newName
- -string - -
-

NewName is the value used to replace the original name.

-
-newTag
- -string - -
-

NewTag is the value used to replace the original tag.

-
-digest
- -string - -
-

Digest is the value used to replace the original image tag. -If digest is present NewTag value is ignored.

-
-
-

Install

@@ -1450,8 +1331,8 @@ the HelmRelease.

patchesJson6902
- -[]PatchJSON6902 + +[]github.com/fluxcd/pkg/apis/kustomize.JSON6902Patch @@ -1464,8 +1345,8 @@ the HelmRelease.

images
- -[]Image + +[]github.com/fluxcd/pkg/apis/kustomize.Image @@ -1480,53 +1361,6 @@ patch, but this operator is simpler to specify.

-

PatchJSON6902 -

-

-(Appears on: -Kustomize) -

-

PatchJSON6902 contains a JSON patch and the target it applies to.

-
-
- - - - - - - - - - - - - - - - - -
FieldDescription
-patch
- - -[]Kubernetes pkg/apis/apiextensions/v1.JSON - - -
-

Patch is the YAML content of a patch.

-
-target
- - -Selector - - -
-

Target points to the resources that the patch is applied to.

-
-
-

PostRenderer

@@ -1674,90 +1508,6 @@ rollback action when it fails.

-

Selector -

-

-(Appears on: -PatchJSON6902) -

-

Selector specifies a set of resources. -Any resource that matches intersection of all conditions -is included in this set.

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescription
-Gvk
- - -Gvk - - -
-

-(Members of Gvk are embedded into this type.) -

-
-namespace
- -string - -
-
-name
- -string - -
-
-annotationSelector
- -string - -
-

AnnotationSelector is a string that follows the label selection expression -https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api -It matches with the resource annotations.

-
-labelSelector
- -string - -
-

LabelSelector is a string that follows the label selection expression -https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api -It matches with the resource labels.

-
-
-

Test

diff --git a/docs/spec/v2beta1/helmreleases.md b/docs/spec/v2beta1/helmreleases.md index 1c320fe59..fa80e61ca 100644 --- a/docs/spec/v2beta1/helmreleases.md +++ b/docs/spec/v2beta1/helmreleases.md @@ -365,30 +365,21 @@ type Uninstall struct { KeepHistory bool `json:"keepHistory,omitempty"` } -// PatchJSON6902 contains a JSON patch and the target it applies to. -type PatchJSON6902 struct { - // Patch is the YAML content of a patch. - Patch []apiextensionsv1.JSON `json:"patch,omitempty" yaml:"patch,omitempty"` - - // Target points to the resources that the patch is applied to. - Target Selector `json:"target,omitempty" yaml:"target,omitempty"` -} - // Kustomize Helm PostRenderer specification. type Kustomize struct { // Strategic merge patches, defined as inline YAML objects. // +optional PatchesStrategicMerge []apiextensionsv1.JSON `json:"patchesStrategicMerge,omitempty"` - // JSON 6902 patches, defined as inline YAML objects. - // +optional - PatchesJSON6902 []PatchJSON6902 `json:"patchesJson6902,omitempty"` + // JSON 6902 patches, defined as inline YAML objects. + // +optional + PatchesJSON6902 []kustomize.JSON6902Patch `json:"patchesJson6902,omitempty"` // Images is a list of (image name, new name, new tag or digest) // for changing image names, tags or digests. This can also be achieved with a // patch, but this operator is simpler to specify. // +optional - Images []Image `json:"images,omitempty" yaml:"images,omitempty"` + Images []kustomize.Image `json:"images,omitempty" yaml:"images,omitempty"` } // PostRenderer contains a Helm PostRenderer specification. @@ -1084,7 +1075,7 @@ spec: postRenderers: # instruct helm-controller to use built-in "kustomize" post renderer. - kustomize: - # Array of inline strategic merge patch definitions as YAML object. + # Array of inline strategic merge patch definitions as YAML object. # Note, this is a YAML object and not a string, to avoid syntax # indention errors. patchesStrategicMerge: @@ -1100,10 +1091,10 @@ spec: operator: "Equal" value: "cluster-services" effect: "NoSchedule" - # Array of inline JSON6902 patch definitions as YAML object. + # Array of inline JSON6902 patch definitions as YAML object. # Note, this is a YAML object and not a string, to avoid syntax # indention errors. - patchesJson6902: + patchesJson6902: - target: version: v1 kind: Deployment diff --git a/go.mod b/go.mod index 7d54aff6d..a3b43523e 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ replace github.com/fluxcd/helm-controller/api => ./api require ( github.com/fluxcd/helm-controller/api v0.6.1 + github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203170140-c9274a8cd235 github.com/fluxcd/pkg/apis/meta v0.7.0 github.com/fluxcd/pkg/runtime v0.8.0 github.com/fluxcd/source-controller/api v0.7.0 diff --git a/go.sum b/go.sum index c25025bd1..4ffae2bcb 100644 --- a/go.sum +++ b/go.sum @@ -241,6 +241,10 @@ github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZM github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203162456-8b60f01eda32 h1:1aMt0EQ7Wd6sJhH/VjNo2l9JvC24zNFi00XF7Hw/A6Q= +github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203162456-8b60f01eda32/go.mod h1:JAFPfnRmcrAoG1gNiA8kmEXsnOBuDyZ/F5X4DAQcVV0= +github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203170140-c9274a8cd235 h1:IBxiuFeaECdJKqBTEHPkQs4wybA9b3rSbRe7w2FAOvk= +github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203170140-c9274a8cd235/go.mod h1:JAFPfnRmcrAoG1gNiA8kmEXsnOBuDyZ/F5X4DAQcVV0= github.com/fluxcd/pkg/apis/meta v0.5.0/go.mod h1:aEUuZIawboAAFLlYz/juVJ7KNmlWbBtJFYkOWWmGUR4= github.com/fluxcd/pkg/apis/meta v0.7.0 h1:5e8gm4OLqjuKWdrOIY5DEEsjcwzyJFK8rCDesJ+V8IY= github.com/fluxcd/pkg/apis/meta v0.7.0/go.mod h1:yHuY8kyGHYz22I0jQzqMMGCcHViuzC/WPdo9Gisk8Po= diff --git a/hack/api-docs/config.json b/hack/api-docs/config.json index 489d1c58b..7971323ac 100644 --- a/hack/api-docs/config.json +++ b/hack/api-docs/config.json @@ -23,6 +23,10 @@ "typeMatchPrefix": "^github.com/fluxcd/pkg/runtime/dependency\\.CrossNamespaceDependencyReference$", "docsURLTemplate": "https://godoc.org/github.com/fluxcd/pkg/runtime/dependency#CrossNamespaceDependencyReference" }, + { + "typeMatchPrefix": "^github.com/fluxcd/pkg/apis/kustomize", + "docsURLTemplate": "https://godoc.org/github.com/fluxcd/pkg/apis/kustomize#{{ .TypeIdentifier }}" + }, { "typeMatchPrefix": "^github.com/fluxcd/pkg/apis/meta", "docsURLTemplate": "https://godoc.org/github.com/fluxcd/pkg/apis/meta#{{ .TypeIdentifier }}" @@ -37,6 +41,7 @@ "k8s.io/apimachinery/pkg/apis/": "Kubernetes ", "k8s.io/apiextensions-apiserver/": "Kubernetes ", "github.com/fluxcd/pkg/runtime/": "Runtime ", + "github.com/fluxcd/pkg/apis/kustomize/": "Kustomize ", "github.com/fluxcd/pkg/apis/meta/": "Meta " }, "markdownDisabled": false diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt index 681f77593..439ccd868 100644 --- a/hack/boilerplate.go.txt +++ b/hack/boilerplate.go.txt @@ -1,5 +1,5 @@ /* -Copyright 2020 The Flux authors +Copyright 2021 The Flux authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/runner/post_renderer.go b/internal/runner/post_renderer.go index 239bbf123..45ad3c501 100644 --- a/internal/runner/post_renderer.go +++ b/internal/runner/post_renderer.go @@ -1,3 +1,19 @@ +/* +Copyright 2021 The Flux authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package runner import ( diff --git a/internal/runner/post_renderer_kustomize.go b/internal/runner/post_renderer_kustomize.go index 4945bfdfb..cc43ec0b1 100644 --- a/internal/runner/post_renderer_kustomize.go +++ b/internal/runner/post_renderer_kustomize.go @@ -1,14 +1,33 @@ +/* +Copyright 2021 The Flux authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package runner import ( "bytes" "encoding/json" - v2 "github.com/fluxcd/helm-controller/api/v2beta1" "sigs.k8s.io/kustomize/api/filesys" "sigs.k8s.io/kustomize/api/konfig" "sigs.k8s.io/kustomize/api/krusty" kustypes "sigs.k8s.io/kustomize/api/types" + + "github.com/fluxcd/pkg/apis/kustomize" + + v2 "github.com/fluxcd/helm-controller/api/v2beta1" ) type postRendererKustomize struct { @@ -45,7 +64,7 @@ func writeFile(fs filesys.FileSystem, path string, content *bytes.Buffer) error return nil } -func adaptImages(images []v2.Image) (output []kustypes.Image) { +func adaptImages(images []kustomize.Image) (output []kustypes.Image) { for _, image := range images { output = append(output, kustypes.Image{ Name: image.Name, @@ -57,12 +76,12 @@ func adaptImages(images []v2.Image) (output []kustypes.Image) { return } -func adaptSelector(selector *v2.Selector) (output *kustypes.Selector) { +func adaptSelector(selector *kustomize.Selector) (output *kustypes.Selector) { if selector != nil { output = &kustypes.Selector{} - output.Gvk.Group = selector.Gvk.Group - output.Gvk.Kind = selector.Gvk.Kind - output.Gvk.Version = selector.Gvk.Version + output.Gvk.Group = selector.Group + output.Gvk.Kind = selector.Kind + output.Gvk.Version = selector.Version output.Name = selector.Name output.Namespace = selector.Namespace output.LabelSelector = selector.LabelSelector diff --git a/internal/runner/runner.go b/internal/runner/runner.go index c4c58ad82..376cfcd20 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -1,5 +1,5 @@ /* -Copyright 2020 The Flux authors +Copyright 2021 The Flux authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.