Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depend on the Kustomize API from fluxcd/pkg #205

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/go.mod
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ module github.com/fluxcd/helm-controller/api
go 1.15

require (
github.com/fluxcd/pkg/apis/kustomize v0.0.1
github.com/fluxcd/pkg/apis/meta v0.7.0
github.com/fluxcd/pkg/runtime v0.6.2
k8s.io/apiextensions-apiserver v0.20.2
9 changes: 2 additions & 7 deletions api/go.sum
Original file line number Diff line number Diff line change
@@ -50,10 +50,8 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -113,6 +111,8 @@ 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.1 h1:TkA80R0GopRY27VJqzKyS6ifiKIAfwBd7OHXtV3t2CI=
github.com/fluxcd/pkg/apis/kustomize v0.0.1/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=
@@ -150,13 +150,11 @@ github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o=
github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8=
github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
@@ -179,7 +177,6 @@ github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dp
github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4=
github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA=
@@ -307,7 +304,6 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
@@ -357,7 +353,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
14 changes: 3 additions & 11 deletions api/v2beta1/helmrelease_types.go
Original file line number Diff line number Diff line change
@@ -25,22 +25,14 @@ 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"
)

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"`
hiddeco marked this conversation as resolved.
Show resolved Hide resolved

// 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.
65 changes: 0 additions & 65 deletions api/v2beta1/kustomization_types.go

This file was deleted.

76 changes: 4 additions & 72 deletions api/v2beta1/zz_generated.deepcopy.go

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

51 changes: 46 additions & 5 deletions config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
Original file line number Diff line number Diff line change
@@ -250,44 +250,85 @@ 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
follows the label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
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
the label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
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:
20 changes: 19 additions & 1 deletion controllers/helmrelease_types_test.go
Original file line number Diff line number Diff line change
@@ -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)
258 changes: 4 additions & 254 deletions docs/api/helmrelease.md
Original file line number Diff line number Diff line change
@@ -422,58 +422,6 @@ string
<h3 id="helm.toolkit.fluxcd.io/v2beta1.DeploymentAction">DeploymentAction
</h3>
<p>DeploymentAction defines a consistent interface for Install and Upgrade.</p>
<h3 id="helm.toolkit.fluxcd.io/v2beta1.Gvk">Gvk
</h3>
<p>
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.Selector">Selector</a>)
</p>
<p>Gvk identifies a Kubernetes API type.
<a href="https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md">https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md</a></p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>group</code><br>
<em>
string
</em>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>version</code><br>
<em>
string
</em>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>kind</code><br>
<em>
string
</em>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="helm.toolkit.fluxcd.io/v2beta1.HelmChartTemplate">HelmChartTemplate
</h3>
<p>
@@ -1114,73 +1062,6 @@ state. It is reset after a successful reconciliation.</p>
</table>
</div>
</div>
<h3 id="helm.toolkit.fluxcd.io/v2beta1.Image">Image
</h3>
<p>
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.Kustomize">Kustomize</a>)
</p>
<p>Image contains an image name, a new name, a new tag or digest,
which will replace the original name and tag.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>name</code><br>
<em>
string
</em>
</td>
<td>
<p>Name is a tag-less image name.</p>
</td>
</tr>
<tr>
<td>
<code>newName</code><br>
<em>
string
</em>
</td>
<td>
<p>NewName is the value used to replace the original name.</p>
</td>
</tr>
<tr>
<td>
<code>newTag</code><br>
<em>
string
</em>
</td>
<td>
<p>NewTag is the value used to replace the original tag.</p>
</td>
</tr>
<tr>
<td>
<code>digest</code><br>
<em>
string
</em>
</td>
<td>
<p>Digest is the value used to replace the original image tag.
If digest is present NewTag value is ignored.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="helm.toolkit.fluxcd.io/v2beta1.Install">Install
</h3>
<p>
@@ -1450,8 +1331,8 @@ the HelmRelease.</p>
<td>
<code>patchesJson6902</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.PatchJSON6902">
[]PatchJSON6902
<a href="https://godoc.org/github.com/fluxcd/pkg/apis/kustomize#JSON6902Patch">
[]github.com/fluxcd/pkg/apis/kustomize.JSON6902Patch
</a>
</em>
</td>
@@ -1464,8 +1345,8 @@ the HelmRelease.</p>
<td>
<code>images</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.Image">
[]Image
<a href="https://godoc.org/github.com/fluxcd/pkg/apis/kustomize#Image">
[]github.com/fluxcd/pkg/apis/kustomize.Image
</a>
</em>
</td>
@@ -1480,53 +1361,6 @@ patch, but this operator is simpler to specify.</p>
</table>
</div>
</div>
<h3 id="helm.toolkit.fluxcd.io/v2beta1.PatchJSON6902">PatchJSON6902
</h3>
<p>
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.Kustomize">Kustomize</a>)
</p>
<p>PatchJSON6902 contains a JSON patch and the target it applies to.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>patch</code><br>
<em>
<a href="https://pkg.go.dev/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1?tab=doc#JSON">
[]Kubernetes pkg/apis/apiextensions/v1.JSON
</a>
</em>
</td>
<td>
<p>Patch is the YAML content of a patch.</p>
</td>
</tr>
<tr>
<td>
<code>target</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.Selector">
Selector
</a>
</em>
</td>
<td>
<p>Target points to the resources that the patch is applied to.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="helm.toolkit.fluxcd.io/v2beta1.PostRenderer">PostRenderer
</h3>
<p>
@@ -1674,90 +1508,6 @@ rollback action when it fails.</p>
</table>
</div>
</div>
<h3 id="helm.toolkit.fluxcd.io/v2beta1.Selector">Selector
</h3>
<p>
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.PatchJSON6902">PatchJSON6902</a>)
</p>
<p>Selector specifies a set of resources.
Any resource that matches intersection of all conditions
is included in this set.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>Gvk</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.Gvk">
Gvk
</a>
</em>
</td>
<td>
<p>
(Members of <code>Gvk</code> are embedded into this type.)
</p>
</td>
</tr>
<tr>
<td>
<code>namespace</code><br>
<em>
string
</em>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>name</code><br>
<em>
string
</em>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>annotationSelector</code><br>
<em>
string
</em>
</td>
<td>
<p>AnnotationSelector is a string that follows the label selection expression
<a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api">https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api</a>
It matches with the resource annotations.</p>
</td>
</tr>
<tr>
<td>
<code>labelSelector</code><br>
<em>
string
</em>
</td>
<td>
<p>LabelSelector is a string that follows the label selection expression
<a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api">https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api</a>
It matches with the resource labels.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="helm.toolkit.fluxcd.io/v2beta1.Test">Test
</h3>
<p>
58 changes: 24 additions & 34 deletions docs/spec/v2beta1/helmreleases.md
Original file line number Diff line number Diff line change
@@ -365,15 +365,6 @@ 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.
@@ -382,13 +373,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.
@@ -1082,11 +1073,11 @@ spec:
namespace: kube-system
interval: 1m
postRenderers:
# instruct helm-controller to use built-in "kustomize" post renderer.
- kustomize:
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.
# Instruct helm-controller to use built-in "kustomize" post renderer.
- kustomize:
# 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:
- kind: Deployment
apiVersion: apps/v1
@@ -1099,24 +1090,23 @@ spec:
- key: "workload-type"
operator: "Equal"
value: "cluster-services"
effect: "NoSchedule"
# 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:
- target:
version: v1
kind: Deployment
name: metrics-server
patch:
- op: add
path: /spec/template/priorityClassName
value: system-cluster-critical
images:
- name: docker.io/bitnami/metrics-server
newName: docker.io/bitnami/metrics-server
newTag: 0.4.1-debian-10-r54
effect: "NoSchedule"
# 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:
- target:
version: v1
kind: Deployment
name: metrics-server
patch:
- op: add
path: /spec/template/priorityClassName
value: system-cluster-critical
images:
- name: docker.io/bitnami/metrics-server
newName: docker.io/bitnami/metrics-server
newTag: 0.4.1-debian-10-r54
```

## Status
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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.1
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
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
@@ -241,6 +241,8 @@ 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.1 h1:TkA80R0GopRY27VJqzKyS6ifiKIAfwBd7OHXtV3t2CI=
github.com/fluxcd/pkg/apis/kustomize v0.0.1/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=
@@ -316,7 +318,6 @@ github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nA
github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY=
github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc=
github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
github.com/go-openapi/spec v0.19.5 h1:Xm0Ao53uqnk9QE/LlYV5DEU09UAgpliA85QoT9LzqPw=
github.com/go-openapi/spec v0.19.5/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk=
@@ -595,12 +596,10 @@ github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7
github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
5 changes: 5 additions & 0 deletions hack/api-docs/config.json
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 16 additions & 0 deletions internal/runner/post_renderer.go
Original file line number Diff line number Diff line change
@@ -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 (
31 changes: 25 additions & 6 deletions internal/runner/post_renderer_kustomize.go
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion internal/runner/runner.go
Original file line number Diff line number Diff line change
@@ -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.