move secretopt to opts pkg

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2016-11-03 11:08:22 -04:00
parent d22e1a91f6
commit 91c08eab93
3 changed files with 11 additions and 11 deletions

View File

@ -432,7 +432,7 @@ type serviceOptions struct {
logDriver logDriverOptions
healthcheck healthCheckOptions
secrets SecretOpt
secrets opts.SecretOpt
}
func newServiceOptions() *serviceOptions {

View File

@ -12,25 +12,25 @@ import (
// parseSecrets retrieves the secrets from the requested names and converts
// them to secret references to use with the spec
func parseSecrets(client client.APIClient, requestedSecrets []*SecretRequestSpec) ([]*swarmtypes.SecretReference, error) {
func parseSecrets(client client.APIClient, requestedSecrets []*types.SecretRequestOptions) ([]*swarmtypes.SecretReference, error) {
secretRefs := make(map[string]*swarmtypes.SecretReference)
ctx := context.Background()
for _, secret := range requestedSecrets {
secretRef := &swarmtypes.SecretReference{
SecretName: secret.source,
SecretName: secret.Source,
Target: swarmtypes.SecretReferenceFileTarget{
Name: secret.target,
UID: secret.uid,
GID: secret.gid,
Mode: secret.mode,
Name: secret.Target,
UID: secret.UID,
GID: secret.GID,
Mode: secret.Mode,
},
}
if _, exists := secretRefs[secret.target]; exists {
return nil, fmt.Errorf("duplicate secret target for %s not allowed", secret.source)
if _, exists := secretRefs[secret.Target]; exists {
return nil, fmt.Errorf("duplicate secret target for %s not allowed", secret.Source)
}
secretRefs[secret.target] = secretRef
secretRefs[secret.Target] = secretRef
}
args := filters.NewArgs()

View File

@ -413,7 +413,7 @@ func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
func getUpdatedSecrets(apiClient client.APIClient, flags *pflag.FlagSet, secrets []*swarm.SecretReference) ([]*swarm.SecretReference, error) {
if flags.Changed(flagSecretAdd) {
values := flags.Lookup(flagSecretAdd).Value.(*SecretOpt).Value()
values := flags.Lookup(flagSecretAdd).Value.(*opts.SecretOpt).Value()
addSecrets, err := parseSecrets(apiClient, values)
if err != nil {