Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EU adjustment #42

Open
wants to merge 1 commit into
base: fix/support_flexera_au_zone
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ type (
)

var (
Config ConfigViper
boolRegexp = regexp.MustCompile(`^(?i:true)$`)
hostRegexp = regexp.MustCompile(`^(?:governance-(\d+)\.(test\.)?rightscale\.com|eu-central-1\.policy-eu\.flexeraeng\.com|api\.eu-central-1\.policy-eu\.flexeraeng\.com|api\.ap-southeast-2\.policy-apac\.flexeraeng\.com)$`)
hostRegexpDep = regexp.MustCompile(`^(?:eu-central-1\.policy-eu\.flexeraeng\.com)$`)
Config ConfigViper
boolRegexp = regexp.MustCompile(`^(?i:true)$`)
hostRegexp = regexp.MustCompile(`^(?:governance-(\d+)\.(test\.)?rightscale\.com|api\.eu-central-1\.policy-eu\.flexeraeng\.com|api\.ap-southeast-2\.policy-apac\.flexeraeng\.com)$`)
)

func init() {
Expand Down Expand Up @@ -104,16 +103,17 @@ func (config *ConfigViper) GetAccount(id int, host string) (*Account, error) {
// Obtain input via STDIN then print out to config file
// Example of config file
// login:
// default_account: acct1
// accounts:
// acct1:
// id: 67972
// host: us-3.rightscale.com
// refresh_token: abc123abc123abc123abc123abc123abc123abc1
// acct2:
// id: 60073
// host: us-4.rightscale.com
// refresh_token: zxy987zxy987zxy987zxy987xzy987zxy987xzy9
//
// default_account: acct1
// accounts:
// acct1:
// id: 67972
// host: us-3.rightscale.com
// refresh_token: abc123abc123abc123abc123abc123abc123abc1
// acct2:
// id: 60073
// host: us-4.rightscale.com
// refresh_token: zxy987zxy987zxy987zxy987xzy987zxy987xzy9
func (config *ConfigViper) SetAccount(name string, setDefault bool, input io.Reader, output io.Writer) error {
// if the default account isn't set we should set it to the account we are setting
if !config.IsSet("login.default_account") {
Expand Down Expand Up @@ -259,9 +259,6 @@ func (a *Account) Validate() error {
if !hostRegexp.MatchString(a.Host) {
return fmt.Errorf("invalid host: must be of form governance-3.rightscale.com, governance-4.rightscale.com, api.eu-central-1.policy-eu.flexeraeng.com, or api.ap-southeast-2.policy-apac.flexeraeng.com")
}
if hostRegexpDep.MatchString(a.Host) {
fmt.Fprintln(os.Stderr, "Warning: API endpoint host eu-central-1.policy-eu.flexeraeng.com is deprecated and will be removed soon. Change profile API endpoint host to api.eu-central-1.policy-eu.flexeraeng.com before May 23rd")
}
return nil
}

Expand Down
Loading