Skip to content

Commit

Permalink
Update system connection to add to farm
Browse files Browse the repository at this point in the history
A new --farm flag is being added to podman system connection
add so that when a new connection is added it can be added to a new
or existing farm. Update the code here to be able to do that.

Signed-off-by: Urvashi Mohnani <[email protected]>
  • Loading branch information
umohnani8 committed Aug 3, 2023
1 parent 6821d97 commit 8cad687
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
13 changes: 13 additions & 0 deletions pkg/ssh/connection_golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
1 change: 1 addition & 0 deletions pkg/ssh/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type ConnectionCreateOptions struct {
Identity string
Socket string
Default bool
Farm string
}

type ConnectionDialOptions struct {
Expand Down

0 comments on commit 8cad687

Please sign in to comment.