Skip to content

Commit

Permalink
fix deploy bug, remove verbose for better logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gauron99 committed Feb 1, 2024
1 parent 5ddc3d8 commit 3a49307
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/functions/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions pkg/functions/client_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down

0 comments on commit 3a49307

Please sign in to comment.