Skip to content

fix(config): create new scw configuration if not found #4864

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gnoale
Copy link
Contributor

@Gnoale Gnoale commented Jun 25, 2025

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Release note for CHANGELOG:


fix #4661 (comment)

@Gnoale Gnoale requested a review from a team as a code owner June 25, 2025 13:26
@Gnoale Gnoale requested review from Mia-Cross and removed request for a team June 25, 2025 13:26
@@ -290,7 +290,12 @@ The only allowed attributes are access_key, secret_key, default_organization_id,
configPath := core.ExtractConfigPath(ctx)
config, err := scw.LoadConfigFromPath(configPath)
if err != nil {
return nil, err
if strings.Contains(err.Error(), "no such file or directory") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could an explicit error be defined and used with error.As here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error returned is

// ConfigFileNotFound indicates that the config file could not be found
type ConfigFileNotFoundError struct {
	path string
}

error.As cannot be used unfortunately because the path field is private if errors.As(err, &scw.ConfigFileNotFoundError{path: configPath}) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the path be exported instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scw config set crashes if there is no config.yaml present
2 participants