From af40dfc2bf614aeb4191916cc2420068696eb776 Mon Sep 17 00:00:00 2001 From: José Guilherme Vanz Date: Tue, 29 Jun 2021 16:39:11 -0300 Subject: --infra-name command line argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the new --infra-name command line argument allowing users to define the name of the infra container Issue #10794 Signed-off-by: José Guilherme Vanz --- pkg/api/handlers/types.go | 1 + pkg/domain/entities/pods.go | 2 ++ pkg/specgen/generate/pod_create.go | 4 ++++ pkg/specgen/pod_validate.go | 3 +++ pkg/specgen/podspecgen.go | 6 ++++++ 5 files changed, 16 insertions(+) (limited to 'pkg') diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index 59f948567..3cc10d70f 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -133,6 +133,7 @@ type PodCreateConfig struct { Infra bool `json:"infra"` InfraCommand string `json:"infra-command"` InfraImage string `json:"infra-image"` + InfraName string `json:"infra-name"` Labels []string `json:"labels"` Publish []string `json:"publish"` Share string `json:"share"` diff --git a/pkg/domain/entities/pods.go b/pkg/domain/entities/pods.go index a0a2a1790..68e335f8d 100644 --- a/pkg/domain/entities/pods.go +++ b/pkg/domain/entities/pods.go @@ -112,6 +112,7 @@ type PodCreateOptions struct { Hostname string Infra bool InfraImage string + InfraName string InfraCommand string InfraConmonPidFile string Labels map[string]string @@ -172,6 +173,7 @@ func (p *PodCreateOptions) ToPodSpecGen(s *specgen.PodSpecGenerator) error { s.InfraConmonPidFile = p.InfraConmonPidFile } s.InfraImage = p.InfraImage + s.InfraName = p.InfraName s.SharedNamespaces = p.Share s.PodCreateCommand = p.CreateCommand diff --git a/pkg/specgen/generate/pod_create.go b/pkg/specgen/generate/pod_create.go index 4ffd8a37f..aab29499e 100644 --- a/pkg/specgen/generate/pod_create.go +++ b/pkg/specgen/generate/pod_create.go @@ -98,6 +98,10 @@ func createPodOptions(p *specgen.PodSpecGenerator, rt *libpod.Runtime) ([]libpod options = append(options, libpod.WithInfraImage(p.InfraImage)) } + if len(p.InfraName) > 0 { + options = append(options, libpod.WithInfraName(p.InfraName)) + } + if len(p.InfraCommand) > 0 { options = append(options, libpod.WithInfraCommand(p.InfraCommand)) } diff --git a/pkg/specgen/pod_validate.go b/pkg/specgen/pod_validate.go index c746bcd1a..bca7b6dbe 100644 --- a/pkg/specgen/pod_validate.go +++ b/pkg/specgen/pod_validate.go @@ -36,6 +36,9 @@ func (p *PodSpecGenerator) Validate() error { if len(p.InfraImage) > 0 { return exclusivePodOptions("NoInfra", "InfraImage") } + if len(p.InfraName) > 0 { + return exclusivePodOptions("NoInfra", "InfraName") + } if len(p.SharedNamespaces) > 0 { return exclusivePodOptions("NoInfra", "SharedNamespaces") } diff --git a/pkg/specgen/podspecgen.go b/pkg/specgen/podspecgen.go index 319345c71..02237afe9 100644 --- a/pkg/specgen/podspecgen.go +++ b/pkg/specgen/podspecgen.go @@ -43,6 +43,12 @@ type PodBasicConfig struct { // Conflicts with NoInfra=true. // Optional. InfraImage string `json:"infra_image,omitempty"` + // InfraName is the name that will be used for the infra container. + // If not set, the default set in the Libpod configuration file will be + // used. + // Conflicts with NoInfra=true. + // Optional. + InfraName string `json:"infra_name,omitempty"` // SharedNamespaces instructs the pod to share a set of namespaces. // Shared namespaces will be joined (by default) by every container // which joins the pod. -- cgit v1.2.3-54-g00ecf