Skip to content

Commit

Permalink
remove patches and imageTags from kustomization.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Liujingfang1 committed Jan 25, 2019
1 parent 028724d commit c461f1f
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 344 deletions.
23 changes: 1 addition & 22 deletions docs/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bases:
# a memory request/limit, change an env var in a
# ConfigMap, etc. Small patches are easy to review and
# easy to mix together in overlays.
patches:
patchesStrategicMerge:
- service_port_8888.yaml
- deployment_increase_replicas.yaml
- deployment_increase_memory.yaml
Expand Down Expand Up @@ -311,24 +311,3 @@ images:
newName: my-app
- name: alpine
digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3

# ImageTags is deprecated, instead use Image.
# ImageTags modify the tags for images without creating patches.
# E.g. Given this fragment of a Deployment:
# ```
# containers:
# - name: myapp
# image: mycontainerregistry/myimage:v0
# - name: nginxapp
# image: nginx:1.7.9
#```
# one can change the tag of myimage to v1 and the tag of nginx to 1.8.0 with the following:
#
# It also supports digests. If digest is present newTag is ignored.
imageTags:
- name: mycontainerregistry/myimage
newTag: v1
- name: nginx
newTag: 1.8.0
- name: alpine
digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
1 change: 0 additions & 1 deletion pkg/commands/edit/set/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func NewCmdSet(fsys fs.FileSystem, v ifc.Validator) *cobra.Command {
newCmdSetNamePrefix(fsys),
newCmdSetNameSuffix(fsys),
newCmdSetNamespace(fsys, v),
newCmdSetImageTag(fsys),
newCmdSetImage(fsys),
)
return c
Expand Down
3 changes: 3 additions & 0 deletions pkg/commands/edit/set/setimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package set

import (
"errors"
"regexp"
"sort"
"strings"

Expand All @@ -31,6 +32,8 @@ type setImageOptions struct {
imageMap map[string]image.Image
}

var pattern = regexp.MustCompile("^(.*):([a-zA-Z0-9._-]*)$")

// errors

var (
Expand Down
132 changes: 0 additions & 132 deletions pkg/commands/edit/set/setimagetag.go

This file was deleted.

101 changes: 0 additions & 101 deletions pkg/commands/edit/set/setimagetag_test.go

This file was deleted.

4 changes: 1 addition & 3 deletions pkg/commands/kustfile/kustomizationfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ func determineFieldOrder() []string {
"Crds",
"CommonLabels",
"CommonAnnotations",
"Patches",
"PatchesStrategicMerge",
"PatchesJson6902",
"ConfigMapGenerator",
"SecretGenerator",
"GeneratorOptions",
"Vars",
"Images",
"ImageTags",
"Configurations",
}

Expand Down Expand Up @@ -148,12 +146,12 @@ func (mf *kustomizationFile) Read() (*types.Kustomization, error) {
if err != nil {
return nil, err
}
data = types.DealWithDeprecatedFields(data)
var k types.Kustomization
err = yaml.Unmarshal(data, &k)
if err != nil {
return nil, err
}
k.DealWithDeprecatedFields()
msgs := k.DealWithMissingFields()
if len(msgs) > 0 {
log.Printf(strings.Join(msgs, "\n"))
Expand Down
47 changes: 0 additions & 47 deletions pkg/commands/kustfile/kustomizationfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestFieldOrder(t *testing.T) {
"GeneratorOptions",
"Vars",
"Images",
"ImageTags",
"Configurations",
}
actual := determineFieldOrder()
Expand Down Expand Up @@ -85,52 +84,6 @@ func TestWriteAndRead(t *testing.T) {
}
}

// Deprecated fields should not survive being read.
func TestDeprecationOfPatches(t *testing.T) {
hasDeprecatedFields := []byte(`
namePrefix: acme
nameSuffix: emca
patches:
- alice
patchesStrategicMerge:
- bob
`)
fSys := fs.MakeFakeFS()
fSys.WriteTestKustomizationWith(hasDeprecatedFields)
mf, err := NewKustomizationFile(fSys)
if err != nil {
t.Fatalf("Unexpected Error: %v", err)
}
k, err := mf.Read()
if err != nil {
t.Fatalf("Couldn't read kustomization file: %v\n", err)
}
if k.NamePrefix != "acme" {
t.Fatalf("Unexpected name prefix")
}
if k.NameSuffix != "emca" {
t.Fatalf("Unexpected name suffix")
}
if len(k.Patches) > 0 {
t.Fatalf("Expected nothing in Patches.")
}
if len(k.PatchesStrategicMerge) != 2 {
t.Fatalf(
"Expected len(k.PatchesStrategicMerge) == 2, got %d",
len(k.PatchesStrategicMerge))
}
m := make(map[string]bool)
for _, v := range k.PatchesStrategicMerge {
m[string(v)] = true
}
if _, f := m["alice"]; !f {
t.Fatalf("Expected alice in PatchesStrategicMerge")
}
if _, f := m["bob"]; !f {
t.Fatalf("Expected bob in PatchesStrategicMerge")
}
}

func TestNewNotExist(t *testing.T) {
fakeFS := fs.MakeFakeFS()
_, err := NewKustomizationFile(fakeFS)
Expand Down
2 changes: 1 addition & 1 deletion pkg/target/baseandoverlaymedium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ configMapGenerator:
- name: app-config
files:
- configmap/app-init.ini
imageTags:
images:
- name: nginx
newTag: 1.8.0`)

Expand Down
Loading

0 comments on commit c461f1f

Please sign in to comment.