diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/api/handlers/compat/auth.go | 59 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 7 | ||||
-rw-r--r-- | pkg/api/handlers/compat/networks.go | 3 | ||||
-rw-r--r-- | pkg/api/server/register_auth.go | 24 | ||||
-rw-r--r-- | pkg/api/server/register_images.go | 2 | ||||
-rw-r--r-- | pkg/api/server/register_networks.go | 45 | ||||
-rw-r--r-- | pkg/api/server/swagger.go | 9 | ||||
-rw-r--r-- | pkg/autoupdate/autoupdate.go | 6 | ||||
-rw-r--r-- | pkg/domain/entities/system.go | 11 | ||||
-rw-r--r-- | pkg/domain/filters/containers.go | 2 | ||||
-rw-r--r-- | pkg/domain/filters/helpers.go | 20 | ||||
-rw-r--r-- | pkg/domain/filters/pods.go | 2 | ||||
-rw-r--r-- | pkg/domain/infra/abi/play.go | 8 | ||||
-rw-r--r-- | pkg/network/network.go | 27 | ||||
-rw-r--r-- | pkg/systemd/define/const.go | 9 | ||||
-rw-r--r-- | pkg/systemd/generate/common.go | 11 | ||||
-rw-r--r-- | pkg/systemd/generate/containers.go | 3 | ||||
-rw-r--r-- | pkg/systemd/generate/containers_test.go | 41 | ||||
-rw-r--r-- | pkg/systemd/generate/pods.go | 3 |
19 files changed, 206 insertions, 86 deletions
diff --git a/pkg/api/handlers/compat/auth.go b/pkg/api/handlers/compat/auth.go new file mode 100644 index 000000000..2c152fbc2 --- /dev/null +++ b/pkg/api/handlers/compat/auth.go @@ -0,0 +1,59 @@ +package compat + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "strings" + + DockerClient "github.com/containers/image/v5/docker" + "github.com/containers/image/v5/types" + "github.com/containers/podman/v3/pkg/api/handlers/utils" + "github.com/containers/podman/v3/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/registries" + docker "github.com/docker/docker/api/types" + "github.com/pkg/errors" +) + +func stripAddressOfScheme(address string) string { + for _, s := range []string{"https", "http"} { + address = strings.TrimPrefix(address, s+"://") + } + return address +} + +func Auth(w http.ResponseWriter, r *http.Request) { + var authConfig docker.AuthConfig + err := json.NewDecoder(r.Body).Decode(&authConfig) + if err != nil { + utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse request")) + return + } + + skipTLS := types.NewOptionalBool(false) + if strings.HasPrefix(authConfig.ServerAddress, "https://localhost/") || strings.HasPrefix(authConfig.ServerAddress, "https://localhost:") || strings.HasPrefix(authConfig.ServerAddress, "localhost:") { + // support for local testing + skipTLS = types.NewOptionalBool(true) + } + + fmt.Println("Authenticating with existing credentials...") + sysCtx := types.SystemContext{ + AuthFilePath: "", + DockerCertPath: "", + DockerInsecureSkipTLSVerify: skipTLS, + SystemRegistriesConfPath: registries.SystemRegistriesConfPath(), + } + registry := stripAddressOfScheme(authConfig.ServerAddress) + if err := DockerClient.CheckAuth(context.Background(), &sysCtx, authConfig.Username, authConfig.Password, registry); err == nil { + utils.WriteResponse(w, http.StatusOK, entities.AuthReport{ + IdentityToken: "", + Status: "Login Succeeded", + }) + } else { + utils.WriteResponse(w, http.StatusBadRequest, entities.AuthReport{ + IdentityToken: "", + Status: "login attempt to " + authConfig.ServerAddress + " failed with status: " + err.Error(), + }) + } +} diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 392f688dd..7751b91a7 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -445,6 +445,13 @@ loop: logrus.Warnf("Failed to json encode error %v", err) } flush() + for _, tag := range query.Tag { + m.Stream = fmt.Sprintf("Successfully tagged %s\n", tag) + if err := enc.Encode(m); err != nil { + logrus.Warnf("Failed to json encode error %v", err) + } + flush() + } } } break loop diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 28e90ac28..dfb1d7fda 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -16,6 +16,7 @@ import ( "github.com/containers/podman/v3/pkg/api/handlers/utils" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/infra/abi" + networkid "github.com/containers/podman/v3/pkg/network" "github.com/docker/docker/api/types" dockerNetwork "github.com/docker/docker/api/types/network" "github.com/gorilla/schema" @@ -135,7 +136,7 @@ func getNetworkResourceByNameOrID(nameOrID string, runtime *libpod.Runtime, filt report := types.NetworkResource{ Name: conf.Name, - ID: network.GetNetworkID(conf.Name), + ID: networkid.GetNetworkID(conf.Name), Created: time.Unix(int64(stat.Ctim.Sec), int64(stat.Ctim.Nsec)), // nolint: unconvert Scope: "local", Driver: network.DefaultNetworkDriver, diff --git a/pkg/api/server/register_auth.go b/pkg/api/server/register_auth.go index 1e5474462..56e115e30 100644 --- a/pkg/api/server/register_auth.go +++ b/pkg/api/server/register_auth.go @@ -1,13 +1,33 @@ package server import ( + "net/http" + "github.com/containers/podman/v3/pkg/api/handlers/compat" "github.com/gorilla/mux" ) func (s *APIServer) registerAuthHandlers(r *mux.Router) error { - r.Handle(VersionedPath("/auth"), s.APIHandler(compat.UnsupportedHandler)) + // swagger:operation POST /auth compat auth + // --- + // summary: Check auth configuration + // tags: + // - system (compat) + // produces: + // - application/json + // parameters: + // - in: body + // name: authConfig + // description: Authentication to check + // schema: + // $ref: "#/definitions/AuthConfig" + // responses: + // 200: + // $ref: "#/responses/SystemAuthResponse" + // 500: + // $ref: "#/responses/InternalError" + r.Handle(VersionedPath("/auth"), s.APIHandler(compat.Auth)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths - r.Handle("/auth", s.APIHandler(compat.UnsupportedHandler)) + r.Handle("/auth", s.APIHandler(compat.Auth)).Methods(http.MethodPost) return nil } diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index f6a8a37ca..3d86e5d38 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -652,6 +652,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // example: | // (build details...) // Successfully built 8ba084515c724cbf90d447a63600c0a6 + // Successfully tagged your_image:latest // 400: // $ref: "#/responses/BadParamError" // 500: @@ -1485,7 +1486,6 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // description: output from build process // example: | // (build details...) - // Successfully built 8ba084515c724cbf90d447a63600c0a6 // 400: // $ref: "#/responses/BadParamError" // 500: diff --git a/pkg/api/server/register_networks.go b/pkg/api/server/register_networks.go index 68a8d4ae4..c54de952f 100644 --- a/pkg/api/server/register_networks.go +++ b/pkg/api/server/register_networks.go @@ -220,28 +220,6 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { */ r.HandleFunc(VersionedPath("/libpod/networks/{name}"), s.APIHandler(libpod.RemoveNetwork)).Methods(http.MethodDelete) - // swagger:operation GET /libpod/networks/{name}/json libpod libpodInspectNetwork - // --- - // tags: - // - networks - // summary: Inspect a network - // description: Display low level configuration for a CNI network - // parameters: - // - in: path - // name: name - // type: string - // required: true - // description: the name of the network - // produces: - // - application/json - // responses: - // 200: - // $ref: "#/responses/NetworkInspectReport" - // 404: - // $ref: "#/responses/NoSuchNetwork" - // 500: - // $ref: "#/responses/InternalError" - r.HandleFunc(VersionedPath("/libpod/networks/{name}/json"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet) // swagger:operation GET /libpod/networks/{name}/exists libpod libpodExistsNetwork // --- // tags: @@ -289,6 +267,29 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/networks/json"), s.APIHandler(libpod.ListNetworks)).Methods(http.MethodGet) + // swagger:operation GET /libpod/networks/{name}/json libpod libpodInspectNetwork + // --- + // tags: + // - networks + // summary: Inspect a network + // description: Display low level configuration for a CNI network + // parameters: + // - in: path + // name: name + // type: string + // required: true + // description: the name of the network + // produces: + // - application/json + // responses: + // 200: + // $ref: "#/responses/NetworkInspectReport" + // 404: + // $ref: "#/responses/NoSuchNetwork" + // 500: + // $ref: "#/responses/InternalError" + r.HandleFunc(VersionedPath("/libpod/networks/{name}/json"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet) + r.HandleFunc(VersionedPath("/libpod/networks/{name}"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet) // swagger:operation POST /libpod/networks/create libpod libpodCreateNetwork // --- // tags: diff --git a/pkg/api/server/swagger.go b/pkg/api/server/swagger.go index 92efb8ef3..12fd083bb 100644 --- a/pkg/api/server/swagger.go +++ b/pkg/api/server/swagger.go @@ -226,3 +226,12 @@ type swagSystemPruneReport struct { entities.SystemPruneReport } } + +// Auth response +// swagger:response SystemAuthResponse +type swagSystemAuthResponse struct { + // in:body + Body struct { + entities.AuthReport + } +} diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go index 53095c295..e271b9466 100644 --- a/pkg/autoupdate/autoupdate.go +++ b/pkg/autoupdate/autoupdate.go @@ -13,7 +13,7 @@ import ( "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/image" "github.com/containers/podman/v3/pkg/systemd" - systemdGen "github.com/containers/podman/v3/pkg/systemd/generate" + systemdDefine "github.com/containers/podman/v3/pkg/systemd/define" "github.com/containers/podman/v3/pkg/util" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -178,10 +178,10 @@ func AutoUpdate(runtime *libpod.Runtime, options Options) ([]string, []error) { updatedUnits := []string{} for _, ctr := range containersToRestart { labels := ctr.Labels() - unit, exists := labels[systemdGen.EnvVariable] + unit, exists := labels[systemdDefine.EnvVariable] if !exists { // Shouldn't happen but let's be sure of it. - errs = append(errs, errors.Errorf("error auto-updating container %q: no %s label found", ctr.ID(), systemdGen.EnvVariable)) + errs = append(errs, errors.Errorf("error auto-updating container %q: no %s label found", ctr.ID(), systemdDefine.EnvVariable)) continue } _, err := conn.RestartUnit(unit, "replace", nil) diff --git a/pkg/domain/entities/system.go b/pkg/domain/entities/system.go index a1cfb4481..4b8383613 100644 --- a/pkg/domain/entities/system.go +++ b/pkg/domain/entities/system.go @@ -107,3 +107,14 @@ type ComponentVersion struct { type ListRegistriesReport struct { Registries []string } + +// swagger:model AuthConfig +type AuthConfig struct { + types.AuthConfig +} + +// AuthReport describes the response for authentication check +type AuthReport struct { + IdentityToken string + Status string +} diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go index 6f4b4e8a0..98b8f7e88 100644 --- a/pkg/domain/filters/containers.go +++ b/pkg/domain/filters/containers.go @@ -7,7 +7,7 @@ import ( "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod/define" - "github.com/containers/podman/v3/libpod/network" + "github.com/containers/podman/v3/pkg/network" "github.com/containers/podman/v3/pkg/timetype" "github.com/containers/podman/v3/pkg/util" "github.com/pkg/errors" diff --git a/pkg/domain/filters/helpers.go b/pkg/domain/filters/helpers.go deleted file mode 100644 index 6a5fb68b1..000000000 --- a/pkg/domain/filters/helpers.go +++ /dev/null @@ -1,20 +0,0 @@ -package filters - -import ( - "net/url" - "strings" - - "github.com/pkg/errors" -) - -func ParseFilterArgumentsIntoFilters(filters []string) (url.Values, error) { - parsedFilters := make(url.Values) - for _, f := range filters { - t := strings.SplitN(f, "=", 2) - if len(t) < 2 { - return parsedFilters, errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f) - } - parsedFilters.Add(t[0], t[1]) - } - return parsedFilters, nil -} diff --git a/pkg/domain/filters/pods.go b/pkg/domain/filters/pods.go index 53d10213a..0490a4848 100644 --- a/pkg/domain/filters/pods.go +++ b/pkg/domain/filters/pods.go @@ -6,7 +6,7 @@ import ( "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod/define" - "github.com/containers/podman/v3/libpod/network" + "github.com/containers/podman/v3/pkg/network" "github.com/containers/podman/v3/pkg/util" "github.com/pkg/errors" ) diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index b7ca69281..efc7c86e3 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -173,13 +173,13 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY var ctrRestartPolicy string switch podYAML.Spec.RestartPolicy { case v1.RestartPolicyAlways: - ctrRestartPolicy = libpod.RestartPolicyAlways + ctrRestartPolicy = define.RestartPolicyAlways case v1.RestartPolicyOnFailure: - ctrRestartPolicy = libpod.RestartPolicyOnFailure + ctrRestartPolicy = define.RestartPolicyOnFailure case v1.RestartPolicyNever: - ctrRestartPolicy = libpod.RestartPolicyNo + ctrRestartPolicy = define.RestartPolicyNo default: // Default to Always - ctrRestartPolicy = libpod.RestartPolicyAlways + ctrRestartPolicy = define.RestartPolicyAlways } configMaps := []v1.ConfigMap{} diff --git a/pkg/network/network.go b/pkg/network/network.go new file mode 100644 index 000000000..44132ca28 --- /dev/null +++ b/pkg/network/network.go @@ -0,0 +1,27 @@ +package network + +import ( + "crypto/sha256" + "encoding/hex" + "strings" + + "github.com/containernetworking/cni/libcni" +) + +// GetCNIPlugins returns a list of plugins that a given network +// has in the form of a string +func GetCNIPlugins(list *libcni.NetworkConfigList) string { + plugins := make([]string, 0, len(list.Plugins)) + for _, plug := range list.Plugins { + plugins = append(plugins, plug.Network.Type) + } + return strings.Join(plugins, ",") +} + +// GetNetworkID return the network ID for a given name. +// It is just the sha256 hash but this should be good enough. +// The caller has to make sure it is only called with the network name. +func GetNetworkID(name string) string { + hash := sha256.Sum256([]byte(name)) + return hex.EncodeToString(hash[:]) +} diff --git a/pkg/systemd/define/const.go b/pkg/systemd/define/const.go new file mode 100644 index 000000000..1b50be5db --- /dev/null +++ b/pkg/systemd/define/const.go @@ -0,0 +1,9 @@ +package define + +// EnvVariable "PODMAN_SYSTEMD_UNIT" is set in all generated systemd units and +// is set to the unit's (unique) name. +const EnvVariable = "PODMAN_SYSTEMD_UNIT" + +// RestartPolicies includes all valid restart policies to be used in a unit +// file. +var RestartPolicies = []string{"no", "on-success", "on-failure", "on-abnormal", "on-watchdog", "on-abort", "always"} diff --git a/pkg/systemd/generate/common.go b/pkg/systemd/generate/common.go index bbd1a5f92..94a6f4cb5 100644 --- a/pkg/systemd/generate/common.go +++ b/pkg/systemd/generate/common.go @@ -4,25 +4,18 @@ import ( "strconv" "strings" + "github.com/containers/podman/v3/pkg/systemd/define" "github.com/pkg/errors" ) -// EnvVariable "PODMAN_SYSTEMD_UNIT" is set in all generated systemd units and -// is set to the unit's (unique) name. -const EnvVariable = "PODMAN_SYSTEMD_UNIT" - // minTimeoutStopSec is the minimal stop timeout for generated systemd units. // Once exceeded, processes of the services are killed and the cgroup(s) are // cleaned up. const minTimeoutStopSec = 60 -// RestartPolicies includes all valid restart policies to be used in a unit -// file. -var RestartPolicies = []string{"no", "on-success", "on-failure", "on-abnormal", "on-watchdog", "on-abort", "always"} - // validateRestartPolicy checks that the user-provided policy is valid. func validateRestartPolicy(restart string) error { - for _, i := range RestartPolicies { + for _, i := range define.RestartPolicies { if i == restart { return nil } diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go index 92c6d8865..9343a5067 100644 --- a/pkg/systemd/generate/containers.go +++ b/pkg/systemd/generate/containers.go @@ -11,6 +11,7 @@ import ( "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/systemd/define" "github.com/containers/podman/v3/version" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -173,7 +174,7 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst info.Executable = executable } - info.EnvVariable = EnvVariable + info.EnvVariable = define.EnvVariable info.ExecStart = "{{{{.Executable}}}} start {{{{.ContainerNameOrID}}}}" info.ExecStop = "{{{{.Executable}}}} stop {{{{if (ge .StopTimeout 0)}}}}-t {{{{.StopTimeout}}}}{{{{end}}}} {{{{.ContainerNameOrID}}}}" info.ExecStopPost = "{{{{.Executable}}}} stop {{{{if (ge .StopTimeout 0)}}}}-t {{{{.StopTimeout}}}}{{{{end}}}} {{{{.ContainerNameOrID}}}}" diff --git a/pkg/systemd/generate/containers_test.go b/pkg/systemd/generate/containers_test.go index 747c54699..ebbbdb786 100644 --- a/pkg/systemd/generate/containers_test.go +++ b/pkg/systemd/generate/containers_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/containers/podman/v3/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/systemd/define" "github.com/stretchr/testify/assert" ) @@ -398,7 +399,7 @@ WantedBy=multi-user.target default.target PIDFile: "/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/conmon.pid", StopTimeout: 22, PodmanVersion: "CI", - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodID, false, @@ -414,7 +415,7 @@ WantedBy=multi-user.target default.target PIDFile: "/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/conmon.pid", StopTimeout: 22, PodmanVersion: "CI", - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodIDNoHeaderInfo, false, @@ -430,7 +431,7 @@ WantedBy=multi-user.target default.target PIDFile: "/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/conmon.pid", StopTimeout: 10, PodmanVersion: "CI", - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodName, false, @@ -447,7 +448,7 @@ WantedBy=multi-user.target default.target StopTimeout: 10, PodmanVersion: "CI", BoundToServices: []string{"pod", "a", "b", "c"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodNameBoundTo, false, @@ -462,7 +463,7 @@ WantedBy=multi-user.target default.target PIDFile: "/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/conmon.pid", StopTimeout: 10, PodmanVersion: "CI", - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, "", false, @@ -479,7 +480,7 @@ WantedBy=multi-user.target default.target StopTimeout: 10, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "container", "run", "--name", "jadda-jadda", "--hostname", "hello-world", "awesome-image:latest", "command", "arg1", "...", "argN", "foo=arg \"with \" space"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodWithNameAndGeneric, true, @@ -496,7 +497,7 @@ WantedBy=multi-user.target default.target StopTimeout: 10, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "-d", "--name", "jadda-jadda", "--hostname", "hello-world", "awesome-image:latest", "command", "arg1", "...", "argN"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodWithExplicitShortDetachParam, true, @@ -513,7 +514,7 @@ WantedBy=multi-user.target default.target StopTimeout: 10, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "-d", "--name", "jadda-jadda", "--hostname", "hello-world", "awesome-image:latest", "command", "arg1", "...", "argN"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, Pod: &podInfo{ PodIDFile: "%t/pod-foobar.pod-id-file", }, @@ -533,7 +534,7 @@ WantedBy=multi-user.target default.target StopTimeout: 10, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "--detach", "--name", "jadda-jadda", "--hostname", "hello-world", "awesome-image:latest", "command", "arg1", "...", "argN"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodNameNewDetach, true, @@ -550,7 +551,7 @@ WantedBy=multi-user.target default.target StopTimeout: 10, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "awesome-image:latest"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodIDNew, true, @@ -567,7 +568,7 @@ WantedBy=multi-user.target default.target StopTimeout: 42, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "--detach=true", "awesome-image:latest"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, genGoodNewDetach("--detach=true"), true, @@ -584,7 +585,7 @@ WantedBy=multi-user.target default.target StopTimeout: 42, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "--detach=false", "awesome-image:latest"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, genGoodNewDetach("-d"), true, @@ -601,7 +602,7 @@ WantedBy=multi-user.target default.target StopTimeout: 42, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "--name", "test", "-p", "80:80", "--detach=false", "awesome-image:latest", "somecmd", "--detach=false"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodNameNewDetachFalseWithCmd, true, @@ -618,7 +619,7 @@ WantedBy=multi-user.target default.target StopTimeout: 42, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "--name", "test", "-p", "80:80", "--detach=false", "--detach=false", "awesome-image:latest", "somecmd", "--detach=false"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodNameNewDetachFalseWithCmd, true, @@ -635,7 +636,7 @@ WantedBy=multi-user.target default.target StopTimeout: 42, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "-dti", "awesome-image:latest"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, genGoodNewDetach("-dti"), true, @@ -652,7 +653,7 @@ WantedBy=multi-user.target default.target StopTimeout: 42, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "run", "-tid", "awesome-image:latest"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, genGoodNewDetach("-tid"), true, @@ -669,7 +670,7 @@ WantedBy=multi-user.target default.target StopTimeout: 42, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "--events-backend", "none", "--runroot", "/root", "run", "awesome-image:latest"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodNewRootFlags, true, @@ -686,7 +687,7 @@ WantedBy=multi-user.target default.target StopTimeout: 10, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "container", "create", "awesome-image:latest"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodContainerCreate, true, @@ -703,7 +704,7 @@ WantedBy=multi-user.target default.target StopTimeout: 10, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "create", "--name", "test", "--log-driver=journald", "--log-opt=tag={{.Name}}", "awesome-image:latest"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodNewWithJournaldTag, true, @@ -720,7 +721,7 @@ WantedBy=multi-user.target default.target StopTimeout: 10, PodmanVersion: "CI", CreateCommand: []string{"I'll get stripped", "create", "--name", "test", "awesome-image:latest", "sh", "-c", "kill $$ && echo %\\"}, - EnvVariable: EnvVariable, + EnvVariable: define.EnvVariable, }, goodNewWithSpecialChars, true, diff --git a/pkg/systemd/generate/pods.go b/pkg/systemd/generate/pods.go index 8c0401278..f96058d36 100644 --- a/pkg/systemd/generate/pods.go +++ b/pkg/systemd/generate/pods.go @@ -11,6 +11,7 @@ import ( "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/systemd/define" "github.com/containers/podman/v3/version" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -237,7 +238,7 @@ func executePodTemplate(info *podInfo, options entities.GenerateSystemdOptions) info.Executable = executable } - info.EnvVariable = EnvVariable + info.EnvVariable = define.EnvVariable info.ExecStart = "{{{{.Executable}}}} start {{{{.InfraNameOrID}}}}" info.ExecStop = "{{{{.Executable}}}} stop {{{{if (ge .StopTimeout 0)}}}}-t {{{{.StopTimeout}}}}{{{{end}}}} {{{{.InfraNameOrID}}}}" info.ExecStopPost = "{{{{.Executable}}}} stop {{{{if (ge .StopTimeout 0)}}}}-t {{{{.StopTimeout}}}}{{{{end}}}} {{{{.InfraNameOrID}}}}" |