// ReadConfigSet reads all regular files in the given directory (recursively)
// and returns them as a ConfigSet with given name.
342490
func ReadConfigSet(dir, name string) (ConfigSet, error) {
	configs := map[string][]byte{}
	err := filepath.Walk(dir, func(p string, info os.FileInfo, err error) error {
		if err != nil || !info.Mode().IsRegular() {
			return err
		}
		content, err := ioutil.ReadFile(p)
		if err != nil {
			return err
		}
		relPath, err := filepath.Rel(dir, p)
		if err != nil {
			return err
		}
		configs[filepath.ToSlash(relPath)] = content
		return nil
	})
	if err != nil {
		return ConfigSet{}, errors.Annotate(err, "failed to read config files").Err()
	}
	return ConfigSet{
		Name: name,
		Data: configs,
	}, nil
}
693696
func (c *cmd) readConfig() *config.RuntimeConfig {
	b, err := config.NewBuilder(c.flagArgs)
	if err != nil {
		c.UI.Error(err.Error())
		return nil
	}
	cfg, err := b.BuildAndValidate()
	if err != nil {
		c.UI.Error(err.Error())
		return nil
	}
	for _, w := range b.Warnings {
		c.UI.Warn(w)
	}
	return &cfg
}
1063882
func (f *ConfigFlag) ReadConfigPairs(ctx *cmd.Context) (map[string]interface{}, error) {
	attrs := make(map[string]interface{})
	for k, v := range f.attrs {
		attrs[k] = v
	}
	return attrs, nil
}
1263520
func (c *Conn) ReadConfigFile(path string) error {
	c_path := C.CString(path)
	defer C.free(unsafe.Pointer(c_path))
	ret := C.rados_conf_read_file(c.cluster, c_path)
	if ret == 0 {
		return nil
	} else {
		return RadosError(int(ret))
	}
}
1237680
func ReadSettings(configFolder string) (public, protected map[string]interface{}, _ error) {
	cf, err := settingsPath(configFolder)
	if err != nil {
		return nil, nil, fmt.Errorf("canot locate settings file: %v", err)
	}
	hs, err := parseHandlerSettingsFile(cf)
	if err != nil {
		return nil, nil, fmt.Errorf("error parsing settings file: %v", err)
	}

	public = hs.PublicSettings
	if err := unmarshalProtectedSettings(configFolder, hs, &protected); err != nil {
		return nil, nil, fmt.Errorf("failed to parse protected settings: %v", err)
	}
	return public, protected, nil
}
39144
func (*DatabaseSettings) ReadSettings(c context.Context) (map[string]string, error) {
	databaseSettings, err := GetUncached(c)
	if err != nil {
		return nil, err
	}

	return map[string]string{
		"Server":   databaseSettings.Server,
		"Username": databaseSettings.Username,
		"Password": databaseSettings.Password,
		"Database": databaseSettings.Database,
	}, nil
}
57870
func filesetConfigMap(configMapName string, files *caas.FileSet) *core.ConfigMap {
	result := &core.ConfigMap{
		ObjectMeta: v1.ObjectMeta{
			Name: configMapName,
		},
		Data: map[string]string{},
	}
	for name, data := range files.Files {
		result.Data[name] = data
	}
	return result
}
957931
func (c *Client) ConfigSet(values map[string]interface{}) error {
	if c.BestAPIVersion() < 5 {
		return errors.Errorf("this controller version doesn't support updating controller config")
	}
	return errors.Trace(
		c.facade.FacadeCall("ConfigSet", params.ControllerConfigSet{Config: values}, nil),
	)
}
654115
func ParseConfigFile(path string) (*Config, error) {
	path, err := filepath.Abs(path)
	if err != nil {
		return nil, err
	}

	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	config, err := ParseConfig(f)
	if err != nil {
		return nil, err
	}

	return config, nil
}
288094
func (s *Service) GetConfig(configSet string, path string) *GetConfigCall {
	c := &GetConfigCall{s: s, urlParams_: make(gensupport.URLParams)}
	c.configSet = configSet
	c.path = path
	return c
}
454465
func ReadConfig(uri, netrc string) (string, string) {
	u, err := url.Parse(uri)
	if err != nil {
		return "", ""
	}

	file, err := os.Open(netrc)
	if err != nil {
		return "", ""
	}
	defer file.Close()

	re := fmt.Sprintf(`^.*machine %s.*$`, u.Host)
	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		s := scanner.Text()

		matched, err := regexp.MatchString(re, s)
		if err != nil {
			return "", ""
		}
		if matched {
			return parseLine(s)
		}
	}

	return "", ""
}
1204231
func genConfigFiles(dstFolder string, cfg *newConfig, skipNonProd bool, force bool) error {
	// Get base path containing templates folder and source files
	p, _ := build.Default.Import(basePackage, "", build.FindOnly)
	if p == nil || len(p.Dir) == 0 {
		return errors.New("cannot locate base path containing templates folder")
	}

	configFiles := map[string]string{
		filepath.Join(p.Dir, "templates", "config.toml.tmpl"): "config.toml",
	}

	if !skipNonProd {
		configFiles[filepath.Join(p.Dir, "templates", "watch.toml.tmpl")] = "watch.toml"
	}

	for src, fname := range configFiles {
		dst := filepath.Join(dstFolder, fname)

		var perm os.FileMode
		f, err := os.Stat(dst)
		if err == nil {
			// if force set and file exists delete file for recreation
			if force {
				perm = f.Mode()
				if err := os.Remove(dst); err != nil {
					return err
				}
			} else { // if force not set and file exists then continue to next file
				continue
			}
		} else { // if file doesnt exist default to 0644 perms
			perm = 0644
		}

		srcContents, err := ioutil.ReadFile(src)
		if err != nil {
			return err
		}

		t, err := template.New("").Funcs(templateFuncs).Parse(string(srcContents))
		if err != nil {
			return err
		}

		fileContents := &bytes.Buffer{}
		err = t.Execute(fileContents, cfg)

		if err := ioutil.WriteFile(dst, fileContents.Bytes(), perm); err != nil {
			return err
		}
	}

	return nil
}
1337905
func (i *Index) FileSet() (*FileSet, error) {
	i.mu.RLock()
	defer i.mu.RUnlock()

	// Keep track of all of the file sets returned from the partitions temporarily.
	// Keeping them alive keeps all of their underlying files alive. We release
	// whatever we have when we return.
	fss := make([]*FileSet, 0, len(i.partitions))
	defer func() {
		for _, fs := range fss {
			fs.Release()
		}
	}()

	// Collect the set of files from each partition.
	var files []File
	for _, p := range i.partitions {
		fs, err := p.FileSet()
		if err != nil {
			return nil, err
		}
		fss = append(fss, fs)
		files = append(files, fs.files...)
	}

	// Construct a new file set from the set of files. This acquires references to
	// each of the files, so we can release all of the file sets returned from the
	// partitions, which happens automatically during the defer.
	return NewFileSet(i.sfile, files)
}
524587
func (c *configCommand) parseSet(args []string) error {
	file := c.configFile.Path != ""
	if file && len(args) > 0 {
		return errors.New("cannot specify --file and key=value arguments simultaneously")
	}
	c.action = c.setConfig
	if file {
		c.useFile = true
		return nil
	}

	settings, err := keyvalues.Parse(args, true)
	if err != nil {
		return err
	}
	c.values = settings

	return nil
}
48957
func ReadFileS(filePath string) (string, error) {
	b, err := ReadFile(filePath)
	return string(b), err
}
456541
func ReadGeneral(filename string) (config map[string]interface{}, err error) {
	fileContents, err := ioutil.ReadFile(filename)

	if err == nil {
		json.Unmarshal(fileContents, &config)
	}

	return
}
178199
func readConfig(scopes []string) (*oauth2.Config, error) {
	// Read the secrets file
	data, err := ioutil.ReadFile(*clientSecretsFile)
	if err != nil {
		pwd, _ := os.Getwd()
		fullPath := filepath.Join(pwd, *clientSecretsFile)
		return nil, fmt.Errorf(missingClientSecretsMessage, fullPath)
	}

	cfg := new(Config)
	err = json.Unmarshal(data, &cfg)
	if err != nil {
		return nil, err
	}

	var redirectURI string
	if len(cfg.Web.RedirectURIs) > 0 {
		redirectURI = cfg.Web.RedirectURIs[0]
	} else if len(cfg.Installed.RedirectURIs) > 0 {
		redirectURI = cfg.Installed.RedirectURIs[0]
	} else {
		return nil, errors.New("Must specify a redirect URI in config file or when creating OAuth client")
	}

	return &oauth2.Config{
		ClientID:     cfg.Installed.ClientID,
		ClientSecret: cfg.Installed.ClientSecret,
		Scopes:       scopes,
		Endpoint:     oauth2.Endpoint{cfg.Installed.AuthURI, cfg.Installed.TokenURI},
		RedirectURL:  redirectURI,
	}, nil
}