diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-09-05 06:42:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-05 06:42:36 -0400 |
commit | f1323a941c7b5709197def5d10ad79ed24bbbc35 (patch) | |
tree | 3d0e1b98c20b4d5191f86b57d8197bf6daadf4f5 /pkg/bindings | |
parent | 6862cc667761fe3cb8dd45a3491cdca977d493cf (diff) | |
parent | ebfea2f4f89328ec3f74a8deedb3e727ce89ea59 (diff) | |
download | podman-f1323a941c7b5709197def5d10ad79ed24bbbc35.tar.gz podman-f1323a941c7b5709197def5d10ad79ed24bbbc35.tar.bz2 podman-f1323a941c7b5709197def5d10ad79ed24bbbc35.zip |
Merge pull request #7329 from Luap99/generate-systemd-remote
APIv2 add generate systemd endpoint
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/generate/generate.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/bindings/generate/generate.go b/pkg/bindings/generate/generate.go index b02221765..dde1cc29c 100644 --- a/pkg/bindings/generate/generate.go +++ b/pkg/bindings/generate/generate.go @@ -10,6 +10,33 @@ import ( "github.com/containers/podman/v2/pkg/domain/entities" ) +func Systemd(ctx context.Context, nameOrID string, options entities.GenerateSystemdOptions) (*entities.GenerateSystemdReport, error) { + conn, err := bindings.GetClient(ctx) + if err != nil { + return nil, err + } + params := url.Values{} + + params.Set("useName", strconv.FormatBool(options.Name)) + params.Set("new", strconv.FormatBool(options.New)) + if options.RestartPolicy != "" { + params.Set("restartPolicy", options.RestartPolicy) + } + if options.StopTimeout != nil { + params.Set("stopTimeout", strconv.FormatUint(uint64(*options.StopTimeout), 10)) + } + params.Set("containerPrefix", options.ContainerPrefix) + params.Set("podPrefix", options.PodPrefix) + params.Set("separator", options.Separator) + + response, err := conn.DoRequest(nil, http.MethodGet, "/generate/%s/systemd", params, nil, nameOrID) + if err != nil { + return nil, err + } + report := &entities.GenerateSystemdReport{} + return report, response.Process(&report.Units) +} + func Kube(ctx context.Context, nameOrID string, options entities.GenerateKubeOptions) (*entities.GenerateKubeReport, error) { conn, err := bindings.GetClient(ctx) if err != nil { |