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 logDriver logDriverOptions
healthcheck healthCheckOptions healthcheck healthCheckOptions
secrets SecretOpt secrets opts.SecretOpt
} }
func newServiceOptions() *serviceOptions { func newServiceOptions() *serviceOptions {

View File

@ -12,25 +12,25 @@ import (
// parseSecrets retrieves the secrets from the requested names and converts // parseSecrets retrieves the secrets from the requested names and converts
// them to secret references to use with the spec // 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) secretRefs := make(map[string]*swarmtypes.SecretReference)
ctx := context.Background() ctx := context.Background()
for _, secret := range requestedSecrets { for _, secret := range requestedSecrets {
secretRef := &swarmtypes.SecretReference{ secretRef := &swarmtypes.SecretReference{
SecretName: secret.source, SecretName: secret.Source,
Target: swarmtypes.SecretReferenceFileTarget{ Target: swarmtypes.SecretReferenceFileTarget{
Name: secret.target, Name: secret.Target,
UID: secret.uid, UID: secret.UID,
GID: secret.gid, GID: secret.GID,
Mode: secret.mode, Mode: secret.Mode,
}, },
} }
if _, exists := secretRefs[secret.target]; exists { if _, exists := secretRefs[secret.Target]; 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.Source)
} }
secretRefs[secret.target] = secretRef secretRefs[secret.Target] = secretRef
} }
args := filters.NewArgs() 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) { func getUpdatedSecrets(apiClient client.APIClient, flags *pflag.FlagSet, secrets []*swarm.SecretReference) ([]*swarm.SecretReference, error) {
if flags.Changed(flagSecretAdd) { if flags.Changed(flagSecretAdd) {
values := flags.Lookup(flagSecretAdd).Value.(*SecretOpt).Value() values := flags.Lookup(flagSecretAdd).Value.(*opts.SecretOpt).Value()
addSecrets, err := parseSecrets(apiClient, values) addSecrets, err := parseSecrets(apiClient, values)
if err != nil { if err != nil {