// cacheAPIInfo updates the local environment settings (.jenv file) // with the provided apiInfo, assuming we've just successfully // connected to the API server. func cacheAPIInfo(info configstore.EnvironInfo, apiInfo *api.Info) error { info.SetAPIEndpoint(configstore.APIEndpoint{ Addresses: apiInfo.Addrs, CACert: string(apiInfo.CACert), }) _, username, err := names.ParseTag(apiInfo.Tag, names.UserTagKind) if err != nil { return fmt.Errorf("invalid API user tag: %v", err) } info.SetAPICredentials(configstore.APICredentials{ User: username, Password: apiInfo.Password, }) return info.Write() }