// GetAppConfig retrives an app's configuration from the controller.
355130
func GetAppConfig(c *deis.Client, username, app string) (api.Config, error) {
	req := api.ConfigHookRequest{User: username, App: app}
	b, err := json.Marshal(req)
	if err != nil {
		return api.Config{}, err
	}

	res, reqErr := c.Request("POST", "/v2/hooks/config/", b)
	if reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {
		return api.Config{}, reqErr
	}
	defer res.Body.Close()

	config := api.Config{}
	if err := json.NewDecoder(res.Body).Decode(&config); err != nil {
		return api.Config{}, err
	}

	return config, reqErr
}
463267
func (api *APIBase) CharmConfig(args params.ApplicationGetArgs) (params.ApplicationGetConfigResults, error) {
	if err := api.checkCanRead(); err != nil {
		return params.ApplicationGetConfigResults{}, err
	}
	results := params.ApplicationGetConfigResults{
		Results: make([]params.ConfigResult, len(args.Args)),
	}
	for i, arg := range args.Args {
		config, err := api.getCharmConfig(arg.BranchName, arg.ApplicationName)
		results.Results[i].Config = config
		results.Results[i].Error = common.ServerError(err)
	}
	return results, nil
}
695298
func GetConfig(env cmds.Environment) (*config.Config, error) {
	ctx, ok := env.(*commands.Context)
	if !ok {
		return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
	}

	return ctx.GetConfig()
}
487519
func (c *configCommand) getConfig(client applicationAPI, ctx *cmd.Context) error {
	results, err := client.Get(c.branchName, c.applicationName)
	if err != nil {
		return err
	}
	if len(c.keys) == 1 {
		logger.Infof("format %v is ignored", c.out.Name())
		key := c.keys[0]
		info, found := results.CharmConfig[key].(map[string]interface{})
		if !found && len(results.ApplicationConfig) > 0 {
			info, found = results.ApplicationConfig[key].(map[string]interface{})
		}
		if !found {
			return errors.Errorf("key %q not found in %q application config or charm settings.", key, c.applicationName)
		}
		v, ok := info["value"]
		if !ok || v == nil {
			// Note that unlike the output with a non-nil and non-empty value below, this
			// output should never have a newline.
			return nil
		}
		// TODO (anastasiamac 2018-08-29) We want to have a new line after here (fmt.Fprintln).
		// However, it will break all existing scripts and should be done as part of Juju 3.x work.
		_, err := fmt.Fprint(ctx.Stdout, v)
		return errors.Trace(err)
	}

	resultsMap := map[string]interface{}{
		"application": results.Application,
		"charm":       results.Charm,
		"settings":    results.CharmConfig,
	}
	if len(results.ApplicationConfig) > 0 {
		resultsMap["application-config"] = results.ApplicationConfig
	}

	err = c.out.Write(ctx, resultsMap)

	if featureflag.Enabled(feature.Generations) && err == nil {
		var gen string
		gen, err = c.ActiveBranch()
		if err == nil {
			_, err = ctx.Stdout.Write([]byte(fmt.Sprintf("\nchanges will be targeted to generation: %s\n", gen)))
		}
	}
	return errors.Trace(err)
}
24898
func getConfig(c context.Context) *Config {
	val, _ := c.Value(&cfgContextKey).(*Config)
	return val
}
386347
func ConfigUnset(appID string, configVars []string) error {
	c, appID, err := load(appID)

	if err != nil {
		return err
	}

	fmt.Print("Removing config... ")

	quit := progress()

	configObj := api.Config{}

	valuesMap := make(map[string]interface{})

	for _, configVar := range configVars {
		valuesMap[configVar] = nil
	}

	configObj.Values = valuesMap

	_, err = config.Set(c, appID, configObj)

	quit <- true
	<-quit

	if err != nil {
		return err
	}

	fmt.Print("done\n\n")

	return ConfigList(appID, false)
}
1370043
func (e *extractorImpl) GetConfig(branchName string, applications ...string) ([]map[string]interface{}, error) {
	return e.application.GetConfig(branchName, applications...)
}
1112383
func (gsf *Gostrufig) RetrieveConfig(target interface{}) {
	gsf.config = target
	gsf.setInitialStructValues(gsf.config, gsf.appName)
	configpath := gsf.generateNameSpacePath()
	loadstatus := CONFIGNOTFOUND
	if gsf.driver != nil {
		loadstatus = gsf.driver.Load(configpath)
	}
	if loadstatus == CONFIGFOUND {
		gsf.setStructValues(gsf.config, gsf.appName, configpath, true)
	}
}
1185715
func (c *Client) GetConfig(subject string) (Config, error) {
	return c.getConfigSubject(subject)
}
423633
func (s *server) GetConfig(c context.Context, req *empty.Empty) (*logdog.GetConfigResponse, error) {
	gcfg, err := endpoints.GetServices(c).Config(c)
	if err != nil {
		log.WithError(err).Errorf(c, "Failed to load configuration.")
		return nil, grpcutil.Internal
	}

	// Load our config service host from settings.
	settings, err := gaeconfig.FetchCachedSettings(c)
	if err != nil {
		log.WithError(err).Errorf(c, "Failed to load settings.")
		return nil, grpcutil.Internal
	}

	return &logdog.GetConfigResponse{
		ConfigServiceHost: settings.ConfigServiceHost,
		ConfigSet:         string(gcfg.ConfigSet),
		ServiceConfigPath: gcfg.ServiceConfigPath,

		// TODO(dnj): Deprecate this field once everything has switched over to
		// using host.
		ConfigServiceUrl: gcfg.ConfigServiceURL.String(),
	}, nil
}
788121
func (s *SupportImpl) GetApplicationConfig(cid string) (channelconfig.Application, bool) {
	return s.PeerSupport.GetApplicationConfig(cid)
}
51316
func (c *Config) getConfig() *oauth2.Config {
	return &oauth2.Config{
		ClientID:     c.Client.ID,
		ClientSecret: c.Client.Secret,
		RedirectURL:  c.Client.RedirectURL,
		Endpoint: oauth2.Endpoint{
			TokenURL: fmt.Sprintf("%s/users/token", c.Server),
			AuthURL:  fmt.Sprintf("%s/users/authorize", c.Server),
		},
	}
}
918398
func (i *Installation) GetAppID() int64 {
	if i == nil || i.AppID == nil {
		return 0
	}
	return *i.AppID
}
886055
func (f *Function) GetConfig() (*lambda.GetFunctionOutput, error) {
	f.Log.Debug("fetching config")
	return f.Service.GetFunction(&lambda.GetFunctionInput{
		FunctionName: &f.FunctionName,
	})
}
1141409
func (client *Client) GetApplicationEnvironment(appGUID string) (Environment, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		URIParams:   internal.Params{"app_guid": appGUID},
		RequestName: internal.GetApplicationEnvRequest,
	})
	if err != nil {
		return Environment{}, nil, err
	}

	var responseEnvVars Environment
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &responseEnvVars,
	}
	err = client.connection.Make(request, &response)
	return responseEnvVars, response.Warnings, err
}
808439
func (r *Resources) ApplicationConfig() (channelconfig.Application, bool) {
	return r.ApplicationConfigVal, r.ApplicationConfigVal != nil
}
1130619
func (g *Generation) Config() map[string]settings.ItemChanges {
	changes := make(map[string]settings.ItemChanges, len(g.doc.Config))
	for appName, appCfg := range g.doc.Config {
		appChanges := make(settings.ItemChanges, len(appCfg))
		for i, ch := range appCfg {
			appChanges[i] = ch.coreChange()
		}
		sort.Sort(appChanges)
		changes[appName] = appChanges
	}
	return changes
}