Skip to content

Commit

Permalink
Scope to fallback allowed namespacs by default
Browse files Browse the repository at this point in the history
Signed-off-by: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com>
  • Loading branch information
praveenrewar committed Oct 9, 2024
1 parent ca6887d commit 82add65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 209 deletions.
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 behaviour is to use this fallback mechanism now")
}

func (s *ResourceTypesFlags) FailingAPIServicePolicy() *FailingAPIServicesPolicy {
Expand Down
14 changes: 7 additions & 7 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 @@ -284,8 +284,8 @@ data:
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 Down
201 changes: 0 additions & 201 deletions vendor/github.com/openshift/crd-schema-checker/LICENSE

This file was deleted.

0 comments on commit 82add65

Please sign in to comment.