Skip to content

Commit 54fc3bf

Browse files
Refactor Metadata EnvVars and UnboundEnvVars on metadataTest (#314)
1 parent 3e6fe0f commit 54fc3bf

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ of these checks are optional.
212212

213213
#### Supported Fields:
214214

215-
- Env (`[]EnvVar`): A list of environment variable key/value pairs that should be set
215+
- EnvVars (`[]EnvVar`): A list of environment variable key/value pairs that should be set
216216
in the container. isRegex (*optional*) interpretes the value as regex.
217-
- UnboundEnv (`[]EnvVar`): A list of environment variable keys that should **NOT** be set
217+
- UnboundEnvVars (`[]EnvVar`): A list of environment variable keys that should **NOT** be set
218218
in the container.
219219
- Labels (`[]Label`): A list of image labels key/value pairs that should be set on the
220220
container. isRegex (*optional*) interpretes the value as regex.

pkg/types/v2/metadata.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
)
2424

2525
type MetadataTest struct {
26-
Env []types.EnvVar `yaml:"env"`
27-
UnboundEnv []types.EnvVar `yaml:"unboundEnv"`
26+
EnvVars []types.EnvVar `yaml:"envVars"`
27+
UnboundEnvVars []types.EnvVar `yaml:"unboundEnvVars"`
2828
ExposedPorts []string `yaml:"exposedPorts"`
2929
UnexposedPorts []string `yaml:"unexposedPorts"`
3030
Entrypoint *[]string `yaml:"entrypoint"`
@@ -37,8 +37,8 @@ type MetadataTest struct {
3737
}
3838

3939
func (mt MetadataTest) IsEmpty() bool {
40-
return len(mt.Env) == 0 &&
41-
len(mt.UnboundEnv) == 0 &&
40+
return len(mt.EnvVars) == 0 &&
41+
len(mt.UnboundEnvVars) == 0 &&
4242
len(mt.ExposedPorts) == 0 &&
4343
len(mt.UnexposedPorts) == 0 &&
4444
mt.Entrypoint == nil &&
@@ -58,7 +58,7 @@ func (mt MetadataTest) Validate(channel chan interface{}) bool {
5858
res := &types.TestResult{
5959
Name: mt.LogName(),
6060
}
61-
for _, envVar := range mt.Env {
61+
for _, envVar := range mt.EnvVars {
6262
if envVar.Key == "" {
6363
res.Error("Environment variable key cannot be empty")
6464
}
@@ -98,7 +98,7 @@ func (mt MetadataTest) Run(driver drivers.Driver) *types.TestResult {
9898
return result
9999
}
100100

101-
for _, pair := range mt.Env {
101+
for _, pair := range mt.EnvVars {
102102
if val, ok := imageConfig.Env[pair.Key]; ok {
103103
var match bool
104104
if pair.IsRegex {
@@ -116,7 +116,7 @@ func (mt MetadataTest) Run(driver drivers.Driver) *types.TestResult {
116116
}
117117
}
118118

119-
for _, pair := range mt.UnboundEnv {
119+
for _, pair := range mt.UnboundEnvVars {
120120
if _, ok := imageConfig.Env[pair.Key]; ok {
121121
result.Errorf("env variable %s should not be present in image metadata", pair.Key)
122122
result.Fail()

tests/amd64/ubuntu_20_04_metadata_test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
schemaVersion: '2.0.0' # Make sure to test the latest schema version
22
metadataTest:
3-
env:
3+
envVars:
44
- key: 'SOME_KEY'
55
value: 'SOME_VAL'
66
- key: 'EMPTY_VAR'
@@ -10,7 +10,7 @@ metadataTest:
1010
- key: 'REGEX_VAR'
1111
value: '[a-z]+-2\.1\.*'
1212
isRegex: true
13-
unboundEnv:
13+
unboundEnvVars:
1414
- key: 'BAR_FOO'
1515
labels:
1616
- key: 'localnet.localdomain.commit_hash'

tests/arm64/ubuntu_20_04_metadata_test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
schemaVersion: '2.0.0' # Make sure to test the latest schema version
22
metadataTest:
3-
env:
3+
envVars:
44
- key: 'SOME_KEY'
55
value: 'SOME_VAL'
66
- key: 'EMPTY_VAR'
@@ -10,7 +10,7 @@ metadataTest:
1010
- key: 'REGEX_VAR'
1111
value: '[a-z]+-2\.1\.*'
1212
isRegex: true
13-
unboundEnv:
13+
unboundEnvVars:
1414
- key: 'BAR_FOO'
1515
labels:
1616
- key: 'localnet.localdomain.commit_hash'

tests/ppc64le/ubuntu_20_04_metadata_test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
schemaVersion: '2.0.0' # Make sure to test the latest schema version
22
metadataTest:
3-
env:
3+
envVars:
44
- key: 'SOME_KEY'
55
value: 'SOME_VAL'
66
- key: 'EMPTY_VAR'
@@ -10,7 +10,7 @@ metadataTest:
1010
- key: 'REGEX_VAR'
1111
value: '[a-z]+-2\.1\.*'
1212
isRegex: true
13-
unboundEnv:
13+
unboundEnvVars:
1414
- key: 'BAR_FOO'
1515
labels:
1616
- key: 'localnet.localdomain.commit_hash'

tests/s390x/ubuntu_20_04_metadata_test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
schemaVersion: '2.0.0' # Make sure to test the latest schema version
22
metadataTest:
3-
env:
3+
envVars:
44
- key: 'SOME_KEY'
55
value: 'SOME_VAL'
66
- key: 'EMPTY_VAR'
@@ -10,7 +10,7 @@ metadataTest:
1010
- key: 'REGEX_VAR'
1111
value: '[a-z]+-2\.1\.*'
1212
isRegex: true
13-
unboundEnv:
13+
unboundEnvVars:
1414
- key: 'BAR_FOO'
1515
labels:
1616
- key: 'localnet.localdomain.commit_hash'

0 commit comments

Comments
 (0)