func loadConfig(configFilename string) (RuntimeState, error) {

	var state RuntimeState

	if _, err := os.Stat(configFilename); os.IsNotExist(err) {
		err = fmt.Errorf("mising config file failure. Filename=%s", configFilename)
		return state, err
	}
	//ioutil.ReadFile returns a byte slice (i.e)(source)
	source, err := ioutil.ReadFile(configFilename)
	if err != nil {
		err = errors.New("cannot read config file")
		return state, err
	}

	//Unmarshall(source []byte,out interface{})decodes the source byte slice/value and puts them in out.
	err = yaml.Unmarshal(source, &state.Config)

	if err != nil {
		err = errors.New("Cannot parse config file")
		log.Printf("Source=%s", source)
		return state, err
	}

	//Load extra templates
	err = state.loadTemplates()
	if err != nil {
		return state, err
	}

	err = initDB(&state)
	if err != nil {
		return state, err
	}

	state.Userinfo = &state.Config.TargetLDAP
	state.allUsersCacheValue = make(map[string]time.Time)
	state.pendingUserActionsCache = make(map[string]pendingUserActionsCacheEntry)
	state.UserSourceinfo = &state.Config.SourceLDAP

	if len(state.Config.Base.ClusterSharedSecretFilename) > 1 {
		state.Config.Base.SharedSecrets, err = getClusterSecretsFile(state.Config.Base.ClusterSharedSecretFilename)
		if err != nil {
			return state, err
		}
	}
	//
	state.authenticator = authn.NewAuthenticator(state.Config.OpenID, "smallpoint", nil,
		state.Config.Base.SharedSecrets, nil,
		nil)

	return state, err
}
//parses initializes from the config file
parses initializes from the config file
// parses initializes from the config file
func loadConfig(configFilename string) (RuntimeState, error) {
	var state RuntimeState
	if _, err := os.Stat(configFilename); os.IsNotExist(err) {
		err = fmt.Errorf("mising config file failure. Filename=%s", configFilename)
		return state, err
	}
	source, err := ioutil.ReadFile(configFilename)
	if err != nil {
		err = errors.New("cannot read config file")
		return state, err
	}
	err = yaml.Unmarshal(source, &state.Config)
	if err != nil {
		err = errors.New("Cannot parse config file")
		log.Printf("Source=%s", source)
		return state, err
	}
	err = state.loadTemplates()
	if err != nil {
		return state, err
	}
	err = initDB(&state)
	if err != nil {
		return state, err
	}
	state.Userinfo = &state.Config.TargetLDAP
	state.allUsersCacheValue = make(map[string]time.Time)
	state.pendingUserActionsCache = make(map[string]pendingUserActionsCacheEntry)
	state.UserSourceinfo = &state.Config.SourceLDAP
	if len(state.Config.Base.ClusterSharedSecretFilename) > 1 {
		state.Config.Base.SharedSecrets, err = getClusterSecretsFile(state.Config.Base.ClusterSharedSecretFilename)
		if err != nil {
			return state, err
		}
	}
	state.authenticator = authn.NewAuthenticator(state.Config.OpenID, "smallpoint", nil,
		state.Config.Base.SharedSecrets, nil,
		nil)
	return state, err
}
func loadConfig ( configFilename string ) ( RuntimeState , error ) { var state RuntimeState if _ , err := os . Stat ( configFilename ) ; os . IsNotExist ( err ) { err = fmt . Errorf ( " " , configFilename ) return state , err } source , err := ioutil . ReadFile ( configFilename ) if err != nil { err = errors . New ( " " ) return state , err } err = yaml . Unmarshal ( source , & state . Config ) if err != nil { err = errors . New ( " " ) log . Printf ( " " , source ) return state , err } err = state . loadTemplates ( ) if err != nil { return state , err } err = initDB ( & state ) if err != nil { return state , err } state . Userinfo = & state . Config . TargetLDAP state . allUsersCacheValue = make ( map [ string ] time . Time ) state . pendingUserActionsCache = make ( map [ string ] pendingUserActionsCacheEntry ) state . UserSourceinfo = & state . Config . SourceLDAP if len ( state . Config . Base . ClusterSharedSecretFilename ) > 1 { state . Config . Base . SharedSecrets , err = getClusterSecretsFile ( state . Config . Base . ClusterSharedSecretFilename ) if err != nil { return state , err } } state . authenticator = authn . NewAuthenticator ( state . Config . OpenID , " " , nil , state . Config . Base . SharedSecrets , nil , nil ) return state , err }
parses initializes from the config file
parses initializes from the config file
//ioutil.ReadFile returns a byte slice (i.e)(source) //Unmarshall(source []byte,out interface{})decodes the source byte slice/value and puts them in out. //Load extra templates //