func NewServiceConfig(options *Options) *ServiceConfig {
	if options == nil {
		options = &Options{
			Mirrors:            opts.NewListOpts(nil),
			InsecureRegistries: opts.NewListOpts(nil),
		}
	}

	// Localhost is by default considered as an insecure registry
	// This is a stop-gap for people who are running a private registry on localhost (especially on Boot2docker).
	//
	// TODO: should we deprecate this once it is easier for people to set up a TLS registry or change
	// daemon flags on boot2docker?
	options.InsecureRegistries.Set("127.0.0.0/8")

	config := &ServiceConfig{
		InsecureRegistryCIDRs: make([]*netIPNet, 0),
		IndexConfigs:          make(map[string]*IndexInfo, 0),
		// Hack: Bypass setting the mirrors to IndexConfigs since they are going away
		// and Mirrors are only for the official registry anyways.
		Mirrors: options.Mirrors.GetAll(),
	}
	// Split --insecure-registry into CIDR and registry-specific settings.
	for _, r := range options.InsecureRegistries.GetAll() {
		// Check if CIDR was passed to --insecure-registry
		_, ipnet, err := net.ParseCIDR(r)
		if err == nil {
			// Valid CIDR.
			config.InsecureRegistryCIDRs = append(config.InsecureRegistryCIDRs, (*netIPNet)(ipnet))
		} else {
			// Assume `host:port` if not CIDR.
			config.IndexConfigs[r] = &IndexInfo{
				Name:     r,
				Mirrors:  make([]string, 0),
				Secure:   false,
				Official: false,
			}
		}
	}

	// Configure public registry.
	config.IndexConfigs[IndexName] = &IndexInfo{
		Name:     IndexName,
		Mirrors:  config.Mirrors,
		Secure:   true,
		Official: true,
	}

	return config
}
// NewServiceConfig returns a new instance of ServiceConfig
NewServiceConfig returns a new instance of ServiceConfig
// NewServiceConfig returns a new instance of ServiceConfig
func NewServiceConfig(options *Options) *ServiceConfig {
	if options == nil {
		options = &Options{
			Mirrors:            opts.NewListOpts(nil),
			InsecureRegistries: opts.NewListOpts(nil),
		}
	}
	 TODO: should we deprecate this once it is easier for people to set up a TLS registry or change
	 daemon flags on boot2docker?
	options.InsecureRegistries.Set("127.0.0.0/8")
	config := &ServiceConfig{
		InsecureRegistryCIDRs: make([]*netIPNet, 0),
		IndexConfigs:          make(map[string]*IndexInfo, 0),
		 Hack: Bypass setting the mirrors to IndexConfigs since they are going away
		 and Mirrors are only for the official registry anyways.
		Mirrors: options.Mirrors.GetAll(),
	}
	 Split --insecure-registry into CIDR and registry-specific settings.
	for _, r := range options.InsecureRegistries.GetAll() {
		 Check if CIDR was passed to --insecure-registry
		_, ipnet, err := net.ParseCIDR(r)
		if err == nil {
			 Valid CIDR.
			config.InsecureRegistryCIDRs = append(config.InsecureRegistryCIDRs, (*netIPNet)(ipnet))
		} else {
			 Assume `host:port` if not CIDR.
			config.IndexConfigs[r] = &IndexInfo{
				Name:     r,
				Mirrors:  make([]string, 0),
				Secure:   false,
				Official: false,
			}
		}
	}
	 Configure public registry.
	config.IndexConfigs[IndexName] = &IndexInfo{
		Name:     IndexName,
		Mirrors:  config.Mirrors,
		Secure:   true,
		Official: true,
	}
	return config
}
func NewServiceConfig ( options * Options ) * ServiceConfig { if options == nil { options = & Options { Mirrors : opts . NewListOpts ( nil ) , InsecureRegistries : opts . NewListOpts ( nil ) , } } options . InsecureRegistries . Set ( " " ) config := & ServiceConfig { InsecureRegistryCIDRs : make ( [ ] * netIPNet , 0 ) , IndexConfigs : make ( map [ string ] * IndexInfo , 0 ) , Mirrors : options . Mirrors . GetAll ( ) , } for _ , r := range options . InsecureRegistries . GetAll ( ) { _ , ipnet , err := net . ParseCIDR ( r ) if err == nil { config . InsecureRegistryCIDRs = append ( config . InsecureRegistryCIDRs , ( * netIPNet ) ( ipnet ) ) } else { config . IndexConfigs [ r ] = & IndexInfo { Name : r , Mirrors : make ( [ ] string , 0 ) , Secure : false , Official : false , } } } config . IndexConfigs [ IndexName ] = & IndexInfo { Name : IndexName , Mirrors : config . Mirrors , Secure : true , Official : true , } return config }
NewServiceConfig returns a new instance of ServiceConfig
NewServiceConfig returns a new instance of ServiceConfig
// Localhost is by default considered as an insecure registry // This is a stop-gap for people who are running a private registry on localhost (especially on Boot2docker). // // TODO: should we deprecate this once it is easier for people to set up a TLS registry or change // daemon flags on boot2docker? // Hack: Bypass setting the mirrors to IndexConfigs since they are going away // and Mirrors are only for the official registry anyways. // Split --insecure-registry into CIDR and registry-specific settings. // Check if CIDR was passed to --insecure-registry // Valid CIDR. // Assume `host:port` if not CIDR. // Configure public registry.