当前位置: 首页>>代码示例>>Golang>>正文


Golang daemon.MergeDaemonConfigurations函数代码示例

本文整理汇总了Golang中github.com/docker/docker/daemon.MergeDaemonConfigurations函数的典型用法代码示例。如果您正苦于以下问题:Golang MergeDaemonConfigurations函数的具体用法?Golang MergeDaemonConfigurations怎么用?Golang MergeDaemonConfigurations使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MergeDaemonConfigurations函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: loadDaemonCliConfig

func loadDaemonCliConfig(config *daemon.Config, daemonFlags *flag.FlagSet, commonConfig *cli.CommonFlags, configFile string) (*daemon.Config, error) {
	config.Debug = commonConfig.Debug
	config.Hosts = commonConfig.Hosts
	config.LogLevel = commonConfig.LogLevel
	config.TLS = commonConfig.TLS
	config.TLSVerify = commonConfig.TLSVerify
	config.TLSOptions = daemon.CommonTLSOptions{}

	if commonConfig.TLSOptions != nil {
		config.TLSOptions.CAFile = commonConfig.TLSOptions.CAFile
		config.TLSOptions.CertFile = commonConfig.TLSOptions.CertFile
		config.TLSOptions.KeyFile = commonConfig.TLSOptions.KeyFile
	}

	if configFile != "" {
		c, err := daemon.MergeDaemonConfigurations(config, daemonFlags, configFile)
		if err != nil {
			if daemonFlags.IsSet(daemonConfigFileFlag) || !os.IsNotExist(err) {
				return nil, fmt.Errorf("unable to configure the Docker daemon with file %s: %v\n", configFile, err)
			}
		}
		// the merged configuration can be nil if the config file didn't exist.
		// leave the current configuration as it is if when that happens.
		if c != nil {
			config = c
		}
	}

	return config, nil
}
开发者ID:Test-Betta-Inc,项目名称:psychic-barnacle,代码行数:30,代码来源:daemon.go

示例2: loadDaemonCliConfig

func loadDaemonCliConfig(opts daemonOptions) (*daemon.Config, error) {
	config := opts.daemonConfig
	flags := opts.flags
	config.Debug = opts.common.Debug
	config.Hosts = opts.common.Hosts
	config.LogLevel = opts.common.LogLevel
	config.TLS = opts.common.TLS
	config.TLSVerify = opts.common.TLSVerify
	config.CommonTLSOptions = daemon.CommonTLSOptions{}

	if opts.common.TLSOptions != nil {
		config.CommonTLSOptions.CAFile = opts.common.TLSOptions.CAFile
		config.CommonTLSOptions.CertFile = opts.common.TLSOptions.CertFile
		config.CommonTLSOptions.KeyFile = opts.common.TLSOptions.KeyFile
	}

	if opts.configFile != "" {
		c, err := daemon.MergeDaemonConfigurations(config, flags, opts.configFile)
		if err != nil {
			if flags.Changed(flagDaemonConfigFile) || !os.IsNotExist(err) {
				return nil, fmt.Errorf("unable to configure the Docker daemon with file %s: %v\n", opts.configFile, err)
			}
		}
		// the merged configuration can be nil if the config file didn't exist.
		// leave the current configuration as it is if when that happens.
		if c != nil {
			config = c
		}
	}

	if err := daemon.ValidateConfiguration(config); err != nil {
		return nil, err
	}

	// Regardless of whether the user sets it to true or false, if they
	// specify TLSVerify at all then we need to turn on TLS
	if config.IsValueSet(cliflags.FlagTLSVerify) {
		config.TLS = true
	}

	// ensure that the log level is the one set after merging configurations
	cliflags.SetLogLevel(config.LogLevel)

	return config, nil
}
开发者ID:kasisnu,项目名称:docker,代码行数:45,代码来源:daemon.go

示例3: loadDaemonCliConfig

func loadDaemonCliConfig(config *daemon.Config, daemonFlags *flag.FlagSet, commonConfig *cli.CommonFlags, configFile string) (*daemon.Config, error) {
	config.Debug = commonConfig.Debug
	config.Hosts = commonConfig.Hosts
	config.LogLevel = commonConfig.LogLevel
	config.TLS = commonConfig.TLS
	config.TLSVerify = commonConfig.TLSVerify
	config.CommonTLSOptions = daemon.CommonTLSOptions{}

	if commonConfig.TLSOptions != nil {
		config.CommonTLSOptions.CAFile = commonConfig.TLSOptions.CAFile
		config.CommonTLSOptions.CertFile = commonConfig.TLSOptions.CertFile
		config.CommonTLSOptions.KeyFile = commonConfig.TLSOptions.KeyFile
	}

	if configFile != "" {
		c, err := daemon.MergeDaemonConfigurations(config, daemonFlags, configFile)
		if err != nil {
			if daemonFlags.IsSet(daemonConfigFileFlag) || !os.IsNotExist(err) {
				return nil, fmt.Errorf("unable to configure the Docker daemon with file %s: %v\n", configFile, err)
			}
		}
		// the merged configuration can be nil if the config file didn't exist.
		// leave the current configuration as it is if when that happens.
		if c != nil {
			config = c
		}
	}

	// Regardless of whether the user sets it to true or false, if they
	// specify TLSVerify at all then we need to turn on TLS
	if config.IsValueSet(tlsVerifyKey) {
		config.TLS = true
	}

	// ensure that the log level is the one set after merging configurations
	setDaemonLogLevel(config.LogLevel)

	return config, nil
}
开发者ID:HackToday,项目名称:docker,代码行数:39,代码来源:daemon.go

示例4: loadDaemonCliConfig

func loadDaemonCliConfig(opts daemonOptions) (*daemon.Config, error) {
	config := opts.daemonConfig
	flags := opts.flags
	config.Debug = opts.common.Debug
	config.Hosts = opts.common.Hosts
	config.LogLevel = opts.common.LogLevel
	config.TLS = opts.common.TLS
	config.TLSVerify = opts.common.TLSVerify
	config.CommonTLSOptions = daemon.CommonTLSOptions{}

	if opts.common.TLSOptions != nil {
		config.CommonTLSOptions.CAFile = opts.common.TLSOptions.CAFile
		config.CommonTLSOptions.CertFile = opts.common.TLSOptions.CertFile
		config.CommonTLSOptions.KeyFile = opts.common.TLSOptions.KeyFile
	}

	if opts.configFile != "" {
		c, err := daemon.MergeDaemonConfigurations(config, flags, opts.configFile)
		if err != nil {
			if flags.Changed(flagDaemonConfigFile) || !os.IsNotExist(err) {
				return nil, fmt.Errorf("unable to configure the Docker daemon with file %s: %v\n", opts.configFile, err)
			}
		}
		// the merged configuration can be nil if the config file didn't exist.
		// leave the current configuration as it is if when that happens.
		if c != nil {
			config = c
		}
	}

	if err := daemon.ValidateConfiguration(config); err != nil {
		return nil, err
	}

	// Labels of the docker engine used to allow multiple values associated with the same key.
	// This is deprecated in 1.13, and, be removed after 3 release cycles.
	// The following will check the conflict of labels, and report a warning for deprecation.
	//
	// TODO: After 3 release cycles (1.16) an error will be returned, and labels will be
	// sanitized to consolidate duplicate key-value pairs (config.Labels = newLabels):
	//
	// newLabels, err := daemon.GetConflictFreeLabels(config.Labels)
	// if err != nil {
	//	return nil, err
	// }
	// config.Labels = newLabels
	//
	if _, err := daemon.GetConflictFreeLabels(config.Labels); err != nil {
		logrus.Warnf("Engine labels with duplicate keys and conflicting values have been deprecated: %s", err)
	}

	// Regardless of whether the user sets it to true or false, if they
	// specify TLSVerify at all then we need to turn on TLS
	if config.IsValueSet(cliflags.FlagTLSVerify) {
		config.TLS = true
	}

	// ensure that the log level is the one set after merging configurations
	cliflags.SetLogLevel(config.LogLevel)

	return config, nil
}
开发者ID:wayneiny,项目名称:docker,代码行数:62,代码来源:daemon.go


注:本文中的github.com/docker/docker/daemon.MergeDaemonConfigurations函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。