diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-10-26 10:53:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-26 10:53:26 +0000 |
commit | 4d75df8be380cff4df082bd6fc2f05aa2c433723 (patch) | |
tree | 99ef73a78541017921848d11729384e019d2f1ff /pkg/specgen | |
parent | f82f93c9bdaca49765019966df43384d34469575 (diff) | |
parent | acd8b4900058c364a660a4a01319a8d9cd097896 (diff) | |
download | podman-4d75df8be380cff4df082bd6fc2f05aa2c433723.tar.gz podman-4d75df8be380cff4df082bd6fc2f05aa2c433723.tar.bz2 podman-4d75df8be380cff4df082bd6fc2f05aa2c433723.zip |
Merge pull request #12086 from rhatdan/log
Add support to play kube for --log-opt
Diffstat (limited to 'pkg/specgen')
-rw-r--r-- | pkg/specgen/generate/kube/kube.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index 6eebc6376..c502a6e62 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -19,6 +19,7 @@ import ( "github.com/containers/podman/v3/pkg/specgen" "github.com/containers/podman/v3/pkg/specgen/generate" "github.com/containers/podman/v3/pkg/util" + "github.com/docker/go-units" spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" v1 "k8s.io/api/core/v1" @@ -116,6 +117,8 @@ type CtrSpecGenOptions struct { SecretsManager *secrets.SecretsManager // LogDriver which should be used for the container LogDriver string + // LogOptions log options which should be used for the container + LogOptions []string // Labels define key-value pairs of metadata Labels map[string]string // @@ -144,6 +147,27 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener Driver: opts.LogDriver, } + for _, o := range opts.LogOptions { + split := strings.SplitN(o, "=", 2) + if len(split) < 2 { + return nil, errors.Errorf("invalid log option %q", o) + } + switch strings.ToLower(split[0]) { + case "driver": + s.LogConfiguration.Driver = split[1] + case "path": + s.LogConfiguration.Path = split[1] + case "max-size": + logSize, err := units.FromHumanSize(split[1]) + if err != nil { + return nil, err + } + s.LogConfiguration.Size = logSize + default: + s.LogConfiguration.Options[split[0]] = split[1] + } + } + s.InitContainerType = opts.InitContainerType setupSecurityContext(s, opts.Container) |