コード例 #1
0
ファイル: update.go プロジェクト: rlugojr/docker
func mergeSwarm(swarm *swarm.Swarm, flags *pflag.FlagSet) error {
	spec := &swarm.Spec

	if flags.Changed(flagTaskHistoryLimit) {
		spec.Orchestration.TaskHistoryRetentionLimit, _ = flags.GetInt64(flagTaskHistoryLimit)
	}

	if flags.Changed(flagDispatcherHeartbeat) {
		if v, err := flags.GetDuration(flagDispatcherHeartbeat); err == nil {
			spec.Dispatcher.HeartbeatPeriod = uint64(v.Nanoseconds())
		}
	}

	if flags.Changed(flagCertExpiry) {
		if v, err := flags.GetDuration(flagCertExpiry); err == nil {
			spec.CAConfig.NodeCertExpiry = v
		}
	}

	if flags.Changed(flagExternalCA) {
		value := flags.Lookup(flagExternalCA).Value.(*ExternalCAOption)
		spec.CAConfig.ExternalCAs = value.Value()
	}

	return nil
}
コード例 #2
0
ファイル: update.go プロジェクト: karunchennuri/docker
func mergeSwarm(swarm *swarm.Swarm, flags *pflag.FlagSet) error {
	spec := &swarm.Spec

	if flags.Changed("auto-accept") {
		value := flags.Lookup("auto-accept").Value.(*AutoAcceptOption)
		if len(spec.AcceptancePolicy.Policies) > 0 {
			spec.AcceptancePolicy.Policies = value.Policies(spec.AcceptancePolicy.Policies[0].Secret)
		} else {
			spec.AcceptancePolicy.Policies = value.Policies("")
		}
	}

	if flags.Changed("secret") {
		secret, _ := flags.GetString("secret")
		for _, policy := range spec.AcceptancePolicy.Policies {
			policy.Secret = secret
		}
	}

	if flags.Changed("task-history-limit") {
		spec.Orchestration.TaskHistoryRetentionLimit, _ = flags.GetInt64("task-history-limit")
	}

	if flags.Changed("dispatcher-heartbeat") {
		if v, err := flags.GetDuration("dispatcher-heartbeat"); err == nil {
			spec.Dispatcher.HeartbeatPeriod = uint64(v.Nanoseconds())
		}
	}

	return nil
}
コード例 #3
0
func mergeSwarm(swarm *swarm.Swarm, flags *pflag.FlagSet) error {
	spec := &swarm.Spec

	if flags.Changed(flagAutoAccept) {
		value := flags.Lookup(flagAutoAccept).Value.(*AutoAcceptOption)
		spec.AcceptancePolicy.Policies = value.Policies(nil)
	}

	var psecret *string
	if flags.Changed(flagSecret) {
		secret, _ := flags.GetString(flagSecret)
		psecret = &secret
	}

	for i := range spec.AcceptancePolicy.Policies {
		spec.AcceptancePolicy.Policies[i].Secret = psecret
	}

	if flags.Changed(flagTaskHistoryLimit) {
		spec.Orchestration.TaskHistoryRetentionLimit, _ = flags.GetInt64(flagTaskHistoryLimit)
	}

	if flags.Changed(flagDispatcherHeartbeat) {
		if v, err := flags.GetDuration(flagDispatcherHeartbeat); err == nil {
			spec.Dispatcher.HeartbeatPeriod = uint64(v.Nanoseconds())
		}
	}

	if flags.Changed(flagCertExpiry) {
		if v, err := flags.GetDuration(flagCertExpiry); err == nil {
			spec.CAConfig.NodeCertExpiry = v
		}
	}

	if flags.Changed(flagExternalCA) {
		value := flags.Lookup(flagExternalCA).Value.(*ExternalCAOption)
		spec.CAConfig.ExternalCAs = value.Value()
	}

	return nil
}
コード例 #4
0
ファイル: update.go プロジェクト: johnstevin/docker
func mergeSwarm(swarm *swarm.Swarm, flags *pflag.FlagSet) error {
	spec := &swarm.Spec

	if flags.Changed("auto-accept") {
		value := flags.Lookup("auto-accept").Value.(*AutoAcceptOption)
		spec.AcceptancePolicy.Policies = value.Policies(nil)
	}

	var psecret *string
	if flags.Changed("secret") {
		secret, _ := flags.GetString("secret")
		psecret = &secret
	}

	for i := range spec.AcceptancePolicy.Policies {
		spec.AcceptancePolicy.Policies[i].Secret = psecret
	}

	if flags.Changed("task-history-limit") {
		spec.Orchestration.TaskHistoryRetentionLimit, _ = flags.GetInt64("task-history-limit")
	}

	if flags.Changed("dispatcher-heartbeat") {
		if v, err := flags.GetDuration("dispatcher-heartbeat"); err == nil {
			spec.Dispatcher.HeartbeatPeriod = uint64(v.Nanoseconds())
		}
	}

	if flags.Changed("cert-expiry") {
		if v, err := flags.GetDuration("cert-expiry"); err == nil {
			spec.CAConfig.NodeCertExpiry = v
		}
	}

	return nil
}