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

feat: always store namespace in func.yaml and warn if current ns & func.yaml ns is different #1118

Merged
merged 8 commits into from
Jul 20, 2022

Conversation

gauron99
Copy link
Contributor

@gauron99 gauron99 commented Jul 15, 2022

Changes

changes to func deploy

  • store namespace to func.yaml on first deployment (from current namespace)
  • if namespace is not specified via CLI and is different from func.yaml print warning explaining this
    (ex: func.yaml->namespace = default && oc->namespace = myns -> print warning where func is deployed)
  • if namespace is specified via CLI, assume user knows what hes doing, do nothing

update

  • add fake KUBECONFIG to all the tests in deploy_test.go
  • replace context.TODO with context.Background in deploy_test.go
  • print warning to stderr

Fixes #1084

@knative-prow knative-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 15, 2022
@matejvasek
Copy link
Contributor

@gauron99 the unitests are failing

@matejvasek
Copy link
Contributor

you need to add
defer WithEnvVar(t, "KUBECONFIG", fmt.Sprintf("%s/testdata/kubeconfig_deploy_namespace", cwd()))()
into Test_runDeploy.

@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #1118 (20ec1f8) into main (b1fd9f7) will increase coverage by 0.03%.
The diff coverage is 62.50%.

@@            Coverage Diff             @@
##             main    #1118      +/-   ##
==========================================
+ Coverage   45.89%   45.92%   +0.03%     
==========================================
  Files          65       65              
  Lines        8701     8717      +16     
==========================================
+ Hits         3993     4003      +10     
- Misses       4321     4325       +4     
- Partials      387      389       +2     
Impacted Files Coverage Δ
cmd/deploy.go 59.26% <62.50%> (+0.13%) ⬆️

cmd/deploy.go Outdated Show resolved Hide resolved
cmd/deploy_test.go Outdated Show resolved Hide resolved
}))

// set namespace argument if given & reset after
cmd.SetArgs([]string{}) // Do not use test command args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we cannot use command args?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When i used cmd.SetArgs i got an error Got error 'unknown flag: --namespace' as it is a global flag, using viper worked to fix it

Copy link
Contributor

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

/hold for others

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 20, 2022
@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 20, 2022
@knative-prow
Copy link

knative-prow bot commented Jul 20, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99, zroubalik

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 20, 2022
@lance
Copy link
Member

lance commented Jul 20, 2022

/lgtm
/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 20, 2022
@knative-prow knative-prow bot merged commit 8cb7080 into knative:main Jul 20, 2022
@lance lance added this to the 0.26.0 Release milestone Jul 28, 2022
@gauron99 gauron99 deleted the 1084-nsfixed branch August 3, 2023 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A Function's namespace should always be stored in func.yaml
4 participants