Skip to content

feat: refactor config package#2109

Open
nrwiersma wants to merge 2 commits into
gomods:mainfrom
nrwiersma:refactor-config
Open

feat: refactor config package#2109
nrwiersma wants to merge 2 commits into
gomods:mainfrom
nrwiersma:refactor-config

Conversation

@nrwiersma
Copy link
Copy Markdown
Contributor

What is the problem I am trying to address?

The config package is inconsistent and difficult to parse. This PR attempts to refactor it to be more consistent and idiomatic.

How is the fix applied?

The general sense of the change is:

  • Config structs are grouped by purpose
  • Config structs are renamed to avoid conflicts and make meaning more apparent
  • Functions and structs are grouped more idiomatically

What GitHub issue(s) does this PR fix or close?

@nrwiersma nrwiersma self-assigned this Apr 17, 2026
@nrwiersma nrwiersma requested a review from a team as a code owner April 17, 2026 16:37
Copy link
Copy Markdown
Member

@Ullaakut Ullaakut left a comment

Choose a reason for hiding this comment

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

Nitpicks. So much insane stuff left in those packages though, no idea how much work it would be to bring everything up to standard.

Comment thread pkg/config/config_test.go
t.Errorf("Port was incorrect. Got: %s, want: %s", conf.Port, expPort)
}
}
var testFile = filepath.Join("testdata", "config.dev.toml")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why use filepath.Join for this instead of just making this a const defined as testdata/config.dev.toml ?

Comment thread pkg/config/storage.go
Comment on lines +37 to +44
// MongoStorage specifies the properties required to use MongoDB as the storage backend.
type MongoStorage struct {
URL string `envconfig:"ATHENS_MONGO_STORAGE_URL" validate:"required"`
DefaultDBName string `default:"athens" envconfig:"ATHENS_MONGO_DEFAULT_DATABASE"`
DefaultCollectionName string `default:"modules" envconfig:"ATHENS_MONGO_DEFAULT_COLLECTION"`
CertPath string `envconfig:"ATHENS_MONGO_CERT_PATH"`
InsecureConn bool `envconfig:"ATHENS_MONGO_INSECURE"`
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wouldnt it be more readable to have the defaults second so that the envconfig tags align? Is it because of a linter or smth that they are ordered they way they are now?

Comment thread pkg/config/storage.go
Comment on lines +46 to +58
// S3Storage specifies the properties required to use S3 as the storage backend.
type S3Storage struct {
Region string `envconfig:"AWS_REGION" validate:"required"`
Key string `envconfig:"AWS_ACCESS_KEY_ID"`
Secret string `envconfig:"AWS_SECRET_ACCESS_KEY"`
Token string `envconfig:"AWS_SESSION_TOKEN"`
Bucket string `envconfig:"ATHENS_S3_BUCKET_NAME" validate:"required"`
UseDefaultConfiguration bool `envconfig:"AWS_USE_DEFAULT_CONFIGURATION"`
ForcePathStyle bool `envconfig:"AWS_FORCE_PATH_STYLE"`
CredentialsEndpoint string `envconfig:"AWS_CREDENTIALS_ENDPOINT"`
AwsContainerCredentialsRelativeURI string `envconfig:"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"`
Endpoint string `envconfig:"AWS_ENDPOINT"`
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sometimes I like tagalign, here I hate it lmao

Secret: "minio123",
Bucket: test.name,
}, config.GetTimeoutDuration(300))
}, 300*time.Second)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

5 * time.Minute seems clearer to me since on a quick read this could look like 30s, but no big deal.

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.

2 participants