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

Variable shadowing occurs when variable name's casing is changed #134

Open
tonglil opened this issue Sep 22, 2020 · 0 comments
Open

Variable shadowing occurs when variable name's casing is changed #134

tonglil opened this issue Sep 22, 2020 · 0 comments

Comments

@tonglil
Copy link
Member

tonglil commented Sep 22, 2020

Describe the bug
It is possible to shadow the available vars by changing the casing of the vars: variable.

To reproduce

---
kind: pipeline
type: docker
name: default

steps:
  - name: gke
    image: nytimes/drone-gke
    pull: always
    environment:
      TOKEN:
        from_secret: GOOGLE_CREDENTIALS
    settings:
      dry_run: true
      verbose: true
      zone: us-east1-b
      cluster: test
      namespace: test
      vars:
        NAMESPACE: "override"

Proceeds successfully:

---START VARIABLES AVAILABLE FOR ALL TEMPLATES---
{
	"BRANCH": "test",
	"BUILD_NUMBER": "78",
	"COMMIT": "xxx",
	"NAMESPACE": "override",
	"TAG": "",
	"cluster": "test",
	"namespace": "test",
	"project": "my-project-x",
	"zone": "us-east1-b"
}
---END VARIABLES AVAILABLE FOR ALL TEMPLATES---

Expected behavior
Should error out with Error: var "namespace" shadows existing var.

Version (please complete the following information):

  • Drone: 1.9.0
  • drone-gke: latest
  • Kubernetes:
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.9", GitCommit:"2e808b7cb054ee242b68e62455323aa783991f03", GitTreeState:"clean", BuildDate:"2020-01-18T23:33:14Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.12-gke.16", GitCommit:"013d168bdbdca7bc365fae800272aede20848d7e", GitTreeState:"clean", BuildDate:"2020-07-29T03:47:52Z", GoVersion:"go1.12.17b4", Compiler:"gc", Platform:"linux/amd64"}

Additional context

Potential fix: lowercase all variables when comparing for shadowing.

https://github.com/nytimes/drone-gke/blob/master/main.go#L430
https://github.com/nytimes/drone-gke/blob/master/main.go#L514
https://github.com/nytimes/drone-gke/blob/master/main.go#L532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant