Skip to content

Commit

Permalink
Honor org and project env vars over data from a loaded profile
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Feb 29, 2024
1 parent 5ad9bda commit ce782f7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/pkg/profile/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ func (l *Loader) LoadProfile(name string) (*Profile, error) {
return nil, fmt.Errorf("profile path name does not match name in file. %q versus %q. Please rename file or name within the profile file to reconcile", name, c.Name)
}

// Honor environment variables around org and project over whatever
// we load from the profile file.
if orgID, ok := os.LookupEnv(envVarHCPOrganizationID); ok {
c.OrganizationID = orgID
}

if projID, ok := os.LookupEnv(envVarHCPProjectID); ok {
c.ProjectID = projID
}

c.dir = l.profilesDir
return &c, nil
}
Expand Down

0 comments on commit ce782f7

Please sign in to comment.