Skip to content

Commit 30227ce

Browse files
committed
Depend on the Kustomize API from fluxcd/pkg
Signed-off-by: Hidde Beydals <hello@hidde.co>
1 parent d753d56 commit 30227ce

16 files changed

+141
-432
lines changed

api/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/fluxcd/helm-controller/api
33
go 1.15
44

55
require (
6+
github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203170140-c9274a8cd235
67
github.com/fluxcd/pkg/apis/meta v0.7.0
78
github.com/fluxcd/pkg/runtime v0.6.2
89
k8s.io/apiextensions-apiserver v0.20.2

api/go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
113113
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
114114
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
115115
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
116+
github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203162456-8b60f01eda32 h1:1aMt0EQ7Wd6sJhH/VjNo2l9JvC24zNFi00XF7Hw/A6Q=
117+
github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203162456-8b60f01eda32/go.mod h1:JAFPfnRmcrAoG1gNiA8kmEXsnOBuDyZ/F5X4DAQcVV0=
118+
github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203170140-c9274a8cd235 h1:IBxiuFeaECdJKqBTEHPkQs4wybA9b3rSbRe7w2FAOvk=
119+
github.com/fluxcd/pkg/apis/kustomize v0.0.0-20210203170140-c9274a8cd235/go.mod h1:JAFPfnRmcrAoG1gNiA8kmEXsnOBuDyZ/F5X4DAQcVV0=
116120
github.com/fluxcd/pkg/apis/meta v0.5.0/go.mod h1:aEUuZIawboAAFLlYz/juVJ7KNmlWbBtJFYkOWWmGUR4=
117121
github.com/fluxcd/pkg/apis/meta v0.7.0 h1:5e8gm4OLqjuKWdrOIY5DEEsjcwzyJFK8rCDesJ+V8IY=
118122
github.com/fluxcd/pkg/apis/meta v0.7.0/go.mod h1:yHuY8kyGHYz22I0jQzqMMGCcHViuzC/WPdo9Gisk8Po=

api/v2beta1/helmrelease_types.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,14 @@ import (
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/apimachinery/pkg/types"
2727

28+
"github.com/fluxcd/pkg/apis/kustomize"
2829
"github.com/fluxcd/pkg/apis/meta"
2930
"github.com/fluxcd/pkg/runtime/dependency"
3031
)
3132

3233
const HelmReleaseKind = "HelmRelease"
3334
const HelmReleaseFinalizer = "finalizers.fluxcd.io"
3435

35-
// PatchJSON6902 contains a JSON patch and the target it applies to.
36-
type PatchJSON6902 struct {
37-
// Patch is the YAML content of a patch.
38-
Patch []apiextensionsv1.JSON `json:"patch,omitempty" yaml:"patch,omitempty"`
39-
40-
// Target points to the resources that the patch is applied to.
41-
Target Selector `json:"target,omitempty" yaml:"target,omitempty"`
42-
}
43-
4436
// Kustomize Helm PostRenderer specification.
4537
type Kustomize struct {
4638
// Strategic merge patches, defined as inline YAML objects.
@@ -49,13 +41,13 @@ type Kustomize struct {
4941

5042
// JSON 6902 patches, defined as inline YAML objects.
5143
// +optional
52-
PatchesJSON6902 []PatchJSON6902 `json:"patchesJson6902,omitempty"`
44+
PatchesJSON6902 []kustomize.JSON6902Patch `json:"patchesJson6902,omitempty"`
5345

5446
// Images is a list of (image name, new name, new tag or digest)
5547
// for changing image names, tags or digests. This can also be achieved with a
5648
// patch, but this operator is simpler to specify.
5749
// +optional
58-
Images []Image `json:"images,omitempty" yaml:"images,omitempty"`
50+
Images []kustomize.Image `json:"images,omitempty" yaml:"images,omitempty"`
5951
}
6052

6153
// PostRenderer contains a Helm PostRenderer specification.

api/v2beta1/kustomization_types.go

-65
This file was deleted.

api/v2beta1/zz_generated.deepcopy.go

+4-72
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml

+46-5
Original file line numberDiff line numberDiff line change
@@ -250,44 +250,85 @@ spec:
250250
description: NewTag is the value used to replace the
251251
original tag.
252252
type: string
253+
required:
254+
- name
253255
type: object
254256
type: array
255257
patchesJson6902:
256258
description: JSON 6902 patches, defined as inline YAML objects.
257259
items:
258-
description: PatchJSON6902 contains a JSON patch and the
259-
target it applies to.
260+
description: JSON6902Patch contains a JSON6902 patch and
261+
the target the patch should be applied to.
260262
properties:
261263
patch:
262-
description: Patch is the YAML content of a patch.
264+
description: Patch contains the JSON6902 patch document
265+
with an array of operation objects.
263266
items:
264-
x-kubernetes-preserve-unknown-fields: true
267+
description: JSON6902 is a JSON6902 operation object.
268+
https://tools.ietf.org/html/rfc6902#section-4
269+
properties:
270+
from:
271+
type: string
272+
op:
273+
enum:
274+
- test
275+
- remove
276+
- add
277+
- replace
278+
- move
279+
- copy
280+
type: string
281+
path:
282+
type: string
283+
value:
284+
x-kubernetes-preserve-unknown-fields: true
285+
required:
286+
- op
287+
- path
288+
type: object
265289
type: array
266290
target:
267291
description: Target points to the resources that the
268-
patch is applied to.
292+
patch document should be applied to.
269293
properties:
270294
annotationSelector:
271295
description: AnnotationSelector is a string that
272296
follows the label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
273297
It matches with the resource annotations.
274298
type: string
275299
group:
300+
description: Group is the API group to select
301+
resources from. Together with Version and Kind
302+
it is capable of unambiguously identifying and/or
303+
selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
276304
type: string
277305
kind:
306+
description: Kind of the API Group to select resources
307+
from. Together with Group and Version it is
308+
capable of unambiguously identifying and/or
309+
selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
278310
type: string
279311
labelSelector:
280312
description: LabelSelector is a string that follows
281313
the label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
282314
It matches with the resource labels.
283315
type: string
284316
name:
317+
description: Name to match resources with.
285318
type: string
286319
namespace:
320+
description: Namespace to select resources from.
287321
type: string
288322
version:
323+
description: Version of the API Group to select
324+
resources from. Together with Group and Kind
325+
it is capable of unambiguously identifying and/or
326+
selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
289327
type: string
290328
type: object
329+
required:
330+
- patch
331+
- target
291332
type: object
292333
type: array
293334
patchesStrategicMerge:

controllers/helmrelease_types_test.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1+
/*
2+
Copyright 2021 The Flux authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package controllers
218

319
import (
420
"encoding/json"
521
"testing"
622

23+
"github.com/fluxcd/pkg/apis/kustomize"
24+
725
v2 "github.com/fluxcd/helm-controller/api/v2beta1"
826
)
927

1028
func TestHelmReleaseTypes_unmarshal_PatchJSON6902(t *testing.T) {
11-
var p v2.PatchJSON6902
29+
var p kustomize.JSON6902Patch
1230
err := json.Unmarshal([]byte(`{"target": {"namespace": "ns", "name": "x", "kind": "k", "version": "v"},"patch": [{"op": "add", "path": "/some/new/path", "value": "value"}]}`), &p)
1331
if err != nil {
1432
t.Error(err)

0 commit comments

Comments
 (0)