From ce782f7774f716a0e4d4161a1d36b60370f1bb26 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Thu, 29 Feb 2024 11:18:53 -0800 Subject: [PATCH] Honor org and project env vars over data from a loaded profile --- internal/pkg/profile/loader.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/pkg/profile/loader.go b/internal/pkg/profile/loader.go index 55a664e0..f08ae0b6 100644 --- a/internal/pkg/profile/loader.go +++ b/internal/pkg/profile/loader.go @@ -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 }