Skip to content

How should clients select/merge profiles? #1676

Open
@busser

Description

@busser

I am currently working on a piece of software that will fetch secrets from Scaleway's Secret Manager. The program should configure its client with whatever is provided in its environment. My question is: what is the standard on building the profile used when building the client?

I can get a profile from the configuration file, if such a file exists:

func getConfigProfile() *scw.Profile {
    config, err := scw.LoadConfig()
    if err != nil {
        return &scw.Profile{}
    }
    profile, err := config.GetActiveProfile()
    if err != nil {
        return &scw.Profile{}
    }
    return profile
}

And I can merge that with the profile based on environment variables,
in the same order that the Scaleway CLI seems to do it:

profile := scw.MergeProfiles(getConfigProfile(), scw.LoadEnvProfile())

And pass that to the client:

c, err := scw.NewClient(scw.WithProfile(profile))

Easy enough, the SDK is well made ;)

From my understanding of the SDK's source code, this would default to whatever settings the user has in their configuration file and override those settings with whatever SCW_ environment variables are set. This seems to be what I am looking for, but...

  1. Have I missed something? Is there another way the user could pass configuration?
  2. Could the SDK include a DefaultProfile() *Profile function that does what I am attempting to do? I would be willing to contribute that function :)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestpriority:lowLow priority such as UX improvements and esthetics

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions