mirror of https://github.com/docker/cli.git
api: Remove SecretRequestOption type
This type is only used by CLI code. It duplicates SecretReference in the types/swarm package. Change the CLI code to use that type instead. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
parent
bc771127d8
commit
395081fc6b
|
@ -10,27 +10,19 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseSecrets retrieves the secrets from the requested names and converts
|
// ParseSecrets retrieves the secrets with the requested names and fills
|
||||||
// them to secret references to use with the spec
|
// secret IDs into the secret references.
|
||||||
func ParseSecrets(client client.SecretAPIClient, requestedSecrets []*types.SecretRequestOption) ([]*swarmtypes.SecretReference, error) {
|
func ParseSecrets(client client.SecretAPIClient, requestedSecrets []*swarmtypes.SecretReference) ([]*swarmtypes.SecretReference, error) {
|
||||||
secretRefs := make(map[string]*swarmtypes.SecretReference)
|
secretRefs := make(map[string]*swarmtypes.SecretReference)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
for _, secret := range requestedSecrets {
|
for _, secret := range requestedSecrets {
|
||||||
if _, exists := secretRefs[secret.Target]; exists {
|
if _, exists := secretRefs[secret.File.Name]; exists {
|
||||||
return nil, fmt.Errorf("duplicate secret target for %s not allowed", secret.Source)
|
return nil, fmt.Errorf("duplicate secret target for %s not allowed", secret.SecretName)
|
||||||
}
|
}
|
||||||
secretRef := &swarmtypes.SecretReference{
|
secretRef := new(swarmtypes.SecretReference)
|
||||||
File: &swarmtypes.SecretReferenceFileTarget{
|
*secretRef = *secret
|
||||||
Name: secret.Target,
|
secretRefs[secret.File.Name] = secretRef
|
||||||
UID: secret.UID,
|
|
||||||
GID: secret.GID,
|
|
||||||
Mode: secret.Mode,
|
|
||||||
},
|
|
||||||
SecretName: secret.Source,
|
|
||||||
}
|
|
||||||
|
|
||||||
secretRefs[secret.Target] = secretRef
|
|
||||||
}
|
}
|
||||||
|
|
||||||
args := filters.NewArgs()
|
args := filters.NewArgs()
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
servicecli "github.com/docker/docker/cli/command/service"
|
servicecli "github.com/docker/docker/cli/command/service"
|
||||||
|
@ -196,7 +195,7 @@ func convertServiceSecrets(
|
||||||
secrets []composetypes.ServiceSecretConfig,
|
secrets []composetypes.ServiceSecretConfig,
|
||||||
secretSpecs map[string]composetypes.SecretConfig,
|
secretSpecs map[string]composetypes.SecretConfig,
|
||||||
) ([]*swarm.SecretReference, error) {
|
) ([]*swarm.SecretReference, error) {
|
||||||
opts := []*types.SecretRequestOption{}
|
refs := []*swarm.SecretReference{}
|
||||||
for _, secret := range secrets {
|
for _, secret := range secrets {
|
||||||
target := secret.Target
|
target := secret.Target
|
||||||
if target == "" {
|
if target == "" {
|
||||||
|
@ -222,16 +221,18 @@ func convertServiceSecrets(
|
||||||
mode = uint32Ptr(0444)
|
mode = uint32Ptr(0444)
|
||||||
}
|
}
|
||||||
|
|
||||||
opts = append(opts, &types.SecretRequestOption{
|
refs = append(refs, &swarm.SecretReference{
|
||||||
Source: source,
|
File: &swarm.SecretReferenceFileTarget{
|
||||||
Target: target,
|
Name: target,
|
||||||
UID: uid,
|
UID: uid,
|
||||||
GID: gid,
|
GID: gid,
|
||||||
Mode: os.FileMode(*mode),
|
Mode: os.FileMode(*mode),
|
||||||
|
},
|
||||||
|
SecretName: source,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return servicecli.ParseSecrets(client, opts)
|
return servicecli.ParseSecrets(client, refs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func uint32Ptr(value uint32) *uint32 {
|
func uint32Ptr(value uint32) *uint32 {
|
||||||
|
|
Loading…
Reference in New Issue