diff --git a/cmd/deploy.go b/cmd/deploy.go index 13c2728aa9..3d9ef6d401 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -235,7 +235,7 @@ func runDeploy(cmd *cobra.Command, newClient ClientFactory) (err error) { } // If using Openshift registry AND redeploying Function, update image registry - if f.Namespace != f.Deploy.Namespace && f.Deploy.Namespace != "" { + if f.Namespace != "" && f.Namespace != f.Deploy.Namespace && f.Deploy.Namespace != "" { // when running openshift, namespace is tied to registry, override on --namespace change // The most default part of registry (in buildConfig) checks 'k8s.IsOpenShift()' and if true, // sets default registry by current namespace diff --git a/pkg/functions/client.go b/pkg/functions/client.go index 8fce6fbb00..9c210544ba 100644 --- a/pkg/functions/client.go +++ b/pkg/functions/client.go @@ -757,10 +757,10 @@ func (c *Client) Deploy(ctx context.Context, f Function, opts ...DeployOption) ( // If Redeployment to NEW namespace was successful -- undeploy dangling Function in old namespace. // On forced namespace change (using --namespace flag) - if f.Namespace != f.Deploy.Namespace && f.Deploy.Namespace != "" { + if f.Namespace != "" && f.Namespace != f.Deploy.Namespace && f.Deploy.Namespace != "" { // TODO: when new prompt is implemented, add here a "are you sure?" check possibly if c.verbose { - fmt.Fprintf(os.Stderr, "Info: Deleting old func in '%s' because the namespace has changed\n", f.Deploy.Namespace) + fmt.Fprintf(os.Stderr, "Info: Deleting old func in '%s' because the namespace has changed to '%s'\n", f.Deploy.Namespace, f.Namespace) } // c.Remove removes a Function in f.Deploy.Namespace which removes the OLD Function diff --git a/pkg/functions/client_int_test.go b/pkg/functions/client_int_test.go index 244f4f6ab6..4ce5c2a4fa 100644 --- a/pkg/functions/client_int_test.go +++ b/pkg/functions/client_int_test.go @@ -202,7 +202,7 @@ func TestDeployWithTriggers(t *testing.T) { func TestUpdateWithAnnotationsAndLabels(t *testing.T) { functionName := "updateannlab" defer Within(t, "testdata/example.com/"+functionName)() - verbose := true + verbose := false servingClient, err := knative.NewServingClient(DefaultNamespace) @@ -215,10 +215,6 @@ func TestUpdateWithAnnotationsAndLabels(t *testing.T) { } defer del(t, client, functionName) - if f, err = client.Deploy(context.Background(), f); err != nil { - t.Fatal(err) - } - // Updated function with a new set of annotations and labels // deploy and check that deployed kcsv contains correct annotations and labels