Update inflate/diff and corresponding tests
This commit is contained in:
parent
a80049d5e6
commit
97859f4abd
|
|
@ -41,7 +41,7 @@ Find more information at:
|
|||
}
|
||||
|
||||
c.AddCommand(
|
||||
newCmdInflate(stdOut, stdErr),
|
||||
newCmdInflate(stdOut, stdErr, fsys),
|
||||
newCmdDiff(stdOut, stdErr, fsys),
|
||||
newCmdInit(stdOut, stdErr, fsys),
|
||||
// 'add' sub command
|
||||
|
|
|
|||
|
|
@ -19,10 +19,13 @@ package commands
|
|||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/kubectl/pkg/kinflate/app"
|
||||
"k8s.io/kubectl/pkg/kinflate/types"
|
||||
"k8s.io/kubectl/pkg/loader"
|
||||
|
||||
"k8s.io/kubectl/pkg/kinflate/tree"
|
||||
"k8s.io/kubectl/pkg/kinflate/util"
|
||||
"k8s.io/kubectl/pkg/kinflate/util/fs"
|
||||
"k8s.io/utils/exec"
|
||||
|
|
@ -72,7 +75,7 @@ func (o *diffOptions) Complete(cmd *cobra.Command, args []string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// RunInit writes a manifest file.
|
||||
// RunDiff gets the differences between Application.Resources() and Application.RawResources().
|
||||
func (o *diffOptions) RunDiff(out, errOut io.Writer, fs fs.FileSystem) error {
|
||||
printer := util.Printer{}
|
||||
diff := util.DiffProgram{
|
||||
|
|
@ -81,23 +84,38 @@ func (o *diffOptions) RunDiff(out, errOut io.Writer, fs fs.FileSystem) error {
|
|||
Stderr: errOut,
|
||||
}
|
||||
|
||||
inflateOp := inflateOptions{manifestPath: o.manifestPath, mode: tree.ModeNormal}
|
||||
kobj1, err := inflateOp.runInflate(fs)
|
||||
l := loader.Init([]loader.SchemeLoader{loader.NewFileLoader(fs)})
|
||||
|
||||
absPath, err := filepath.Abs(o.manifestPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
transformedDir, err := util.WriteToDir(kobj1, "transformed", printer)
|
||||
|
||||
rootLoader, err := l.New(absPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
application, err := app.New(rootLoader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resources, err := application.Resources()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rawResources, err := application.RawResources()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
transformedDir, err := util.WriteToDir(types.KObject(resources), "transformed", printer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer transformedDir.Delete()
|
||||
|
||||
inflateNoOp := inflateOptions{manifestPath: o.manifestPath, mode: tree.ModeNoop}
|
||||
kobj2, err := inflateNoOp.runInflate(fs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
noopDir, err := util.WriteToDir(kobj2, "noop", printer)
|
||||
noopDir, err := util.WriteToDir(types.KObject(rawResources), "noop", printer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
Copyright 2018 The Kubernetes 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 commands
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/kubectl/pkg/kinflate/util/fs"
|
||||
)
|
||||
|
||||
type DiffTestCase struct {
|
||||
Description string `yaml:"description"`
|
||||
Args []string `yaml:"args"`
|
||||
Filename string `yaml:"filename"`
|
||||
// path to the file that contains the expected output
|
||||
ExpectedDiff string `yaml:"expectedDiff"`
|
||||
}
|
||||
|
||||
func TestDiff(t *testing.T) {
|
||||
const updateEnvVar = "UPDATE_KINFLATE_EXPECTED_DATA"
|
||||
updateKinflateExpected := os.Getenv(updateEnvVar) == "true"
|
||||
|
||||
noopDir, _ := regexp.Compile(`/tmp/noop-[0-9]*/`)
|
||||
transformedDir, _ := regexp.Compile(`/tmp/transformed-[0-9]*/`)
|
||||
timestamp, _ := regexp.Compile(`[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9].[0-9]* [+-]{1}[0-9]{4}`)
|
||||
|
||||
fs := fs.MakeRealFS()
|
||||
|
||||
testcases := sets.NewString()
|
||||
filepath.Walk("testdata", func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if path == "testdata" {
|
||||
return nil
|
||||
}
|
||||
name := filepath.Base(path)
|
||||
if info.IsDir() {
|
||||
if strings.HasPrefix(name, "testcase-") {
|
||||
testcases.Insert(strings.TrimPrefix(name, "testcase-"))
|
||||
}
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
})
|
||||
// sanity check that we found the right folder
|
||||
if !testcases.Has("simple") {
|
||||
t.Fatalf("Error locating kinflate inflate testcases")
|
||||
}
|
||||
|
||||
for _, testcaseName := range testcases.List() {
|
||||
t.Run(testcaseName, func(t *testing.T) {
|
||||
name := testcaseName
|
||||
testcase := DiffTestCase{}
|
||||
testcaseDir := filepath.Join("testdata", "testcase-"+name)
|
||||
testcaseData, err := ioutil.ReadFile(filepath.Join(testcaseDir, "test.yaml"))
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
if err := yaml.Unmarshal(testcaseData, &testcase); err != nil {
|
||||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
|
||||
diffOps := &diffOptions{
|
||||
manifestPath: testcase.Filename,
|
||||
}
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
err = diffOps.RunDiff(buf, os.Stderr, fs)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
actualString := string(buf.Bytes())
|
||||
actualString = noopDir.ReplaceAllString(actualString, "/tmp/noop/")
|
||||
actualString = transformedDir.ReplaceAllString(actualString, "/tmp/transformed/")
|
||||
actualString = timestamp.ReplaceAllString(actualString, "YYYY-MM-DD HH:MM:SS")
|
||||
actualBytes := []byte(actualString)
|
||||
if !updateKinflateExpected {
|
||||
expectedBytes, err := ioutil.ReadFile(testcase.ExpectedDiff)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(actualBytes, expectedBytes) {
|
||||
t.Errorf("%s\ndoesn't equal expected:\n%s\n", actualBytes, expectedBytes)
|
||||
}
|
||||
} else {
|
||||
ioutil.WriteFile(testcase.ExpectedDiff, actualBytes, 0644)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -23,23 +23,20 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/kubectl/pkg/kinflate/types"
|
||||
|
||||
"k8s.io/kubectl/pkg/kinflate/app"
|
||||
"k8s.io/kubectl/pkg/kinflate/tree"
|
||||
"k8s.io/kubectl/pkg/kinflate/types"
|
||||
kutil "k8s.io/kubectl/pkg/kinflate/util"
|
||||
"k8s.io/kubectl/pkg/kinflate/util/fs"
|
||||
"k8s.io/kubectl/pkg/loader"
|
||||
)
|
||||
|
||||
type inflateOptions struct {
|
||||
outputdir string
|
||||
manifestPath string
|
||||
mode tree.ModeType
|
||||
}
|
||||
|
||||
// newCmdInflate creates a new inflate command.
|
||||
func newCmdInflate(out, errOut io.Writer) *cobra.Command {
|
||||
func newCmdInflate(out, errOut io.Writer, fs fs.FileSystem) *cobra.Command {
|
||||
var o inflateOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
|
|
@ -60,7 +57,7 @@ func newCmdInflate(out, errOut io.Writer) *cobra.Command {
|
|||
fmt.Fprintf(errOut, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = o.RunInflate(out, errOut)
|
||||
err = o.RunInflate(out, errOut, fs)
|
||||
if err != nil {
|
||||
fmt.Fprintf(errOut, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
|
@ -80,54 +77,36 @@ func (o *inflateOptions) Validate(cmd *cobra.Command, args []string) error {
|
|||
|
||||
// Complete completes inflate command.
|
||||
func (o *inflateOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
o.mode = tree.ModeNormal
|
||||
return nil
|
||||
}
|
||||
|
||||
// runInflate does the real transformation.
|
||||
func (o *inflateOptions) runInflate(fs fs.FileSystem) (types.KObject, error) {
|
||||
// RunInflate runs inflate command (do real work).
|
||||
func (o *inflateOptions) RunInflate(out, errOut io.Writer, fs fs.FileSystem) error {
|
||||
l := loader.Init([]loader.SchemeLoader{loader.NewFileLoader(fs)})
|
||||
|
||||
absPath, err := filepath.Abs(o.manifestPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
rootLoader, err := l.New(absPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
application, err := app.New(rootLoader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
allResources := types.ResourceCollection{}
|
||||
switch o.mode {
|
||||
case tree.ModeNormal:
|
||||
allResources, err = application.Resources()
|
||||
case tree.ModeNoop:
|
||||
allResources, err = application.RawResources()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
allResources, err := application.Resources()
|
||||
|
||||
return types.KObject(allResources), nil
|
||||
}
|
||||
|
||||
// RunInflate runs inflate command (do real work).
|
||||
func (o *inflateOptions) RunInflate(out, errOut io.Writer) error {
|
||||
fs := fs.MakeRealFS()
|
||||
|
||||
kobj, err := o.runInflate(fs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Output the objects.
|
||||
res, err := kutil.Encode(kobj)
|
||||
res, err := kutil.Encode(types.KObject(allResources))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,14 +28,13 @@ import (
|
|||
"github.com/ghodss/yaml"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/kubectl/pkg/kinflate/tree"
|
||||
"k8s.io/kubectl/pkg/kinflate/util/fs"
|
||||
)
|
||||
|
||||
type InflateTestCase struct {
|
||||
Description string `yaml:"description"`
|
||||
Args []string `yaml:"args"`
|
||||
Filename string `yaml:"filename"`
|
||||
Mode tree.ModeType `yaml:"mode"`
|
||||
Description string `yaml:"description"`
|
||||
Args []string `yaml:"args"`
|
||||
Filename string `yaml:"filename"`
|
||||
// path to the file that contains the expected output
|
||||
ExpectedStdout string `yaml:"expectedStdout"`
|
||||
}
|
||||
|
|
@ -43,11 +42,7 @@ type InflateTestCase struct {
|
|||
func TestInflate(t *testing.T) {
|
||||
const updateEnvVar = "UPDATE_KINFLATE_EXPECTED_DATA"
|
||||
updateKinflateExpected := os.Getenv(updateEnvVar) == "true"
|
||||
|
||||
var (
|
||||
name string
|
||||
testcase InflateTestCase
|
||||
)
|
||||
fs := fs.MakeRealFS()
|
||||
|
||||
testcases := sets.NewString()
|
||||
filepath.Walk("testdata", func(path string, info os.FileInfo, err error) error {
|
||||
|
|
@ -73,8 +68,8 @@ func TestInflate(t *testing.T) {
|
|||
|
||||
for _, testcaseName := range testcases.List() {
|
||||
t.Run(testcaseName, func(t *testing.T) {
|
||||
name = testcaseName
|
||||
testcase = InflateTestCase{}
|
||||
name := testcaseName
|
||||
testcase := InflateTestCase{}
|
||||
testcaseDir := filepath.Join("testdata", "testcase-"+name)
|
||||
testcaseData, err := ioutil.ReadFile(filepath.Join(testcaseDir, "test.yaml"))
|
||||
if err != nil {
|
||||
|
|
@ -84,15 +79,11 @@ func TestInflate(t *testing.T) {
|
|||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
|
||||
if testcase.Mode == "" {
|
||||
testcase.Mode = tree.ModeNormal
|
||||
}
|
||||
ops := &inflateOptions{
|
||||
manifestPath: testcase.Filename,
|
||||
mode: testcase.Mode,
|
||||
}
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
err = ops.RunInflate(buf, os.Stderr)
|
||||
err = ops.RunInflate(buf, os.Stderr, fs)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
diff -u -N /tmp/noop/apps_v1beta2_Deployment_nginx.yaml /tmp/transformed/apps_v1beta2_Deployment_nginx.yaml
|
||||
--- /tmp/noop/apps_v1beta2_Deployment_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||
+++ /tmp/transformed/apps_v1beta2_Deployment_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||
@@ -1,14 +1,27 @@
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
+ annotations:
|
||||
+ note: This is a test annotation
|
||||
labels:
|
||||
- app: nginx
|
||||
- name: nginx
|
||||
+ app: mynginx
|
||||
+ org: example.com
|
||||
+ team: foo
|
||||
+ name: team-foo-nginx
|
||||
spec:
|
||||
+ selector:
|
||||
+ matchLabels:
|
||||
+ app: mynginx
|
||||
+ org: example.com
|
||||
+ team: foo
|
||||
template:
|
||||
metadata:
|
||||
+ annotations:
|
||||
+ note: This is a test annotation
|
||||
labels:
|
||||
- app: nginx
|
||||
+ app: mynginx
|
||||
+ org: example.com
|
||||
+ team: foo
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
diff -u -N /tmp/noop/v1_Service_nginx.yaml /tmp/transformed/v1_Service_nginx.yaml
|
||||
--- /tmp/noop/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||
+++ /tmp/transformed/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||
@@ -1,11 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
+ annotations:
|
||||
+ note: This is a test annotation
|
||||
labels:
|
||||
- app: nginx
|
||||
- name: nginx
|
||||
+ app: mynginx
|
||||
+ org: example.com
|
||||
+ team: foo
|
||||
+ name: team-foo-nginx
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
- app: nginx
|
||||
+ app: mynginx
|
||||
+ org: example.com
|
||||
+ team: foo
|
||||
|
|
@ -2,3 +2,4 @@ description: base only
|
|||
args: []
|
||||
filename: testdata/testcase-base-only/in
|
||||
expectedStdout: testdata/testcase-base-only/expected.yaml
|
||||
expectedDiff: testdata/testcase-base-only/expected.diff
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
apiVersion: manifest.k8s.io/v1alpha1
|
||||
kind: Manifest
|
||||
metadata:
|
||||
name: mysql-wordpress
|
||||
description: wordpress app with mysql
|
||||
namePrefix: my-awesome-app-
|
||||
objectAnnotations:
|
||||
note: This is a test annotation
|
||||
packages:
|
||||
- mysql/
|
||||
- wordpress/
|
||||
patches:
|
||||
- patch.yaml
|
||||
configmaps:
|
||||
- name: app-env
|
||||
env: configmap/app.env
|
||||
- name: app-config
|
||||
files:
|
||||
- configmap/app-init.ini
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
FOO=bar
|
||||
BAR=baz
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
DB_USERNAME=admin
|
||||
DB_PASSWORD=somepw
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
note: This is a test annotation
|
||||
labels:
|
||||
app: mysql
|
||||
component: mysql
|
||||
name: mysql
|
||||
spec:
|
||||
ports:
|
||||
- port: 3306
|
||||
selector:
|
||||
app: mysql
|
||||
component: mysql
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
note: This is a test annotation
|
||||
labels:
|
||||
app: wordpress
|
||||
component: wordpress
|
||||
name: wordpress
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: wordpress
|
||||
component: wordpress
|
||||
---
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
note: This is a test annotation
|
||||
labels:
|
||||
app: mysql
|
||||
component: mysql
|
||||
name: mysql
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
component: mysql
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
note: This is a test annotation
|
||||
labels:
|
||||
app: mysql
|
||||
component: mysql
|
||||
spec:
|
||||
containers:
|
||||
- image: mysql
|
||||
name: mysql
|
||||
---
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
note: This is a test annotation
|
||||
labels:
|
||||
app: wordpress
|
||||
component: wordpress
|
||||
name: wordpress
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
component: wordpress
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
note: This is a test annotation
|
||||
labels:
|
||||
app: wordpress
|
||||
component: wordpress
|
||||
spec:
|
||||
containers:
|
||||
- image: wordpress
|
||||
name: wordpress
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
apiVersion: manifest.k8s.io/v1alpha1
|
||||
kind: Manifest
|
||||
metadata:
|
||||
name: mysql-app
|
||||
description: mysql app for team foo
|
||||
objectLabels:
|
||||
component: mysql
|
||||
objectAnnotations:
|
||||
note: This is a test annotation
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: mysql
|
||||
labels:
|
||||
app: mysql
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mysql
|
||||
spec:
|
||||
containers:
|
||||
- name: mysql
|
||||
image: mysql
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mysql
|
||||
labels:
|
||||
app: mysql
|
||||
spec:
|
||||
ports:
|
||||
- port: 3306
|
||||
selector:
|
||||
app: mysql
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
apiVersion: apps/v1beta2 # for versions before 1.9.0 use apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: wordpress
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: wordpress
|
||||
env:
|
||||
- name: WORDPRESS_DB_HOST
|
||||
value: mysql
|
||||
- name: WORDPRESS_DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mysql-pass
|
||||
key: password
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
description: noop
|
||||
args: []
|
||||
filename: testdata/testcase-noop/
|
||||
mode: noop_mode
|
||||
expectedStdout: testdata/testcase-noop/expected.yaml
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
apiVersion: manifest.k8s.io/v1alpha1
|
||||
kind: Manifest
|
||||
metadata:
|
||||
name: wordpress
|
||||
description: wordpress app
|
||||
objectLabels:
|
||||
component: wordpress
|
||||
objectAnnotations:
|
||||
note: This is a test annotation
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: wordpress
|
||||
labels:
|
||||
app: wordpress
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: wordpress
|
||||
spec:
|
||||
containers:
|
||||
- name: wordpress
|
||||
image: wordpress
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: wordpress
|
||||
labels:
|
||||
app: wordpress
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: wordpress
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
diff -u -N /tmp/noop/extensions_v1beta1_Deployment_mungebot.yaml /tmp/transformed/extensions_v1beta1_Deployment_mungebot.yaml
|
||||
--- /tmp/noop/extensions_v1beta1_Deployment_mungebot.yaml YYYY-MM-DD HH:MM:SS
|
||||
+++ /tmp/transformed/extensions_v1beta1_Deployment_mungebot.yaml YYYY-MM-DD HH:MM:SS
|
||||
@@ -3,28 +3,68 @@
|
||||
metadata:
|
||||
annotations:
|
||||
baseAnno: This is an base annotation
|
||||
+ note: This is a test annotation
|
||||
labels:
|
||||
app: mungebot
|
||||
foo: bar
|
||||
- name: baseprefix-mungebot
|
||||
+ org: kubernetes
|
||||
+ repo: test-infra
|
||||
+ name: test-infra-baseprefix-mungebot
|
||||
spec:
|
||||
- replicas: 1
|
||||
+ replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
+ app: mungebot
|
||||
foo: bar
|
||||
+ org: kubernetes
|
||||
+ repo: test-infra
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
baseAnno: This is an base annotation
|
||||
+ note: This is a test annotation
|
||||
labels:
|
||||
app: mungebot
|
||||
foo: bar
|
||||
+ org: kubernetes
|
||||
+ repo: test-infra
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
+ - name: FOO
|
||||
+ valueFrom:
|
||||
+ configMapKeyRef:
|
||||
+ key: somekey
|
||||
+ name: test-infra-app-env-hf26mf2f2f
|
||||
+ - name: BAR
|
||||
+ valueFrom:
|
||||
+ secretKeyRef:
|
||||
+ key: somekey
|
||||
+ name: test-infra-app-tls-4d47hbbh9m
|
||||
- name: foo
|
||||
value: bar
|
||||
- image: nginx
|
||||
+ image: nginx:1.7.9
|
||||
name: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
+ - envFrom:
|
||||
+ - configMapRef:
|
||||
+ name: someConfigMap
|
||||
+ - configMapRef:
|
||||
+ name: test-infra-app-env-hf26mf2f2f
|
||||
+ - secretRef:
|
||||
+ name: test-infra-app-tls-4d47hbbh9m
|
||||
+ image: busybox
|
||||
+ name: busybox
|
||||
+ volumeMounts:
|
||||
+ - mountPath: /tmp/env
|
||||
+ name: app-env
|
||||
+ - mountPath: /tmp/tls
|
||||
+ name: app-tls
|
||||
+ volumes:
|
||||
+ - configMap:
|
||||
+ name: test-infra-app-env-hf26mf2f2f
|
||||
+ name: app-env
|
||||
+ - name: app-tls
|
||||
+ secret:
|
||||
+ secretName: test-infra-app-tls-4d47hbbh9m
|
||||
diff -u -N /tmp/noop/v1_ConfigMap_app-config.yaml /tmp/transformed/v1_ConfigMap_app-config.yaml
|
||||
--- /tmp/noop/v1_ConfigMap_app-config.yaml YYYY-MM-DD HH:MM:SS
|
||||
+++ /tmp/transformed/v1_ConfigMap_app-config.yaml YYYY-MM-DD HH:MM:SS
|
||||
@@ -0,0 +1,15 @@
|
||||
+apiVersion: v1
|
||||
+data:
|
||||
+ app-init.ini: |
|
||||
+ FOO=bar
|
||||
+ BAR=baz
|
||||
+kind: ConfigMap
|
||||
+metadata:
|
||||
+ annotations:
|
||||
+ note: This is a test annotation
|
||||
+ creationTimestamp: null
|
||||
+ labels:
|
||||
+ app: mungebot
|
||||
+ org: kubernetes
|
||||
+ repo: test-infra
|
||||
+ name: test-infra-app-config-ht8ck65bcg
|
||||
diff -u -N /tmp/noop/v1_ConfigMap_app-env.yaml /tmp/transformed/v1_ConfigMap_app-env.yaml
|
||||
--- /tmp/noop/v1_ConfigMap_app-env.yaml YYYY-MM-DD HH:MM:SS
|
||||
+++ /tmp/transformed/v1_ConfigMap_app-env.yaml YYYY-MM-DD HH:MM:SS
|
||||
@@ -0,0 +1,14 @@
|
||||
+apiVersion: v1
|
||||
+data:
|
||||
+ DB_PASSWORD: somepw
|
||||
+ DB_USERNAME: admin
|
||||
+kind: ConfigMap
|
||||
+metadata:
|
||||
+ annotations:
|
||||
+ note: This is a test annotation
|
||||
+ creationTimestamp: null
|
||||
+ labels:
|
||||
+ app: mungebot
|
||||
+ org: kubernetes
|
||||
+ repo: test-infra
|
||||
+ name: test-infra-app-env-hf26mf2f2f
|
||||
diff -u -N /tmp/noop/v1_Secret_app-tls.yaml /tmp/transformed/v1_Secret_app-tls.yaml
|
||||
--- /tmp/noop/v1_Secret_app-tls.yaml YYYY-MM-DD HH:MM:SS
|
||||
+++ /tmp/transformed/v1_Secret_app-tls.yaml YYYY-MM-DD HH:MM:SS
|
||||
@@ -0,0 +1,15 @@
|
||||
+apiVersion: v1
|
||||
+data:
|
||||
+ tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUIwekNDQVgyZ0F3SUJBZ0lKQUkvTTdCWWp3Qit1TUEwR0NTcUdTSWIzRFFFQkJRVUFNRVV4Q3pBSkJnTlYKQkFZVEFrRlZNUk13RVFZRFZRUUlEQXBUYjIxbExWTjBZWFJsTVNFd0h3WURWUVFLREJoSmJuUmxjbTVsZENCWAphV1JuYVhSeklGQjBlU0JNZEdRd0hoY05NVEl3T1RFeU1qRTFNakF5V2hjTk1UVXdPVEV5TWpFMU1qQXlXakJGCk1Rc3dDUVlEVlFRR0V3SkJWVEVUTUJFR0ExVUVDQXdLVTI5dFpTMVRkR0YwWlRFaE1COEdBMVVFQ2d3WVNXNTAKWlhKdVpYUWdWMmxrWjJsMGN5QlFkSGtnVEhSa01Gd3dEUVlKS29aSWh2Y05BUUVCQlFBRFN3QXdTQUpCQU5MSgpoUEhoSVRxUWJQa2xHM2liQ1Z4d0dNUmZwL3Y0WHFoZmRRSGRjVmZIYXA2TlE1V29rLzR4SUErdWkzNS9NbU5hCnJ0TnVDK0JkWjF0TXVWQ1BGWmNDQXdFQUFhTlFNRTR3SFFZRFZSME9CQllFRkp2S3M4UmZKYVhUSDA4VytTR3YKelF5S24wSDhNQjhHQTFVZEl3UVlNQmFBRkp2S3M4UmZKYVhUSDA4VytTR3Z6UXlLbjBIOE1Bd0dBMVVkRXdRRgpNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUZCUUFEUVFCSmxmZkpIeWJqREd4Uk1xYVJtRGhYMCs2djAyVFVLWnNXCnI1UXVWYnBRaEg2dSswVWdjVzBqcDlRd3B4b1BUTFRXR1hFV0JCQnVyeEZ3aUNCaGtRK1YKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
|
||||
+ tls.key: LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlCT3dJQkFBSkJBTkxKaFBIaElUcVFiUGtsRzNpYkNWeHdHTVJmcC92NFhxaGZkUUhkY1ZmSGFwNk5RNVdvCmsvNHhJQSt1aTM1L01tTmFydE51QytCZFoxdE11VkNQRlpjQ0F3RUFBUUpBRUoyTit6c1IwWG44L1E2dHdhNEcKNk9CMU0xV08rayt6dG5YLzFTdk5lV3U4RDZHSW10dXBMVFlnalpjSHVmeWtqMDlqaUhtakh4OHU4WlpCL28xTgpNUUloQVBXK2V5Wm83YXkzbE16MVYwMVdWak5LSzlRU24xTUpsYjA2aC9MdVl2OUZBaUVBMjVXUGVkS2dWeUNXClNtVXdiUHc4Zm5UY3BxRFdFM3lUTzN2S2NlYnFNU3NDSUJGM1VtVnVlOFlVM2p5YkMzTnh1WHEzd05tMzRSOFQKeFZMSHdEWGgvNk5KQWlFQWwyb0hHR0x6NjRCdUFmaktycXd6N3FNWXI5SENMSWUvWXNvV3Evb2x6U2NDSVFEaQpEMmxXdXNvZTIvbkVxZkRWVldHV2x5Sjd5T21xYVZtL2lOVU45QjJOMmc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
|
||||
+kind: Secret
|
||||
+metadata:
|
||||
+ annotations:
|
||||
+ note: This is a test annotation
|
||||
+ creationTimestamp: null
|
||||
+ labels:
|
||||
+ app: mungebot
|
||||
+ org: kubernetes
|
||||
+ repo: test-infra
|
||||
+ name: test-infra-app-tls-4d47hbbh9m
|
||||
+type: kubernetes.io/tls
|
||||
diff -u -N /tmp/noop/v1_Service_mungebot-service.yaml /tmp/transformed/v1_Service_mungebot-service.yaml
|
||||
--- /tmp/noop/v1_Service_mungebot-service.yaml YYYY-MM-DD HH:MM:SS
|
||||
+++ /tmp/transformed/v1_Service_mungebot-service.yaml YYYY-MM-DD HH:MM:SS
|
||||
@@ -3,13 +3,18 @@
|
||||
metadata:
|
||||
annotations:
|
||||
baseAnno: This is an base annotation
|
||||
+ note: This is a test annotation
|
||||
labels:
|
||||
app: mungebot
|
||||
foo: bar
|
||||
- name: baseprefix-mungebot-service
|
||||
+ org: kubernetes
|
||||
+ repo: test-infra
|
||||
+ name: test-infra-baseprefix-mungebot-service
|
||||
spec:
|
||||
ports:
|
||||
- port: 7002
|
||||
selector:
|
||||
app: mungebot
|
||||
foo: bar
|
||||
+ org: kubernetes
|
||||
+ repo: test-infra
|
||||
|
|
@ -2,3 +2,4 @@ description: simple
|
|||
args: []
|
||||
filename: ../examples/simple/instances/exampleinstance/
|
||||
expectedStdout: testdata/testcase-simple/expected.yaml
|
||||
expectedDiff: testdata/testcase-simple/expected.diff
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
diff -u -N /tmp/noop/apps_v1beta2_Deployment_nginx.yaml /tmp/transformed/apps_v1beta2_Deployment_nginx.yaml
|
||||
--- /tmp/noop/apps_v1beta2_Deployment_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||
+++ /tmp/transformed/apps_v1beta2_Deployment_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||
@@ -5,13 +5,15 @@
|
||||
note: This is a test annotation
|
||||
labels:
|
||||
app: mynginx
|
||||
+ env: staging
|
||||
org: example.com
|
||||
team: foo
|
||||
- name: team-foo-nginx
|
||||
+ name: staging-team-foo-nginx
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mynginx
|
||||
+ env: staging
|
||||
org: example.com
|
||||
team: foo
|
||||
template:
|
||||
@@ -20,6 +22,7 @@
|
||||
note: This is a test annotation
|
||||
labels:
|
||||
app: mynginx
|
||||
+ env: staging
|
||||
org: example.com
|
||||
team: foo
|
||||
spec:
|
||||
@@ -30,5 +33,6 @@
|
||||
- mountPath: /tmp/ps
|
||||
name: nginx-persistent-storage
|
||||
volumes:
|
||||
- - emptyDir: {}
|
||||
+ - gcePersistentDisk:
|
||||
+ pdName: nginx-persistent-storage
|
||||
name: nginx-persistent-storage
|
||||
diff -u -N /tmp/noop/v1_Service_nginx.yaml /tmp/transformed/v1_Service_nginx.yaml
|
||||
--- /tmp/noop/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||
+++ /tmp/transformed/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||
@@ -5,13 +5,15 @@
|
||||
note: This is a test annotation
|
||||
labels:
|
||||
app: mynginx
|
||||
+ env: staging
|
||||
org: example.com
|
||||
team: foo
|
||||
- name: team-foo-nginx
|
||||
+ name: staging-team-foo-nginx
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: mynginx
|
||||
+ env: staging
|
||||
org: example.com
|
||||
team: foo
|
||||
|
|
@ -2,3 +2,4 @@ description: single overlay
|
|||
args: []
|
||||
filename: testdata/testcase-single-overlay/in/overlay/
|
||||
expectedStdout: testdata/testcase-single-overlay/expected.yaml
|
||||
expectedDiff: testdata/testcase-single-overlay/expected.diff
|
||||
|
|
|
|||
Loading…
Reference in New Issue