Skip to content

Commit 950c353

Browse files
committed
Delete diff command and code it uses.
1 parent aff09b1 commit 950c353

File tree

8 files changed

+1
-564
lines changed

8 files changed

+1
-564
lines changed

pkg/app/application.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,6 @@ func (a *Application) MakeCustomizedResMap() (resmap.ResMap, error) {
8686
return a.resolveRefsToGeneratedResources(m)
8787
}
8888

89-
// MakeUncustomizedResMap purports to create a ResMap without customization.
90-
// The Resources in the returned ResMap include all resources mentioned
91-
// in the kustomization file and transitively reachable via its Bases,
92-
// and all generated secrets and configMaps.
93-
// Meant for use in generating a diff against customized resources.
94-
// TODO: See https://github.com/kubernetes-sigs/kustomize/issues/85
95-
func (a *Application) MakeUncustomizedResMap() (resmap.ResMap, error) {
96-
m, err := a.loadResMapFromBasesAndResources()
97-
if err != nil {
98-
return nil, err
99-
}
100-
return a.resolveRefsToGeneratedResources(m)
101-
}
102-
10389
// resolveRefsToGeneratedResources fixes all name references.
10490
func (a *Application) resolveRefsToGeneratedResources(m resmap.ResMap) (resmap.ResMap, error) {
10591
err := transformers.NewNameHashTransformer().Transform(m)

pkg/app/application_test.go

Lines changed: 0 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ var deploy = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deploy
9696
var cmap = schema.GroupVersionKind{Version: "v1", Kind: "ConfigMap"}
9797
var secret = schema.GroupVersionKind{Version: "v1", Kind: "Secret"}
9898
var ns = schema.GroupVersionKind{Version: "v1", Kind: "Namespace"}
99-
var svc = schema.GroupVersionKind{Version: "v1", Kind: "Service"}
10099

101100
func TestResources1(t *testing.T) {
102101
expected := resmap.ResMap{
@@ -227,153 +226,6 @@ func TestResourceNotFound(t *testing.T) {
227226
}
228227
}
229228

230-
func TestRawResources1(t *testing.T) {
231-
expected := resmap.ResMap{
232-
resource.NewResId(deploy, "dply1"): resource.NewResourceFromMap(
233-
map[string]interface{}{
234-
"apiVersion": "apps/v1",
235-
"kind": "Deployment",
236-
"metadata": map[string]interface{}{
237-
"name": "dply1",
238-
},
239-
}),
240-
resource.NewResId(ns, "ns1"): resource.NewResourceFromMap(
241-
map[string]interface{}{
242-
"apiVersion": "v1",
243-
"kind": "Namespace",
244-
"metadata": map[string]interface{}{
245-
"name": "ns1",
246-
},
247-
}),
248-
}
249-
l := makeLoader1(t)
250-
app, err := NewApplication(l, fs.MakeFakeFS())
251-
if err != nil {
252-
t.Fatalf("Unexpected construction error %v", err)
253-
}
254-
actual, err := app.MakeUncustomizedResMap()
255-
if err != nil {
256-
t.Fatalf("Unexpected RawResources error %v", err)
257-
}
258-
259-
if err := expected.ErrorIfNotEqual(actual); err != nil {
260-
t.Fatalf("unexpected inequality: %v", err)
261-
}
262-
}
263-
264-
const (
265-
kustomizationContentBase = `
266-
namePrefix: foo-
267-
commonLabels:
268-
app: banana
269-
resources:
270-
- deployment.yaml
271-
`
272-
kustomizationContentOverlay = `
273-
commonLabels:
274-
env: staging
275-
resources:
276-
- service.yaml
277-
bases:
278-
- base
279-
`
280-
serviceContent = `apiVersion: v1
281-
kind: Service
282-
metadata:
283-
name: svc
284-
spec:
285-
type: LoadBalancer
286-
`
287-
)
288-
289-
func makeLoader2(t *testing.T) loader.Loader {
290-
ldr := loadertest.NewFakeLoader("/testpath")
291-
err := ldr.AddFile("/testpath/"+constants.KustomizationFileName, []byte(kustomizationContentOverlay))
292-
if err != nil {
293-
t.Fatal(err)
294-
}
295-
err = ldr.AddFile("/testpath/service.yaml", []byte(serviceContent))
296-
if err != nil {
297-
t.Fatalf("Failed to setup fake ldr.")
298-
}
299-
err = ldr.AddDirectory("/testpath/base")
300-
if err != nil {
301-
t.Fatalf("Failed to setup fake ldr.")
302-
}
303-
err = ldr.AddFile("/testpath/base/"+constants.KustomizationFileName, []byte(kustomizationContentBase))
304-
if err != nil {
305-
t.Fatalf("Failed to setup fake ldr.")
306-
}
307-
err = ldr.AddFile("/testpath/base/deployment.yaml", []byte(deploymentContent))
308-
if err != nil {
309-
t.Fatalf("Failed to setup fake ldr.")
310-
}
311-
return ldr
312-
}
313-
314-
// TODO: This test covers incorrect behavior; it should not pass.
315-
// It asks for raw resources. The Service resource is returned in raw form,
316-
// but the resources in the base are modified to have the banana label,
317-
// the 'foo' name prefix, etc. This method exists only to support the
318-
// diff command comparing customized to non-customized resources;
319-
// perhaps it's not worth supporting the command.
320-
func TestRawResources2(t *testing.T) {
321-
expected := resmap.ResMap{
322-
resource.NewResIdWithPrefix(deploy, "dply1", "foo-"): resource.NewResourceFromMap(
323-
map[string]interface{}{
324-
"apiVersion": "apps/v1",
325-
"kind": "Deployment",
326-
"metadata": map[string]interface{}{
327-
"name": "foo-dply1",
328-
"labels": map[string]interface{}{
329-
"app": "banana",
330-
},
331-
},
332-
"spec": map[string]interface{}{
333-
"selector": map[string]interface{}{
334-
"matchLabels": map[string]interface{}{
335-
"app": "banana",
336-
},
337-
},
338-
"template": map[string]interface{}{
339-
"metadata": map[string]interface{}{
340-
"labels": map[string]interface{}{
341-
"app": "banana",
342-
},
343-
},
344-
},
345-
},
346-
}),
347-
resource.NewResId(svc, "svc"): resource.NewResourceFromMap(
348-
map[string]interface{}{
349-
"apiVersion": "v1",
350-
"kind": "Service",
351-
"metadata": map[string]interface{}{
352-
"name": "svc",
353-
},
354-
"spec": map[string]interface{}{
355-
"type": "LoadBalancer",
356-
},
357-
}),
358-
}
359-
l := makeLoader2(t)
360-
app, err := NewApplication(l, fs.MakeFakeFS())
361-
if err != nil {
362-
t.Fatalf("Unexpected construction error %v", err)
363-
}
364-
actual, err := app.MakeUncustomizedResMap()
365-
if err != nil {
366-
t.Fatalf("Unexpected RawResources error %v", err)
367-
}
368-
369-
if err := expected.ErrorIfNotEqual(actual); err != nil {
370-
t.Fatalf("unexpected inequality: %v", err)
371-
}
372-
if !loadertest.CleanupCalled {
373-
t.Fatalf("Cleanup should be called")
374-
}
375-
}
376-
377229
func TestSecretTimeout(t *testing.T) {
378230
l := loadertest.NewFakeLoader("/testpath")
379231
err := l.AddFile("/testpath/"+constants.KustomizationFileName, []byte(kustomizationContent2))

pkg/commands/commands.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
// NewDefaultCommand returns the default (aka root) command for kustomize command.
2929
func NewDefaultCommand() *cobra.Command {
3030
fsys := fs.MakeRealFS()
31-
stdOut, stdErr := os.Stdout, os.Stderr
31+
stdOut := os.Stdout
3232

3333
c := &cobra.Command{
3434
Use: "kustomize",
@@ -43,7 +43,6 @@ See https://github.com/kubernetes-sigs/kustomize
4343
c.AddCommand(
4444
// TODO: Make consistent API for newCmd* functions.
4545
newCmdBuild(stdOut, fsys),
46-
newCmdDiff(stdOut, stdErr, fsys),
4746
newCmdEdit(fsys),
4847
newCmdVersion(stdOut),
4948
)

pkg/commands/diff.go

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)