Merge branch 'master' into krm-function-converter

This commit is contained in:
Jeff Regan
2020-11-21 06:10:25 -08:00
committed by GitHub
11 changed files with 317 additions and 18 deletions

View File

@@ -317,6 +317,7 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/securego/gosec v0.0.0-20191002120514-e680875ea14d/go.mod h1:w5+eXa0mYznDkHaMCXA4XYffjlH+cy1oyKbfzJXa2Do=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=

View File

@@ -568,7 +568,7 @@ func (m *resWrangler) Select(s types.Selector) ([]*resource.Resource, error) {
func (m *resWrangler) ToRNodeSlice() ([]*kyaml_yaml.RNode, error) {
var rnodes []*kyaml_yaml.RNode
for _, r := range m.Resources() {
s, err := r.MarshalJSON()
s, err := r.AsYAML()
if err != nil {
return nil, err
}

View File

@@ -16,7 +16,6 @@ import (
"sigs.k8s.io/kustomize/api/resource"
resmaptest_test "sigs.k8s.io/kustomize/api/testutils/resmaptest"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/yaml"
)
var rf = resource.NewFactory(
@@ -769,11 +768,7 @@ rules:
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
y, err := yaml.JSONToYAML([]byte(s))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
b.WriteString(string(y))
b.WriteString(s)
}
if !reflect.DeepEqual(input, b.String()) {

View File

@@ -131,7 +131,11 @@ func TestTransformerConverter(t *testing.T) {
assert.Equal(t, `apiVersion: config.kubernetes.io/v1beta1
kind: ResourceList
items:
- {"apiVersion": "apps/v1", "kind": "foobar", "metadata": {"name": "whatever", "namespace": "foo"}}
- apiVersion: apps/v1
kind: foobar
metadata:
name: whatever
namespace: foo
functionConfig:
apiVersion: foo-corp.com/v1
kind: FulfillmentCenter
@@ -223,7 +227,10 @@ func TestGeneratorConverter(t *testing.T) {
assert.Equal(t, `apiVersion: config.kubernetes.io/v1beta1
kind: ResourceList
items:
- {"apiVersion": "v1", "kind": "ConfigMap", "metadata": {"name": "staging"}}
- apiVersion: v1
kind: ConfigMap
metadata:
name: staging
functionConfig:
apiVersion: foo-corp.com/v1
kind: FulfillmentCenter

View File

@@ -8,7 +8,7 @@ import (
func init() {
data := "PK\x03\x04\x14\x00\x08\x00\x08\x00\x96\x00sQ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00 \x00go.mod.srcUT\x05\x00\x01\x9c\xb6\xb5_\x84\xce\xc1\xae\x820\x10\x85\xe15\xf3\x14]\xde\xbb`:3T\"\x0b}\x97\x82\x15\x1b\xa8EJI\xf4\xe9\x0dq\xe5B]\x9f/9\x7f\x88\xa7<:\x15\xac\xbf\x02\xf4Q1\xb2\x01\x98\xdd-\xfb\xd9\xa9?(z\xbf\\r\x8b]\x0c:Mg\xaet\x17\xdb\xd9\xaa\x95\x91\x90\xa0H\xbeO8\xec\x13\xfa\xa8\x87\x9c\x96\x18\xfc\xc3i;y\xb5\x12\xd6h>\x89\xe1n\xc3\xb8\x99\x06\xabw\xf3\x1a\x18\x05 \xfe\xb7\x94i\xb4\x9dS\xbf\x8e\xd4\xe1\xf8\xdd\x10R)$\xc4\xcc57\"\xc4\xa5\x95\x9d\x91\xc6\xba\xaa\x15\x03\xcf\x00\x00\x00\xff\xffPK\x07\x08\xb1\xe0\xcew\x9c\x00\x00\x00\n\x01\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00P\xa8sQ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00 \x00main.goUT\x05\x00\x01i\xdd\xb6_\x94TMo\xdc6\x14<\x93\xbf\xe2EE\x0b\xaaXH\xe8-H\xb0\xa7\xd4n\x83\xd6F\xe0\x1a\xbd\x049\xd0\xd4\xe3\x86X~\x08\x8f\x94\x9d\xd4\xd0\x7f/\xa8/\xaf\xd4u\xea\\\x16\xd8\xa7\xe1\xcc\xf0i4u\x0d\xb7\x9fM\x04m,\xc2\x83\xb1\x16\xee\x10Z\n\nc\xc4\x06\xa4o\x00\xdd\x1d6\x0d6\x90\x02\xb4\xb6;\x18/S\xa0\x8a\xf3V\xaa\xa3< \xe8\xce\xab\x07\x92m\x8b\x14Iqn\\\x1b(\x81\xe0\xac\xd0.\x15\x9c\x15!\x16\x9c\xb3\"\x9aC\xac\x8e\xafceB}\xecb\n\xce\xfc\x83\xb5lM}|\x1d\x1blc}\xec|L\xd4\xa9\xe1\xd4\xf3p\xc2\xe8d\xfb\xbf\x98\xd0\x91\xc2\xe7Q\xc7\xaf\xd2\xd9Z\xfbZ\x93t\xf8\x10\xe8\xb8\xc5f@\xc1K\xce\xeb\xda\x07k|\xe2\xf9\xae\xe0\xa4\xf1\xa2\x84G\xce\xee%M;\x81\xd1S\xf5.xm\x0e\x1d\xc9;\x8b\x9c\x8d\xc3K\xa9R\xa0\xaf\xf0f\x0f\x1e\x1fn0^-3Qr\xceF\x86\xdf\xd1\xe6\x0dN\xa8\x0f\xa73\xb1\xe2\xc9G\xe6\xdb\xfdib\xca'~Z\xeeP\xdd\x9c<z\xec\xd7\xd0\xea\xb2\xf3*\x99\xe0G\x9b\xb0\x07'\xdb\x8f1\x91\xf1\x87O\xc6'$-\x15>\xf6\x8f=\xe7L\xb9&S?1\xbf\x0b\xceI\xdf\x88S\xc6\xdd\xf0\xfaE H\x14(\xef$\x0b^\xc9v\x97'\xf9\xfc\xca{u\xbd,\x80\x82\xbb\xb9\x0e\x0d\xfee\x8d\xc2\x15g\xf5>\xa1\x8b%g\xcc\xe8\x81\xe5\xd5\x1e\xbc\xb1\x039#L\x1d\xf9<\xe6\x8c\xf5\x9c\xb1F&yi\xd06\x8b\xe2\x01\xd3\xafyH\xc1\xad\xef+\xbe\xb1\x8b\xef\x91\xfb[\xda\x0e\x17\xb9\x9c\x92\xeaJR\xfc,\xadX\xdc\xbc\x8c\x8f3\x96\x11\xfb)ES|\xc4*\x11;X4_F:`\xd2\x0e\xc21\xdb\x9b\x98\xa7\x0cU\xb7$}\xd4\x81\x1c\xd2\x98\xb1\xf2m\x06\x0e<\xa3\x95\xf4\x84\x11\xe3\xbb\xcc\xb2\xe7t\xd7\xc2\x83r\x0fh#\x82\xd1px\xc6\xc0o\xe8\x91r\x85\xfcG\xfe48{8\xccH\x14\xdf\xa3\xcf\xc7\x04n\xc24\x93\x8e\x12\xd5m8\x89\xdeK\x97:\x0d\xbc\xb1\x9c\xf5%\x9f\xcf\xbc\xd9\x83rMu\xf1\x05U\x97\xbd\xbe\xdd2i\x97\xaa\x0fd|\xb2^ Q\x96\x0b\xb1\xba\xf8b\x92\xf8\xa5\xe4\xac\xe7\xfd\xb6`\xbe\xfd\xfd\xc3\xcf\xd3&\xe7>X\x06\xabCY{\xb2<=\xbe\xde\xd2zcw0\xfcl\n\xe6\x9c\xa3Mom]\x8cr\xe3\xdeO\no\x1ee\xf1\xf9\xec\xd2\xf2y\xf8\xc7\xfc\xa7#l&\xc4{\xd7ZQ\x96g\xfc\xcf\x14\x1b\xa5\xe1\x16gl?\xdf\x04Z\xc1I\xdf\x95 N\xfe\xed\xc62\x1b\x1a^\xcf)\xd6\xaa\x12\xe7\xcbr\x8c\xc2\xab)\xc5O)\xd9A~\xf3\x17\x99J\x8bBO\xfa\xa0\xc6\xea\xfd\xf1\x87{0\x11|Hp/\xadi\x8a\x1dh5\xc4a\xa6\xd0\x1f\x8b\xfc\xe1\x17\x9f\x86\xdb\xf1\x9e\xff\x1b\x00\x00\xff\xffPK\x07\x08\x00\xf5\x0c\xd0\xd7\x02\x00\x00\xad\x07\x00\x00PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\x96\x00sQ\xb1\xe0\xcew\x9c\x00\x00\x00\n\x01\x00\x00\n\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x81\x00\x00\x00\x00go.mod.srcUT\x05\x00\x01\x9c\xb6\xb5_PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00P\xa8sQ\x00\xf5\x0c\xd0\xd7\x02\x00\x00\xad\x07\x00\x00\x07\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x81\xdd\x00\x00\x00main.goUT\x05\x00\x01i\xdd\xb6_PK\x05\x06\x00\x00\x00\x00\x02\x00\x02\x00\x7f\x00\x00\x00\xf2\x03\x00\x00\x00\x00"
data := "PK\x03\x04\x14\x00\x08\x00\x08\x00E\x03uQ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00 \x00go.mod.srcUT\x05\x00\x01\xa2^\xb8_\x84\xce\xb1\xb2\x820\x10\x85\xe1\x9a}\x8a\x94\xf7\x16l6 \x82\x14\xfa. F\xdc\x81\x18$\x84\x19}z\x87\xb1\xb2P\xeb\xf3\xcd\x9c?\xc4S\x1e\xbd\x08\x96\xaf\x00}\x14\nU\x050\xfb[\xe6\xd9\x8b?(z^.\xd9a\x17\x83L\xd3Y\x19\xd9E7[\xb1*$$(\x12\xf7 \x87}B\x8er\xc8i\x89\x81\x1f^\xda\x89\xc5JXc\xf5I\x0cw\x1b\xc6\xcd\xb4h\xde\xcdkP\xa8\x91\xe0\x7fK\x99F\xdby\xf1\xebH\x1c\x8e\xdf\x0d!\x95\x9a4)\xa5I\x1bj\x8c)i\xa7m\xed*\xdf\xd6\x8d\x83g\x00\x00\x00\xff\xffPK\x07\x08\xf0\x039\x0c\x9d\x00\x00\x00\n\x01\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\xfc\xb3tQ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00 \x00main.goUT\x05\x00\x01\xdcC\xb8_\x94TMo\xdb8\x10=\x93\xbfb\xd6\x87\x85\xb40$\xec-H\xe0S\x90\xec\x06m\x82 \xf5\xad\xe8\x81\xa6F\x0e!~\x08C\xaaN\x1a\xe8\xbf\x17\xd4\x87#\xa9N\x9a^\x0cx\xf4\xe6\xbd73\x9c\xc9s\xd8>*\x0f\xa5\xd2\x08\x07\xa55\xec\x10jr\x12\xbd\xc7\x02\x84-\x00\xcd\x0e\x8b\x02\x0b\x08\x0ej\xdd\xec\x95\x15\xc1Q\xc6y-d%\xf6\x08ec\xe5\x81D]#y\x92\x9c+S;\n\x90p\xb6*MXq\xb6r~\xc59[y\xb5\xf7Yu\xe63\xe5\xf2\xaa\xf1\xc1\x19\xf5\x03sQ\xab\xbc:\xf3\x05\xd6>\xaf\x1a\xeb\x035\xb2\xcbz\x1bN\xe8\x8d\xa8\x7f\x8bq\x0dI|\x1bU=\x0b\xa3\xf3\xd2\xe6% \x83\x07G\xd5\x12\x1b\x01+\x9er\x9e\xe7\xd6ie\x03\x8f\xb5\x82\x11\xca&)\xbcp\xf6]\xd0\xd0\x13\xe8=e\x97\xce\x96j\xdf\x90\xd8i\xe4\xac\x0f^\x0b\x19\x1c=\xc3\xf9\x06,\x1e\x1e\xd0\xdf\x1ecI\xca9\xeb\x19\xfeG\x1d;8\xa0\xee\xa7\xb1d\xc6\x13S\xc6\xea>+\x1fb\xc6\xdf\xc7\x1a\xb2\x87\xc9\xa7\x97\x96s&M\x11!\xaf\x88Kg\x8c\xb0E2%YwcLR@\"G\xb1\xb6\xa8q+\xeau\x8c\xc4\xfc\x99\x87\xec\xeeX\x089\xf3p\xe7\n\xfc\xa2\x95\xc4\x19gv\x13\xd0\xf8\x943\xa6\xca\x8e\xe5\xaf\x0dX\xa5;rF\x18\x1a\xb21\xcc\x19k9\x1b\xba\xd0\xf7\xef(\x1aM\x05\xe5\x86\xf0\xd6\xddO@s\xad\xeb\x19\xf2c\xa2\x9c\xb1\x88\xd8\x0c3\x1c\x86\x97\xcc\xe6\xb1\x86\xa9\xb1\x8f\xf1v\x98\xb0\x06W\xc5\x1a\x06\xf2a\x88\xd9\x96\x84\xf5\xa5#\x83\xd4W\x93^D`\xc7\xd3\xbb \xaf\x98\xa4\x1fB\x94=\xa5;\x17\xee\x94[@\xed\x11T \xfb7\x0c\xfc\x87\x16)\xee\xf0/\xf2\xd3\x89o`?\"1\xf9\x13}\xde?\x9d\xc5+\x18I{\x89l\xeb&o\xe6\xa3M\x1d\x02Vi\xce\xda\x94\x8f9\xe7\x1b\x90\xa6\xc8\xae\x9eP6\xd1\xeb\xc5\x92\xa94!\xbb'e\x83\xb6 \x12E9\xe7\xb3\xab'\x15\x92\x7fS\xceZ\xde.7\xfc\xfd\x05\x84\x7f\x86N\x8e\x0by\x0c\xcc\x92\xa2\xf6`y\xf8|\xb7\xa4\xb5J\xaf\xa1\xfbYl\xf8)G\x8b\xc3\xb1t\xd1\xcb\xf5}\x9f\\\x9c1\x14\xc5\xc7\xdc\xe3\x99\x8d\xc1O\xe3\x9f\x86\xb0\x18\x107\xa6\xd6I\x9a\x9e\xf0?R,\x94\xba*N\xd8~w\x7fK \xca\x06\xa4RH|iSH\xbe~\xdb=\x07\\\xf77(\x9d\xf4/\x1e\xe2\xecV\x90\x7f\x14:)e\x14\xfa\x19\x00\x00\xff\xffPK\x07\x08\xd7\xcf\xa4\xce}\x02\x00\x00\xba\x06\x00\x00PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00E\x03uQ\xf0\x039\x0c\x9d\x00\x00\x00\n\x01\x00\x00\n\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x81\x00\x00\x00\x00go.mod.srcUT\x05\x00\x01\xa2^\xb8_PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\xfc\xb3tQ\xd7\xcf\xa4\xce}\x02\x00\x00\xba\x06\x00\x00\x07\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x81\xde\x00\x00\x00main.goUT\x05\x00\x01\xdcC\xb8_PK\x05\x06\x00\x00\x00\x00\x02\x00\x02\x00\x7f\x00\x00\x00\x99\x03\x00\x00\x00\x00"
fs.Register(data)
}

View File

@@ -9,4 +9,4 @@ require (
sigs.k8s.io/yaml v1.2.0
)
replace sigs.k8s.io/kustomize/api v0.6.4 => sigs.k8s.io/kustomize/api v0.0.0-20201116192201-a25429ae3b24
replace sigs.k8s.io/kustomize/api v0.6.4 => sigs.k8s.io/kustomize/api v0.0.0-20201120230733-052a6b4e967b

View File

@@ -11,7 +11,6 @@ in the [multibases](multibases/README.md) example. There's
one pod in the output:
<!-- @remoteOverlayBuild @testAgainstLatestRelease -->
```
target="github.com/kubernetes-sigs/kustomize/examples/multibases/dev/?ref=v1.0.6"
test 1 == \

View File

@@ -0,0 +1,60 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package framework
import (
"bytes"
"text/template"
"sigs.k8s.io/kustomize/kyaml/errors"
"sigs.k8s.io/kustomize/kyaml/sets"
"sigs.k8s.io/kustomize/kyaml/yaml"
"sigs.k8s.io/kustomize/kyaml/yaml/merge2"
)
// PatchTemplateContainers executes t as a template and patches each container in each resource
// with the result.
func PatchTemplateContainers(resources []*yaml.RNode, t string, input interface{}, containers ...string) error {
resourcePatch := template.Must(template.New("containers").Parse(t))
var b bytes.Buffer
if err := resourcePatch.Execute(&b, input); err != nil {
return errors.Wrap(err)
}
patch, err := yaml.Parse(b.String())
if err != nil {
return errors.WrapPrefixf(err, b.String())
}
return PatchContainers(resources, patch, containers...)
}
// PatchContainers applies patch to each container in each resource.
func PatchContainers(resources []*yaml.RNode, patch *yaml.RNode, containers ...string) error {
names := sets.String{}
names.Insert(containers...)
for i := range resources {
containers, err := resources[i].Pipe(yaml.Lookup("spec", "template", "spec", "containers"))
if err != nil {
return errors.Wrap(err)
}
if containers == nil {
continue
}
err = containers.VisitElements(func(node *yaml.RNode) error {
f := node.Field("name")
if f == nil {
return nil
}
if names.Len() > 0 && !names.Has(yaml.GetValue(f.Value)) {
return nil
}
_, err := merge2.Merge(patch, node, yaml.MergeOptions{})
return errors.Wrap(err)
})
if err != nil {
return errors.Wrap(err)
}
}
return nil
}

View File

@@ -6,12 +6,14 @@ package framework_test
import (
"bytes"
"fmt"
"log"
"os"
"path/filepath"
"text/template"
"github.com/spf13/pflag"
"sigs.k8s.io/kustomize/kyaml/fn/framework"
"sigs.k8s.io/kustomize/kyaml/kio"
"sigs.k8s.io/kustomize/kyaml/yaml"
)
@@ -890,3 +892,226 @@ metadata:
// key: bar
// config.kubernetes.io/index: '1'
}
// ExamplePatchTemplateContainers_names patches all containers.
func ExamplePatchTemplateContainers() {
resources, err := kio.ParseAll(`
apiVersion: apps/v1
kind: Deployment
metadata:
name: foo
spec:
template:
spec:
containers:
- name: foo
image: a
- name: bar
image: b
---
apiVersion: v1
kind: Service
metadata:
name: foo
spec:
selector:
foo: bar
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: bar
spec:
template:
spec:
containers:
- name: foo
image: a
- name: baz
image: b
---
apiVersion: v1
kind: Service
metadata:
name: bar
spec:
selector:
foo: bar
`)
if err != nil {
log.Fatal(err)
}
input := struct{ Value string }{Value: "new-value"}
err = framework.PatchTemplateContainers(resources, `
env:
KEY: {{ .Value }}
`, input)
if err != nil {
log.Fatal(err)
}
fmt.Println(kio.StringAll(resources))
// Output:
// apiVersion: apps/v1
// kind: Deployment
// metadata:
// name: foo
// spec:
// template:
// spec:
// containers:
// - name: foo
// image: a
// env:
// KEY: new-value
// - name: bar
// image: b
// env:
// KEY: new-value
// ---
// apiVersion: v1
// kind: Service
// metadata:
// name: foo
// spec:
// selector:
// foo: bar
// ---
// apiVersion: apps/v1
// kind: Deployment
// metadata:
// name: bar
// spec:
// template:
// spec:
// containers:
// - name: foo
// image: a
// env:
// KEY: new-value
// - name: baz
// image: b
// env:
// KEY: new-value
// ---
// apiVersion: v1
// kind: Service
// metadata:
// name: bar
// spec:
// selector:
// foo: bar
// <nil>
}
// ExamplePatchTemplateContainers_names patches containers matching
// a specific name.
func ExamplePatchTemplateContainers_names() {
resources, err := kio.ParseAll(`
apiVersion: apps/v1
kind: Deployment
metadata:
name: foo
spec:
template:
spec:
containers:
- name: foo
image: a
- name: bar
image: b
---
apiVersion: v1
kind: Service
metadata:
name: foo
spec:
selector:
foo: bar
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: bar
spec:
template:
spec:
containers:
- name: foo
image: a
- name: baz
image: b
---
apiVersion: v1
kind: Service
metadata:
name: bar
spec:
selector:
foo: bar
`)
if err != nil {
log.Fatal(err)
}
input := struct{ Value string }{Value: "new-value"}
err = framework.PatchTemplateContainers(resources, `
env:
KEY: {{ .Value }}
`, input, "foo")
if err != nil {
log.Fatal(err)
}
fmt.Println(kio.StringAll(resources))
// Output:
// apiVersion: apps/v1
// kind: Deployment
// metadata:
// name: foo
// spec:
// template:
// spec:
// containers:
// - name: foo
// image: a
// env:
// KEY: new-value
// - name: bar
// image: b
// ---
// apiVersion: v1
// kind: Service
// metadata:
// name: foo
// spec:
// selector:
// foo: bar
// ---
// apiVersion: apps/v1
// kind: Deployment
// metadata:
// name: bar
// spec:
// template:
// spec:
// containers:
// - name: foo
// image: a
// env:
// KEY: new-value
// - name: baz
// image: b
// ---
// apiVersion: v1
// kind: Service
// metadata:
// name: bar
// spec:
// selector:
// foo: bar
// <nil>
}

View File

@@ -78,6 +78,20 @@ func (rw *ByteReadWriter) Write(nodes []*yaml.RNode) error {
}.Write(nodes)
}
// ParseAll reads all of the inputs into resources
func ParseAll(inputs ...string) ([]*yaml.RNode, error) {
return (&ByteReader{
Reader: bytes.NewBufferString(strings.Join(inputs, "\n---\n")),
}).Read()
}
// StringAll writes all of the resources to a string
func StringAll(resources []*yaml.RNode) (string, error) {
var b bytes.Buffer
err := (&ByteWriter{Writer: &b}).Write(resources)
return b.String(), err
}
// ByteReader decodes ResourceNodes from bytes.
// By default, Read will set the config.kubernetes.io/index annotation on each RNode as it
// is read so they can be written back in the same order.

View File

@@ -34,15 +34,13 @@ echo "Remaining args: $remainingArgs"
module=${fullTag%/*}
echo "module=$module"
# Obtain most recent commit hash associated with the module.
lastCommitHash=$(
git log --tags=$module -1 \
--oneline --no-walk --pretty=format:%h)
# Find previous tag that matches the tags module
prevTag=$(git tag -l "$module*" --sort=-version:refname --no-contains=$fullTag | head -n 1)
# Generate the changelog for this release
# using commit hashes and commit messages.
# using the last two tags for the module
changeLogFile=$(mktemp)
git log $lastCommitHash.. \
git log $prevTag..$fullTag \
--pretty=oneline \
--abbrev-commit --no-decorate --no-color --no-merges \
-- $module > $changeLogFile