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

Scope to fallback allowed namespaces by default #1026

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion pkg/kapp/cmd/app/resource_types_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ func (s *ResourceTypesFlags) Set(cmd *cobra.Command) {
false, "Allow to ignore failing APIServices")

cmd.Flags().BoolVar(&s.ScopeToFallbackAllowedNamespaces, "dangerous-scope-to-fallback-allowed-namespaces",
false, "Scope resource searching to fallback allowed namespaces")
true, "Scope resource searching to fallback allowed namespaces")

cmd.Flags().MarkDeprecated("dangerous-scope-to-fallback-allowed-namespaces", "The default and recommended behavior is to use this fallback mechanism now")
}

func (s *ResourceTypesFlags) FailingAPIServicePolicy() *FailingAPIServicesPolicy {
Expand Down
28 changes: 20 additions & 8 deletions test/e2e/fallback_allowed_ns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ data:
NewPresentClusterResource("configmap", "cm-3", testNamespace, kubectl)
})

logger.Section("inspect app without scope-to-fallback-allowed-namespaces", func() {
logger.Section("inspect app with scope-to-fallback-allowed-namespaces false", func() {
const appLabelKey string = "kapp.k14s.io/app"
NewClusterResource(t, "ns", testNamespace2, "", kubectl)
NewClusterResource(t, "cm", "cm-4", testNamespace2, kubectl)
Expand All @@ -242,7 +242,7 @@ data:
patch := fmt.Sprintf(`[{ "op": "add", "path": "/metadata/labels", "value": {%s: "%s"}}]`, appLabelKey, appLabel)
PatchClusterResource("cm", "cm-4", testNamespace2, patch, kubectl)

out := kapp.Run([]string{"inspect", "-a", appName, "--json"})
out := kapp.Run([]string{"inspect", "-a", appName, "--json", "--dangerous-scope-to-fallback-allowed-namespaces=false"})

// Should get the newly added configmap
expectedResources := []map[string]string{{
Expand Down Expand Up @@ -279,13 +279,13 @@ data:
"reconcile_state": "ok",
}}

resp := uitest.JSONUIFromBytes(t, []byte(out))
resp := uitest.JSONUIFromBytes(t, []byte(removeCobraFlagDeprecationWarning(out, "dangerous-scope-to-fallback-allowed-namespaces")))

require.Equalf(t, expectedResources, replaceAge((resp.Tables[0].Rows)), "Expected resources to match")
})

logger.Section("inspect app with scope-to-fallback-allowed-namespaces", func() {
out := kapp.Run([]string{"inspect", "-a", appName, "--json", "--dangerous-scope-to-fallback-allowed-namespaces"})
logger.Section("inspect app without scope-to-fallback-allowed-namespaces", func() {
out := kapp.Run([]string{"inspect", "-a", appName, "--json"})

// Shouldn't get the newly added configmap
expectedResources := []map[string]string{{
Expand Down Expand Up @@ -319,8 +319,8 @@ data:
require.Equalf(t, expectedResources, replaceAge((resp.Tables[0].Rows)), "Expected resources to match")
})

logger.Section("delete one configmap and deploy again with scope-to-fallback-allowed-namespaces", func() {
kapp.RunWithOpts([]string{"deploy", "-a", appName, "-f", "-", "--dangerous-scope-to-fallback-allowed-namespaces"},
logger.Section("delete one configmap and deploy again without", func() {
kapp.RunWithOpts([]string{"deploy", "-a", appName, "-f", "-"},
RunOpts{StdinReader: strings.NewReader(yaml2)})

NewPresentClusterResource("configmap", "cm-1", env.Namespace, kubectl)
Expand All @@ -329,7 +329,7 @@ data:
})

logger.Section("delete app", func() {
kapp.Run([]string{"delete", "-a", appName, "--dangerous-scope-to-fallback-allowed-namespaces"})
kapp.Run([]string{"delete", "-a", appName})

NewMissingClusterResource(t, "configmap", "cm-1", env.Namespace, kubectl)
NewMissingClusterResource(t, "configmap", "cm-2", testNamespace, kubectl)
Expand All @@ -356,3 +356,15 @@ func ScopedContext(t *testing.T, kubectl Kubectl, _, contextName, userName strin
kubectl.Run([]string{"config", "delete-user", userName})
}
}

func removeCobraFlagDeprecationWarning(output, flag string) string {
newOut := ""
lines := strings.Split(output, "\n")
for _, line := range lines {
if strings.Contains(line, fmt.Sprintf("Flag --%s has been deprecated", flag)) {
continue
}
newOut += line + "\n"
}
return newOut
}
201 changes: 0 additions & 201 deletions vendor/github.com/openshift/crd-schema-checker/LICENSE

This file was deleted.

Loading