Modify tkn version to accept namespace as ldflag and flag #1092
Conversation
|
The following is the coverage report on the affected files.
|
|
The following is the coverage report on the affected files.
|
|
|
|
/test pull-tekton-cli-integration-tests |
| @@ -23,6 +23,9 @@ import ( | |||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | |||
| ) | |||
|
|
|||
| // NOTE: use go build -ldflags "-X github.com/tektoncd/cli/pkg/version.defaultNamespace=tekton-pipelines" | |||
| var defaultNamespace = "tekton-pipelines" | |||
piyush-garg
Jul 31, 2020
Contributor
Is not better to put defaultNamespace value in flag itself
Is not better to put defaultNamespace value in flag itself
vdemeester
Jul 31, 2020
Member
@piyush-garg wdym ? we need to have that variable "defined" so that we can overwrite it with the ldflags. Being here seems to make more sense to me than in the cmd part (with the flags).
@piyush-garg wdym ? we need to have that variable "defined" so that we can overwrite it with the ldflags. Being here seems to make more sense to me than in the cmd part (with the flags).
|
Not sure if that was discussed but can't we have a list of most common namespaces in defaultNamespaces := []string{
"tekton-pipeline",
"openshift-pipeline",
"otherinthefutureofpopularnamespacefortekton",
}so an upstream tkn binary can work on openshift-pipelines by default (and vice versa) ? we try the list in order to find the version in there? |
Hi @chmouel I don't remember exactly like we discussed to keep list of namespace but we can do that instead of one namespace
But i am not sure if we have someother namespace used by anyother vendor. So shall i go ahead with those 2 namespace right now ? |
| ifneq ($(SKIPLDFLAG),) | ||
| FLAGS := $(VERSIONLDFLAG) $(SKIPLDFLAG) | ||
| FLAGS := $(VERSIONLDFLAG) $(SKIPLDFLAG)$(NAMESPACEFLAG) |
piyush-garg
Aug 3, 2020
Contributor
I think we need an if case for this also, there may be scenarios of only namespace flag provided
I think we need an if case for this also, there may be scenarios of only namespace flag provided
savitaashture
Aug 4, 2020
Author
Contributor
| clientVersion = devVersion | ||
| // flag to skip check flag in version cmd | ||
| skipCheckFlag = "false" | ||
| namespace string |
piyush-garg
Aug 3, 2020
Contributor
@vdemeester I mean we can put the default value here, and this can be overridden with LDFLAG and also namespace flag in cmd. And we can further use this in all functions. This way we can remove the defaultNamespace flag from pkg cc @savitaashture
@vdemeester I mean we can put the default value here, and this can be overridden with LDFLAG and also namespace flag in cmd. And we can further use this in all functions. This way we can remove the defaultNamespace flag from pkg cc @savitaashture
piyush-garg
Aug 3, 2020
Contributor
This can be single source for namespace then rather than two different for cmd and LDFLAG
This can be single source for namespace then rather than two different for cmd and LDFLAG
savitaashture
Aug 4, 2020
•
Author
Contributor
@piyush-garg updated code to have same var for both cmd and LDFLAG but not for default because now default is an []string{} and as per my understanding LDFLAG doesn't take the [] .
@piyush-garg updated code to have same var for both cmd and LDFLAG but not for default because now default is an []string{} and as per my understanding LDFLAG doesn't take the [] .
Nit: AFAIR, namespaces are
|
|
@savitaashture Sounds good to me ! (the list of @piyush-garg openshift-pipeline with s :)) |
defaultNamespaces := []string{
"tekton-pipelines",
"openshift-pipelines",
}If we use that, how does |
|
@vdemeester If there is a ldflag that was specified it will :
|
|
The following is the coverage report on the affected files.
|
|
The following is the coverage report on the affected files.
|
|
@chmouel @vdemeester @piyush-garg Addressed all the comments and rebased please do have a look Thank you |
|
@savitaashture i think the unit test needs to be fixed for 0_10? |
|
/test pull-tekton-cli-integration-tests-0_10 |
@chmouel Done |
|
/meow |
|
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
| ifneq ($(SKIPLDFLAG),) | ||
| FLAGS := $(VERSIONLDFLAG) $(SKIPLDFLAG) | ||
| FLAGS := $(VERSIONLDFLAG) $(SKIPLDFLAG) $(NAMESPACELDFLAG) |
piyush-garg
Sep 17, 2020
•
Contributor
we need to handle the cases here carefully, I think it will cause an issue when you will not have skip flag but have namespace flag
or
we need to handle namespace flag case
we need to handle the cases here carefully, I think it will cause an issue when you will not have skip flag but have namespace flag
or
we need to handle namespace flag case
savitaashture
Sep 21, 2020
Author
Contributor
I have tested without specifying skip flag like below
GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags "-X github.com/tektoncd/cli/pkg/cmd/version.namespace=tekton-pipelines"
and it works without any issue
let me know if i miss understand the point which you have mentioned
I have tested without specifying skip flag like below
GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags "-X github.com/tektoncd/cli/pkg/cmd/version.namespace=tekton-pipelines"
and it works without any issue
let me know if i miss understand the point which you have mentioned
piyush-garg
Sep 22, 2020
Contributor
You are not using makefile here :D
You are not using makefile here :D
savitaashture
Sep 22, 2020
Author
Contributor
Updated makefile
tested with following scenario
NAMESPACE=tekton-pipelines SKIP_CHECK_FLAG=true RELEASE_VERSION=0.13 make amd64
NAMESPACE=tekton-pipelines make amd64
NAMESPACE=tekton-pipelines RELEASE_VERSION=0.13 make amd64
SKIP_CHECK_FLAG=true NAMESPACE=tekton-pipelines make amd64
Updated makefile
tested with following scenario
NAMESPACE=tekton-pipelines SKIP_CHECK_FLAG=true RELEASE_VERSION=0.13 make amd64NAMESPACE=tekton-pipelines make amd64NAMESPACE=tekton-pipelines RELEASE_VERSION=0.13 make amd64SKIP_CHECK_FLAG=true NAMESPACE=tekton-pipelines make amd64
| if pipelineVersion == "" { | ||
| pipelineVersion = "unknown" | ||
| pipelineVersion = "unknown, " + | ||
| "pipeline controller may be installed in another namespace please use tkn version -n {namespace}" |
piyush-garg
Sep 17, 2020
Contributor
Do we need this, as we are planning to no show version in case of unknown
Do we need this, as we are planning to no show version in case of unknown
savitaashture
Sep 21, 2020
Author
Contributor
I see still it exist in the current code so in order to keep in sync with master added this change but if there is a plan to not to show unknown then i think we can remove while doing the PR related to removing unknown changes
WDYT?
I see still it exist in the current code so in order to keep in sync with master added this change but if there is a plan to not to show unknown then i think we can remove while doing the PR related to removing unknown changes
WDYT?
|
The following is the coverage report on the affected files.
|
|
/test pull-tekton-cli-integration-tests |
|
The following is the coverage report on the affected files.
|
|
/test pull-tekton-cli-integration-tests |
|
The following is the coverage report on the affected files.
|
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: piyush-garg, vdemeester 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 |
2587bd1
into
tektoncd:master

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.


Changes
Issue: Authenticated user(non-admin) cannot get the
tkn versioninfo because of permission issue as tkn version generally looks pipeline and triggers controller deployment across the cluster(all-namespaces) and non-admin user generally doesn't have permission to view on all namespaces.So to satisfy admin and non-admin requirements to get the
tkn-versioncome up with the below solution from WG meetingldflagduringtkncompilationtkn version -n {namespace}tekton-pipelinesif noldflagand-nflag specifiedOutput:
ldflagistekton-pipelines1and controllers are running intekton-pipelinesflagBy default
tkn versionlooks Deployment intekton-pipelineoropenshift-pipelinesnamespaceSubmitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make checkmake generatedSee the contribution guide
for more details.
Release Notes