mirror of
https://github.com/containers/podman.git
synced 2025-06-26 04:46:57 +08:00
Merge pull request #9036 from baude/composelog
Set log driver for compatibility containers
This commit is contained in:
@ -402,7 +402,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
|
||||
logDriverFlagName := "log-driver"
|
||||
createFlags.StringVar(
|
||||
&cf.LogDriver,
|
||||
logDriverFlagName, "",
|
||||
logDriverFlagName, logDriver(),
|
||||
"Logging driver for the container",
|
||||
)
|
||||
_ = cmd.RegisterFlagCompletionFunc(logDriverFlagName, AutocompleteLogDriver)
|
||||
|
@ -517,3 +517,10 @@ func volumes() []string {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func logDriver() string {
|
||||
if !registry.IsRemote() {
|
||||
return containerConfig.Containers.LogDriver
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
|
||||
if s.LogConfiguration == nil {
|
||||
s.LogConfiguration = &specgen.LogConfig{}
|
||||
}
|
||||
s.LogConfiguration.Driver = define.KubernetesLogging
|
||||
|
||||
if ld := c.LogDriver; len(ld) > 0 {
|
||||
s.LogConfiguration.Driver = ld
|
||||
}
|
||||
|
@ -327,6 +327,11 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
||||
state.Running = true
|
||||
}
|
||||
|
||||
// docker calls the configured state "created"
|
||||
if state.Status == define.ContainerStateConfigured.String() {
|
||||
state.Status = define.ContainerStateCreated.String()
|
||||
}
|
||||
|
||||
formatCapabilities(inspect.HostConfig.CapDrop)
|
||||
formatCapabilities(inspect.HostConfig.CapAdd)
|
||||
|
||||
@ -338,6 +343,11 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
||||
if err := json.Unmarshal(h, &hc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// k8s-file == json-file
|
||||
if hc.LogConfig.Type == define.KubernetesLogging {
|
||||
hc.LogConfig.Type = define.JSONLogging
|
||||
}
|
||||
g, err := json.Marshal(inspect.GraphDriver)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -257,6 +257,14 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
|
||||
}
|
||||
}
|
||||
|
||||
if s.LogConfiguration == nil {
|
||||
s.LogConfiguration = &specgen.LogConfig{}
|
||||
}
|
||||
// set log-driver from common if not already set
|
||||
if len(s.LogConfiguration.Driver) < 1 {
|
||||
s.LogConfiguration.Driver = rtc.Containers.LogDriver
|
||||
}
|
||||
|
||||
warnings, err := verifyContainerResources(s)
|
||||
if err != nil {
|
||||
return warnings, err
|
||||
|
Reference in New Issue
Block a user