// LoadAuth parses an AuthInfo object from a file path. It prompts user and creates file if it doesn't exist. func (a *PromptingAuthLoader) LoadAuth(path string) (*clientauth.Info, error) { var auth clientauth.Info // Prompt for user/pass and write a file if none exists. if _, err := os.Stat(path); os.IsNotExist(err) { auth = *a.Prompt() data, err := json.Marshal(auth) if err != nil { return &auth, err } err = ioutil.WriteFile(path, data, 0600) return &auth, err } authPtr, err := clientauth.LoadFromFile(path) if err != nil { return nil, err } return authPtr, nil }
// LoadAuth for defaultAuthLoader simply delegates to clientauth.LoadFromFile func (*defaultAuthLoader) LoadAuth(path string) (*clientauth.Info, error) { return clientauth.LoadFromFile(path) }