forked from vmware-archive/atc
/
fetch_config_action.go
53 lines (43 loc) · 1.2 KB
/
fetch_config_action.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
package exec
import (
"os"
"code.cloudfoundry.org/lager"
"github.com/concourse/atc"
"github.com/concourse/atc/worker"
)
type ConfigFetcher interface {
FetchConfig(repository *worker.ArtifactRepository) (atc.TaskConfig, error)
}
type FetchConfigResultAction interface {
Result() atc.TaskConfig
}
// FetchConfigAction fetches task config based on config source,
// either statically provided or dynamically loaded from worker.ArtifactRepository.
type FetchConfigAction struct {
configFetcher ConfigFetcher
result atc.TaskConfig
}
// Run first load the TaskConfig
func (action *FetchConfigAction) Run(
logger lager.Logger,
repository *worker.ArtifactRepository,
// TODO: consider passing these as context
signals <-chan os.Signal,
ready chan<- struct{},
) error {
var err error
action.result, err = action.configFetcher.FetchConfig(repository)
if err != nil {
return err
}
return nil
}
// Result returns the fetched atc.TaskConfig
func (action *FetchConfigAction) Result() atc.TaskConfig {
return action.result
}
// ExitStatus always 0. Fetching config might error but it does not produce
// any exit status.
func (action *FetchConfigAction) ExitStatus() ExitStatus {
return ExitStatus(0)
}