-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels