/
input_env.go
68 lines (53 loc) · 1.53 KB
/
input_env.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package steps
import (
"context"
"sort"
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
"github.com/openshift/ci-tools/pkg/api"
)
type inputEnvironmentStep struct {
name string
values map[string]string
links []api.StepLink
}
// InputEnvironmentStep acts as a shim for a given step, taking a precalculated set of
// inputs and returning those when executed. May be used to substitute a step that does work
// with another that simply reports output.
func InputEnvironmentStep(name string, values map[string]string, links []api.StepLink) api.Step {
return &inputEnvironmentStep{
name: name,
values: values,
links: links,
}
}
var _ api.Step = &inputEnvironmentStep{}
func (s *inputEnvironmentStep) Inputs() (api.InputDefinition, error) {
var values []string
for _, v := range s.values {
values = append(values, v)
}
sort.Strings(values)
return values, nil
}
func (*inputEnvironmentStep) Validate() error { return nil }
func (s *inputEnvironmentStep) Run(ctx context.Context) error {
return nil
}
func (s *inputEnvironmentStep) Name() string {
return s.name
}
func (s *inputEnvironmentStep) Description() string {
return "Used to stub out another step in the graph when the outputs are already known."
}
func (s *inputEnvironmentStep) Requires() []api.StepLink {
return nil
}
func (s *inputEnvironmentStep) Creates() []api.StepLink {
return s.links
}
func (s *inputEnvironmentStep) Provides() api.ParameterMap {
return nil
}
func (s *inputEnvironmentStep) Objects() []ctrlruntimeclient.Object {
return nil
}