diff --git a/common/pkg/config/config_test.go b/common/pkg/config/config_test.go index 61cea20bc9..0e5dd525d4 100644 --- a/common/pkg/config/config_test.go +++ b/common/pkg/config/config_test.go @@ -988,7 +988,7 @@ env=["foo=bar"]` gomega.Expect(err).ToNot(gomega.HaveOccurred()) // config should only contain empty stanzas gomega.Expect(string(b)).To(gomega. - Equal("[containers]\n\n[engine]\n\n[machine]\n\n[network]\n\n[secrets]\n\n[configmaps]\n")) + Equal("[containers]\n\n[engine]\n\n[machine]\n\n[network]\n\n[secrets]\n\n[configmaps]\n\n[farms]\n")) }) It("validate ImageVolumeMode", func() { diff --git a/common/pkg/ssh/connection_golang.go b/common/pkg/ssh/connection_golang.go index b9c464478d..9584ae6272 100644 --- a/common/pkg/ssh/connection_golang.go +++ b/common/pkg/ssh/connection_golang.go @@ -64,6 +64,19 @@ func golangConnectionCreate(options ConnectionCreateOptions) error { } else { cfg.Engine.ServiceDestinations[options.Name] = *dst } + + // Create or update an existing farm with the connection being added + if options.Farm != "" { + if len(cfg.Farms.List) == 0 { + cfg.Farms.Default = options.Farm + } + if val, ok := cfg.Farms.List[options.Farm]; ok { + cfg.Farms.List[options.Farm] = append(val, options.Name) + } else { + cfg.Farms.List[options.Farm] = []string{options.Name} + } + } + return cfg.Write() } diff --git a/common/pkg/ssh/types.go b/common/pkg/ssh/types.go index 16512c43f1..600655931d 100644 --- a/common/pkg/ssh/types.go +++ b/common/pkg/ssh/types.go @@ -24,6 +24,7 @@ type ConnectionCreateOptions struct { Identity string Socket string Default bool + Farm string } type ConnectionDialOptions struct {