File tree 3 files changed +31
-1
lines changed
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,22 @@ func runStart(cmd *cobra.Command, args []string) {
176
176
177
177
if existing != nil {
178
178
upgradeExistingConfig (existing )
179
+ } else {
180
+ validPs , _ , err := config .ListProfiles ()
181
+ if err != nil {
182
+ exit .Message (reason .InternalListConfig , "Unable to list profiles: {{.error}}" , out.V {"error" : err })
183
+ }
184
+ for _ , ps := range validPs {
185
+ for _ , existNode := range ps .Config .Nodes {
186
+ machineName := config .MachineName (* ps .Config , existNode )
187
+ if ClusterFlagValue () == machineName {
188
+ out .WarningT ("Profile name '{{.name}}' is duplicated with machine name '{{.machine}}' in profile '{{.profile}}'" , out.V {"name" : ClusterFlagValue (),
189
+ "machine" : machineName ,
190
+ "profile" : ps .Name })
191
+ exit .Message (reason .Usage , "Profile name should be unique" )
192
+ }
193
+ }
194
+ }
179
195
}
180
196
181
197
validateSpecifiedDriver (existing )
Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ func ProfileFolderPath(profile string, miniHome ...string) string {
291
291
// MachineName returns the name of the machine, as seen by the hypervisor given the cluster and node names
292
292
func MachineName (cc ClusterConfig , n Node ) string {
293
293
// For single node cluster, default to back to old naming
294
- if len (cc .Nodes ) == 1 || n .ControlPlane {
294
+ if ( len (cc .Nodes ) == 1 && cc . Nodes [ 0 ]. Name == n . Name ) || n .ControlPlane {
295
295
return cc .Name
296
296
}
297
297
return fmt .Sprintf ("%s-%s" , cc .Name , n .Name )
Original file line number Diff line number Diff line change @@ -38,6 +38,20 @@ const (
38
38
39
39
// Add adds a new node config to an existing cluster.
40
40
func Add (cc * config.ClusterConfig , n config.Node , delOnFail bool ) error {
41
+ validPs , _ , err := config .ListProfiles ()
42
+ if err != nil {
43
+ return err
44
+ }
45
+
46
+ machineName := config .MachineName (* cc , n )
47
+ for _ , ps := range validPs {
48
+ for _ , existNode := range ps .Config .Nodes {
49
+ if machineName == config .MachineName (* ps .Config , existNode ) {
50
+ return errors .Errorf ("Node %s already exists in %s profile" , machineName , ps .Name )
51
+ }
52
+ }
53
+ }
54
+
41
55
if err := config .SaveNode (cc , & n ); err != nil {
42
56
return errors .Wrap (err , "save node" )
43
57
}
You can’t perform that action at this time.
0 commit comments