// NetworkConfig returns information about all given relation/unit pairs,
// including their id, key and the local endpoint.
// It's not included in APIv5
// TODO(wpk): NetworkConfig API is obsoleted by Uniter.NetworkInfo
7746
func (u *UniterAPIV4) NetworkConfig(args params.UnitsNetworkConfig) (params.UnitNetworkConfigResults, error) {
	result := params.UnitNetworkConfigResults{
		Results: make([]params.UnitNetworkConfigResult, len(args.Args)),
	}

	canAccess, err := u.accessUnit()
	if err != nil {
		return params.UnitNetworkConfigResults{}, err
	}

	for i, arg := range args.Args {
		netConfig, err := u.getOneNetworkConfig(canAccess, arg.UnitTag, arg.BindingName)
		if err == nil {
			result.Results[i].Config = netConfig
		} else {
			result.Results[i].Error = common.ServerError(err)
		}
	}
	return result, nil
}
25772
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config == nil {
		return nil, errors.New("sakuracloud: the configuration of the DNS provider is nil")
	}

	if config.Token == "" {
		return nil, errors.New("sakuracloud: AccessToken is missing")
	}

	if config.Secret == "" {
		return nil, errors.New("sakuracloud: AccessSecret is missing")
	}

	apiClient := api.NewClient(config.Token, config.Secret, "is1a")
	if config.HTTPClient == nil {
		apiClient.HTTPClient = http.DefaultClient
	} else {
		apiClient.HTTPClient = config.HTTPClient
	}

	return &DNSProvider{
		client: apiClient.GetDNSAPI(),
		config: config,
	}, nil
}
207266
func (s *RunTaskInput) SetNetworkConfiguration(v *NetworkConfiguration) *RunTaskInput {
	s.NetworkConfiguration = v
	return s
}
688438
func getNetworking(c *InstanceConfig) (string, string, error) {
	networkId := c.Network
	subnetworkId := c.Subnetwork

	// Apply network naming requirements per
	// https://cloud.google.com/compute/docs/reference/latest/instances#resource
	switch c.Network {
	// It is possible to omit the network property as long as a subnet is
	// specified. That will be validated later.
	case "":
		break
	// This special short name should be expanded.
	case "default":
		networkId = "global/networks/default"
	// A value other than "default" was provided for the network name.
	default:
		// If the value doesn't contain a slash, we assume it's not a full or
		// partial URL. We will expand it into a partial URL here and avoid
		// making an API call to discover the network as it's common for the
		// caller to not have permission against network discovery APIs.
		if !strings.Contains(c.Network, "/") {
			networkId = "projects/" + c.NetworkProjectId + "/global/networks/" + c.Network
		}
	}

	// Apply subnetwork naming requirements per
	// https://cloud.google.com/compute/docs/reference/latest/instances#resource
	switch c.Subnetwork {
	case "":
		// You can't omit both subnetwork and network
		if networkId == "" {
			return networkId, subnetworkId, fmt.Errorf("both network and subnetwork were empty.")
		}
		// An empty subnetwork is only valid for networks in legacy mode or
		// auto-subnet mode. We could make an API call to get that information
		// about the network, but it's common for the caller to not have
		// permission to that API. We'll proceed assuming they're correct in
		// omitting the subnetwork and let the compute.insert API surface an
		// error about an invalid network configuration if it exists.
		break
	default:
		// If the value doesn't contain a slash, we assume it's not a full or
		// partial URL. We will expand it into a partial URL here and avoid
		// making a call to discover the subnetwork.
		if !strings.Contains(c.Subnetwork, "/") {
			subnetworkId = "projects/" + c.NetworkProjectId + "/regions/" + c.Region + "/subnetworks/" + c.Subnetwork
		}
	}
	return networkId, subnetworkId, nil
}
60008
func (api *CrossModelRelationsAPI) RelationUnitSettings(relationUnits params.RemoteRelationUnits) (params.SettingsResults, error) {
	results := params.SettingsResults{
		Results: make([]params.SettingsResult, len(relationUnits.RelationUnits)),
	}
	for i, arg := range relationUnits.RelationUnits {
		relationTag, err := api.st.GetRemoteEntity(arg.RelationToken)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		if err := api.checkMacaroonsForRelation(relationTag, arg.Macaroons); err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}

		ru := params.RelationUnit{
			Relation: relationTag.String(),
			Unit:     arg.Unit,
		}
		settings, err := commoncrossmodel.RelationUnitSettings(api.st, ru)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		results.Results[i].Settings = settings
	}
	return results, nil
}
507789
func (o CustomResourceDefinitionsServerOptions) Config() (*apiserver.Config, error) {
	// TODO have a "real" external address
	if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, []net.IP{net.ParseIP("127.0.0.1")}); err != nil {
		return nil, fmt.Errorf("error creating self-signed certificates: %v", err)
	}

	serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs)
	if err := o.RecommendedOptions.ApplyTo(serverConfig); err != nil {
		return nil, err
	}
	if err := o.APIEnablement.ApplyTo(&serverConfig.Config, apiserver.DefaultAPIResourceConfigSource(), apiserver.Scheme); err != nil {
		return nil, err
	}

	config := &apiserver.Config{
		GenericConfig: serverConfig,
		ExtraConfig: apiserver.ExtraConfig{
			CRDRESTOptionsGetter: NewCRDRESTOptionsGetter(*o.RecommendedOptions.Etcd),
			ServiceResolver:      &serviceResolver{serverConfig.SharedInformerFactory.Core().V1().Services().Lister()},
			AuthResolverWrapper:  webhook.NewDefaultAuthenticationInfoResolverWrapper(nil, serverConfig.LoopbackClientConfig),
		},
	}
	return config, nil
}
1008184
func (c *containerConfig) createNetworkingConfig(b executorpkg.Backend) *network.NetworkingConfig {
	var networks []*api.NetworkAttachment
	if c.task.Spec.GetContainer() != nil || c.task.Spec.GetAttachment() != nil {
		networks = c.task.Networks
	}

	epConfig := make(map[string]*network.EndpointSettings)
	if len(networks) > 0 {
		epConfig[networks[0].Network.Spec.Annotations.Name] = getEndpointConfig(networks[0], b)
	}

	return &network.NetworkingConfig{EndpointsConfig: epConfig}
}
1165101
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config == nil {
		return nil, errors.New("azure: the configuration of the DNS provider is nil")
	}

	if config.HTTPClient == nil {
		config.HTTPClient = http.DefaultClient
	}

	authorizer, err := getAuthorizer(config)
	if err != nil {
		return nil, err
	}

	if config.SubscriptionID == "" {
		subsID, err := getMetadata(config, "subscriptionId")
		if err != nil {
			return nil, fmt.Errorf("azure: %v", err)
		}

		if subsID == "" {
			return nil, errors.New("azure: SubscriptionID is missing")
		}
		config.SubscriptionID = subsID
	}

	if config.ResourceGroup == "" {
		resGroup, err := getMetadata(config, "resourceGroupName")
		if err != nil {
			return nil, fmt.Errorf("azure: %v", err)
		}

		if resGroup == "" {
			return nil, errors.New("azure: ResourceGroup is missing")
		}
		config.ResourceGroup = resGroup
	}

	return &DNSProvider{config: config, authorizer: authorizer}, nil
}
707272
func (m *FanConfigurerAPI) FanConfig() (params.FanConfigResult, error) {
	result := params.FanConfigResult{}
	config, err := m.model.ModelConfig()
	if err != nil {
		return result, err
	}
	fanConfig, err := config.FanConfig()
	if err != nil {
		return result, err
	}
	return networkingcommon.FanConfigToFanConfigResult(fanConfig), nil
}
438392
func ReadNetmapConfig(path string) (NetworkMap, error) {
	fd, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer fd.Close()
	return ReadNetworkMap(fd)
}
446564
func (c *EndpointConfig) PeerConfig(nameOrURL string) (*fab.PeerConfig, bool) {
	return c.tryMatchingPeerConfig(nameOrURL, true)
}
1318315
func DefaultConfig() *Config {
	return &Config{
		BOSHAddress:       "https://192.168.50.4:25555",
		Username:          "admin",
		Password:          "admin",
		HttpClient:        http.DefaultClient,
		SkipSslValidation: true,
	}
}
968747
func (c *Config) FanConfig() (network.FanConfig, error) {
	// At this point we are sure that the line is valid.
	return network.ParseFanConfig(c.asString(FanConfig))
}
623014
func ConnectConfig(addr string, config *nsq.Config) error {
	return DefaultProducer.ConnectConfig(addr, config)
}
106131
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config == nil {
		return nil, errors.New("otc: the configuration of the DNS provider is nil")
	}

	if config.DomainName == "" || config.UserName == "" || config.Password == "" || config.ProjectName == "" {
		return nil, fmt.Errorf("otc: credentials missing")
	}

	if config.TTL < minTTL {
		return nil, fmt.Errorf("otc: invalid TTL, TTL (%d) must be greater than %d", config.TTL, minTTL)
	}

	if config.IdentityEndpoint == "" {
		config.IdentityEndpoint = defaultIdentityEndpoint
	}

	return &DNSProvider{config: config}, nil
}
927652
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config == nil {
		return nil, errors.New("dyn: the configuration of the DNS provider is nil")
	}

	if config.CustomerName == "" || config.UserName == "" || config.Password == "" {
		return nil, fmt.Errorf("dyn: credentials missing")
	}

	return &DNSProvider{config: config}, nil
}
62085
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config == nil {
		return nil, errors.New("CloudXNS: the configuration of the DNS provider is nil")
	}

	client, err := internal.NewClient(config.APIKey, config.SecretKey)
	if err != nil {
		return nil, err
	}

	client.HTTPClient = config.HTTPClient

	return &DNSProvider{client: client, config: config}, nil
}