@@ -41,7 +41,7 @@ type FactoryOptions struct {
41
41
// Factory chooses the appropriate service runner for the given data stream, depending
42
42
// on service configuration files defined in the package or data stream.
43
43
func Factory (options FactoryOptions ) (AgentDeployer , error ) {
44
- agentDeployerName , agentDeployerPath , err := selectAgentDeployerType (options )
44
+ agentDeployerName , err := selectAgentDeployerType (options )
45
45
if err != nil {
46
46
return nil , fmt .Errorf ("failed to select agent deployer type: %w" , err )
47
47
}
@@ -68,51 +68,48 @@ func Factory(options FactoryOptions) (AgentDeployer, error) {
68
68
return nil , nil
69
69
case "k8s" :
70
70
opts := KubernetesAgentDeployerOptions {
71
- Profile : options .Profile ,
72
- DefinitionsDir : agentDeployerPath ,
73
- StackVersion : options .StackVersion ,
74
- PolicyName : options .PolicyName ,
75
- DataStream : options .DataStream ,
76
- RunSetup : options .RunSetup ,
77
- RunTestsOnly : options .RunTestsOnly ,
78
- RunTearDown : options .RunTearDown ,
71
+ Profile : options .Profile ,
72
+ StackVersion : options .StackVersion ,
73
+ PolicyName : options .PolicyName ,
74
+ DataStream : options .DataStream ,
75
+ RunSetup : options .RunSetup ,
76
+ RunTestsOnly : options .RunTestsOnly ,
77
+ RunTearDown : options .RunTearDown ,
79
78
}
80
79
return NewKubernetesAgentDeployer (opts )
81
80
}
82
81
return nil , fmt .Errorf ("unsupported agent deployer (name: %s)" , agentDeployerName )
83
82
}
84
83
85
- func selectAgentDeployerType (options FactoryOptions ) (string , string , error ) {
84
+ func selectAgentDeployerType (options FactoryOptions ) (string , error ) {
86
85
devDeployPath , err := FindDevDeployPath (options )
87
86
if errors .Is (err , os .ErrNotExist ) {
88
- return "default" , "" , nil
87
+ return "default" , nil
89
88
}
90
89
if err != nil {
91
- return "" , "" , fmt .Errorf ("can't find \" %s\" directory: %w" , options .DevDeployDir , err )
90
+ return "" , fmt .Errorf ("can't find \" %s\" directory: %w" , options .DevDeployDir , err )
92
91
}
93
92
94
93
agentDeployerNames , err := findAgentDeployers (devDeployPath )
95
94
if errors .Is (err , os .ErrNotExist ) || len (agentDeployerNames ) == 0 {
96
95
logger .Debugf ("Not agent deployer found, using default one" )
97
- return "default" , "" , nil
96
+ return "default" , nil
98
97
}
99
98
if err != nil {
100
- return "" , "" , fmt .Errorf ("failed to find agent deployer: %w" , err )
99
+ return "" , fmt .Errorf ("failed to find agent deployer: %w" , err )
101
100
}
102
101
if len (agentDeployerNames ) != 1 {
103
- return "" , "" , fmt .Errorf ("expected to find only one agent deployer in \" %s\" " , devDeployPath )
102
+ return "" , fmt .Errorf ("expected to find only one agent deployer in \" %s\" " , devDeployPath )
104
103
}
105
104
agentDeployerName := agentDeployerNames [0 ]
106
105
107
- // if package defines `_dev/deploy/docker` folder to start their services, it should be
108
- // using the default agent deployer`
106
+ // if package defines `_dev/deploy/docker` or `_dev/deploy/tf` folder to start their services,
107
+ // it should be using the default agent deployer`
109
108
if agentDeployerName == "docker" || agentDeployerName == "tf" {
110
- return "default" , "" , nil
109
+ return "default" , nil
111
110
}
112
111
113
- // No need to check if this path exists because it comes from a directory list.
114
- agentDeployerPath := filepath .Join (devDeployPath , agentDeployerName )
115
- return agentDeployerName , agentDeployerPath , nil
112
+ return agentDeployerName , nil
116
113
}
117
114
118
115
// FindDevDeployPath function returns a path reference to the "_dev/deploy" directory.
0 commit comments