Skip to content

Commit 62c0e7d

Browse files
authored
Merge pull request #2031 from ripienaar/2029.1
(#2029) allow the name of generated agents to be customised
2 parents 634c2b6 + 0367610 commit 62c0e7d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

aagent/watchers/machineswatcher/machines.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ type Properties struct {
8585
PublicKey string `mapstructure:"public_key"`
8686
// Directory sets the directory where plugins are being deployed into, when empty defaults to machines directory like /etc/choria/machines
8787
Directory string `mapstructure:"plugins_directory"`
88+
// ManagerMachinePrefix the prefix used in constructing names for the managed machines
89+
ManagerMachinePrefix string `mapstructure:"manager_machine_prefix"`
8890
}
8991

9092
type Watcher struct {
@@ -142,6 +144,10 @@ func New(machine model.Machine, name string, states []string, failEvent string,
142144
machines.properties.PublicKey = pk
143145
}
144146

147+
if machines.properties.ManagerMachinePrefix == "" {
148+
machines.properties.ManagerMachinePrefix = "mm_"
149+
}
150+
145151
return machines, nil
146152
}
147153

@@ -326,7 +332,7 @@ func (w *Watcher) targetDirForManagedPlugins() string {
326332
}
327333

328334
func (w *Watcher) targetDirForManagerMachine(m string) string {
329-
return filepath.Join(filepath.Dir(w.machine.Directory()), fmt.Sprintf("mm_%s", m))
335+
return filepath.Join(filepath.Dir(w.machine.Directory()), fmt.Sprintf("%s%s", w.properties.ManagerMachinePrefix, m))
330336
}
331337

332338
func (w *Watcher) targetDirForManagedMachine(m string) string {

0 commit comments

Comments
 (0)