// ReadLocalConfig loads up the local configuration file. Returns nil if config does not exist
504441
func ReadLocalConfig(path string) (*LocalConfig, error) {
	var err error
	var config LocalConfig
	err = configUtil.UnmarshalLocalFile(path, &config)
	if os.IsNotExist(err) {
		return nil, nil
	}
	err = ValidateLocalConfig(config)
	if err != nil {
		return nil, err
	}
	return &config, nil
}
754051
func (c *ConfigParser) ReadString(s string) (err error) {
	r := strings.NewReader(s)
	return c.Read(r)
}
967315
func (s *IndicesGetMappingService) Local(local bool) *IndicesGetMappingService {
	s.local = &local
	return s
}
64641
func readLocalBundle(ctx *cmd.Context, bundleFile string) (*charm.BundleData, string, error) {
	bundleData, err := charmrepo.ReadBundleFile(bundleFile)
	if err == nil {
		// If the bundle is defined with just a yaml file, the bundle
		// path is the directory that holds the file.
		return bundleData, filepath.Dir(ctx.AbsPath(bundleFile)), nil
	}

	// We may have been given a local bundle archive or exploded directory.
	bundle, _, pathErr := charmrepo.NewBundleAtPath(bundleFile)
	if charmrepo.IsInvalidPathError(pathErr) {
		return nil, "", pathErr
	}
	if pathErr != nil {
		// If the bundle files existed but we couldn't read them,
		// then return that error rather than trying to interpret
		// as a charm.
		if info, statErr := os.Stat(bundleFile); statErr == nil {
			if info.IsDir() {
				if _, ok := pathErr.(*charmrepo.NotFoundError); !ok {
					return nil, "", errors.Trace(pathErr)
				}
			}
		}

		logger.Debugf("cannot interpret as local bundle: %v", err)
		return nil, "", errors.NotValidf("local bundle %q", bundleFile)
	}
	bundleData = bundle.Data()

	// If we get to here bundleFile is a directory, in which case
	// we should use the absolute path as the bundFilePath, or it is
	// an archive, in which case we should pass the empty string.
	var bundleDir string
	if info, err := os.Stat(bundleFile); err == nil && info.IsDir() {
		bundleDir = ctx.AbsPath(bundleFile)
	}

	return bundleData, bundleDir, nil
}
1134132
func LoadLocalMsp(dir string, bccspConfig *factory.FactoryOpts, mspID string) error {
	if mspID == "" {
		return errors.New("the local MSP must have an ID")
	}

	conf, err := msp.GetLocalMspConfig(dir, bccspConfig, mspID)
	if err != nil {
		return err
	}

	return GetLocalMSP().Setup(conf)
}
372474
func (container *Container) readHostConfig() error {
	container.HostConfig = &containertypes.HostConfig{}
	// If the hostconfig file does not exist, do not read it.
	// (We still have to initialize container.HostConfig,
	// but that's OK, since we just did that above.)
	pth, err := container.HostConfigPath()
	if err != nil {
		return err
	}

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

	if err := json.NewDecoder(f).Decode(&container.HostConfig); err != nil {
		return err
	}

	container.InitDNSHostConfig()

	return nil
}
946090
func ReadConfig(reader io.Reader) (*FileConfig, error) {
	// read & parse YAML config:
	bytes, err := ioutil.ReadAll(reader)
	if err != nil {
		return nil, trace.Wrap(err, "failed reading Teleport configuration")
	}
	var fc FileConfig
	if err = yaml.Unmarshal(bytes, &fc); err != nil {
		return nil, trace.BadParameter("failed to parse Teleport configuration: %v", err)
	}
	// don't start Teleport with invalid ciphers, kex algorithms, or mac algorithms.
	err = fc.Check()
	if err != nil {
		return nil, trace.BadParameter("failed to parse Teleport configuration: %v", err)
	}
	// now check for unknown (misspelled) config keys:
	var validateKeys func(m YAMLMap) error
	validateKeys = func(m YAMLMap) error {
		var recursive, ok bool
		var key string
		for k, v := range m {
			if key, ok = k.(string); ok {
				if recursive, ok = validKeys[key]; !ok {
					return trace.BadParameter("unrecognized configuration key: '%v'", key)
				}
				if recursive {
					if m2, ok := v.(YAMLMap); ok {
						if err := validateKeys(m2); err != nil {
							return err
						}
					}
				}
			}
		}
		return nil
	}
	// validate configuration keys:
	var tmp YAMLMap
	if err = yaml.Unmarshal(bytes, &tmp); err != nil {
		return nil, trace.BadParameter("error parsing YAML config")
	}
	if err = validateKeys(tmp); err != nil {
		return nil, trace.Wrap(err)
	}
	return &fc, nil
}
1130101
func ReadConfig() (*Config, error) {
	cfg := &Config{}
	rawCfg := struct{ PhraseApp *Config }{PhraseApp: cfg}

	content, err := configContent()
	switch {
	case err != nil:
		return nil, err
	case content == nil:
		return cfg, nil
	default:
		return cfg, yaml.Unmarshal(content, rawCfg)
	}
}
1042836
func ReadConfig(fpath string) (*viper.Viper, error) {
	v := viper.New()
	if fpath != "" {
		if !fileExists(fpath, "") {
			return nil, fmt.Errorf("can't find file for %q", fpath)
		}
		file, err := os.Open(fpath)
		if err != nil {
			return nil, err
		}
		defer func() { _ = file.Close() }()
		ext := filepath.Ext(fpath)
		if len(ext) > 0 {
			ext = ext[1:]
		}
		v.SetConfigType(ext)
		if err := v.ReadConfig(file); err != nil {
			return nil, err
		}
		return v, nil
	}

	v.SetConfigName(".swagger")
	v.AddConfigPath(".")
	if err := v.ReadInConfig(); err != nil {
		if _, ok := err.(viper.UnsupportedConfigError); !ok && v.ConfigFileUsed() != "" {
			return nil, err
		}
	}
	return v, nil
}
301632
func (scope *EvalScope) LocalVariables(cfg LoadConfig) ([]*Variable, error) {
	vars, err := scope.Locals()
	if err != nil {
		return nil, err
	}
	vars = filterVariables(vars, func(v *Variable) bool {
		return (v.Flags & (VariableArgument | VariableReturnArgument)) == 0
	})
	cfg.MaxMapBuckets = maxMapBucketsFactor * cfg.MaxArrayValues
	loadValues(vars, cfg)
	return vars, nil
}
462111
func (s *server) readConf() error {
	confPath := path.Join(s.path, "conf")
	s.debugln("readConf.open ", confPath)

	// open conf file
	b, err := ioutil.ReadFile(confPath)

	if err != nil {
		return nil
	}

	conf := &Config{}

	if err = json.Unmarshal(b, conf); err != nil {
		return err
	}

	s.log.updateCommitIndex(conf.CommitIndex)

	return nil
}
1077657
func (s *IndicesGetSettingsService) Local(local bool) *IndicesGetSettingsService {
	s.local = &local
	return s
}
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
}
406999
func (l *Language) GetLocal(key string) interface{} {
	if l == nil {
		panic("language not set")
	}
	key = strings.ToLower(key)
	if !globalOnlySettings[key] {
		if v, ok := l.settings[key]; ok {
			return v
		}
	}
	return nil
}
494982
func (c *Configuration) UnsetLocalSection(key string) (string, error) {
	return c.gitConfigWrite("--local", "--remove-section", key)
}
1218561
func (c *Configuration) SetLocal(key, val string) (string, error) {
	return c.gitConfigWrite("--replace-all", key, val)
}
219740
func (m *Module) ReadConfig(i interface{}) error {
	m.configDefs = append(m.configDefs, reflect.TypeOf(i))
	return json.Unmarshal(m.Byte, i)
}