mirror of
https://github.com/containers/podman.git
synced 2025-10-18 11:42:55 +08:00
Secret create - add ignore option to allow noop
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
This commit is contained in:
@ -27,6 +27,7 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
|
||||
DriverOpts map[string]string `schema:"driveropts"`
|
||||
Labels map[string]string `schema:"labels"`
|
||||
Replace bool `schema:"replace"`
|
||||
Ignore bool `schema:"ignore"`
|
||||
}{
|
||||
// override any golang type defaults
|
||||
}
|
||||
@ -40,6 +41,7 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
|
||||
opts.DriverOpts = query.DriverOpts
|
||||
opts.Labels = query.Labels
|
||||
opts.Replace = query.Replace
|
||||
opts.Ignore = query.Ignore
|
||||
|
||||
ic := abi.ContainerEngine{Libpod: runtime}
|
||||
report, err := ic.SecretCreate(r.Context(), query.Name, r.Body, opts)
|
||||
|
@ -29,4 +29,5 @@ type CreateOptions struct {
|
||||
DriverOpts map[string]string
|
||||
Labels map[string]string
|
||||
Replace *bool
|
||||
Ignore *bool
|
||||
}
|
||||
|
@ -91,3 +91,18 @@ func (o *CreateOptions) GetReplace() bool {
|
||||
}
|
||||
return *o.Replace
|
||||
}
|
||||
|
||||
// WithIgnore set field Ignore to given value
|
||||
func (o *CreateOptions) WithIgnore(value bool) *CreateOptions {
|
||||
o.Ignore = &value
|
||||
return o
|
||||
}
|
||||
|
||||
// GetIgnore returns value of field Ignore
|
||||
func (o *CreateOptions) GetIgnore() bool {
|
||||
if o.Ignore == nil {
|
||||
var z bool
|
||||
return z
|
||||
}
|
||||
return *o.Ignore
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ type SecretCreateOptions struct {
|
||||
DriverOpts map[string]string
|
||||
Labels map[string]string
|
||||
Replace bool
|
||||
Ignore bool
|
||||
}
|
||||
|
||||
type SecretInspectOptions struct {
|
||||
|
@ -47,9 +47,10 @@ func (ic *ContainerEngine) SecretCreate(ctx context.Context, name string, reader
|
||||
}
|
||||
|
||||
storeOpts := secrets.StoreOptions{
|
||||
DriverOpts: options.DriverOpts,
|
||||
Labels: options.Labels,
|
||||
Replace: options.Replace,
|
||||
DriverOpts: options.DriverOpts,
|
||||
Labels: options.Labels,
|
||||
Replace: options.Replace,
|
||||
IgnoreIfExists: options.Ignore,
|
||||
}
|
||||
|
||||
secretID, err := manager.Store(name, data, options.Driver, storeOpts)
|
||||
|
@ -16,7 +16,8 @@ func (ic *ContainerEngine) SecretCreate(ctx context.Context, name string, reader
|
||||
WithDriverOpts(options.DriverOpts).
|
||||
WithName(name).
|
||||
WithLabels(options.Labels).
|
||||
WithReplace(options.Replace)
|
||||
WithReplace(options.Replace).
|
||||
WithIgnore(options.Ignore)
|
||||
created, err := secrets.Create(ic.ClientCtx, reader, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user