atc: initial testflight coverage for var_sources
* uses the dummy credential manager to avoid setting up any external credential managers * only covers a single credential manager; might want to add coverage for multi- later Signed-off-by: Alex Suraci <suraci.alex@gmail.com> Conflicts: atc/creds/dummy/manager_factory.go
This commit is contained in:
parent
4f8858ffdb
commit
1630422e90
|
@ -693,7 +693,7 @@ func validateVarSources(c Config) error {
|
|||
// TODO: this check should eventually be removed once all credential managers
|
||||
// are supported in pipeline. - @evanchaoli
|
||||
switch cm.Type {
|
||||
case "vault":
|
||||
case "vault", "dummy":
|
||||
default:
|
||||
return fmt.Errorf("credential manager type %s is not supported in pipeline yet", cm.Type)
|
||||
}
|
||||
|
|
|
@ -30,10 +30,24 @@ func (factory *managerFactory) AddConfig(group *flags.Group) creds.Manager {
|
|||
}
|
||||
|
||||
func (factory *managerFactory) NewInstance(config interface{}) (creds.Manager, error) {
|
||||
if _, ok := config.(map[string]interface{}); !ok {
|
||||
return nil, fmt.Errorf("invalid dummy config format")
|
||||
} else {
|
||||
manager := &Manager{}
|
||||
return manager, nil
|
||||
configMap, ok := config.(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid dummy credential manager config: %T", config)
|
||||
}
|
||||
|
||||
vars, ok := configMap["vars"].(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid vars config: %T", configMap["vars"])
|
||||
}
|
||||
|
||||
manager := &Manager{}
|
||||
|
||||
for k, v := range vars {
|
||||
manager.Vars = append(manager.Vars, VarFlag{
|
||||
Name: k,
|
||||
Value: v,
|
||||
})
|
||||
}
|
||||
|
||||
return manager, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
var_sources:
|
||||
- type: dummy
|
||||
config:
|
||||
vars:
|
||||
some_var: hello-im-a-var
|
||||
some_numeric_var: 42
|
||||
initial_version_var: hello-im-a-version
|
||||
|
||||
resources:
|
||||
- name: resource-using-vars
|
||||
type: mock
|
||||
source:
|
||||
initial_version: ((initial_version_var))
|
||||
create_files:
|
||||
some_file: ((some_numeric_var))
|
||||
|
||||
jobs:
|
||||
- name: use-vars
|
||||
plan:
|
||||
- get: resource-using-vars
|
||||
- task: use-vars
|
||||
config:
|
||||
platform: linux
|
||||
|
||||
image_resource:
|
||||
type: mock
|
||||
source: {mirror_self: true}
|
||||
|
||||
inputs:
|
||||
- name: resource-using-vars
|
||||
|
||||
run:
|
||||
path: sh
|
||||
args:
|
||||
- -exc
|
||||
- |
|
||||
test "((some_var))" = "hello-im-a-var"
|
||||
test "$(cat resource-using-vars/version)" = "hello-im-a-version"
|
||||
test "$(cat resource-using-vars/some_file)" = "42"
|
|
@ -0,0 +1,15 @@
|
|||
package testflight_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
)
|
||||
|
||||
var _ = Describe("Pipeline Var Sources", func() {
|
||||
BeforeEach(func() {
|
||||
setAndUnpausePipeline("fixtures/var-sources.yml")
|
||||
})
|
||||
|
||||
It("uses the pipeline var sources for resource checking and build execution", func() {
|
||||
fly("trigger-job", "-j", inPipeline("use-vars"), "-w")
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue