这是indexloc提供的服务,不要输入任何密码
Skip to content

Move user config and repo config to Viper #1751

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

Merged
merged 8 commits into from
Aug 25, 2022
Merged

Move user config and repo config to Viper #1751

merged 8 commits into from
Aug 25, 2022

Conversation

gsoltis
Copy link
Contributor

@gsoltis gsoltis commented Aug 23, 2022

The main goal is break up the giant Config struct into pieces that will fit into a top-level helper / command base in the final move to cobra.

  • Moves our top-level repo- and user-config file parsing to viper.
  • Applies ENV VAR overrides as appropriate
  • Does not yet handle top-level flags in the mix, since that requires top-level cobra, but that is the eventual goal
  • Pulls out auth and endpoint details for the api client into a struct. This struct is generated with values from the repo and user configs

@gsoltis gsoltis requested a review from a team as a code owner August 23, 2022 22:55
@vercel
Copy link

vercel bot commented Aug 23, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
turbo-site ✅ Ready (Inspect) Visit Preview Aug 25, 2022 at 9:40PM (UTC)

@gsoltis gsoltis marked this pull request as draft August 23, 2022 22:58
Copy link
Contributor

@mehulkar mehulkar left a comment

Choose a reason for hiding this comment

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

I had some trouble understanding the full scope of these changes and how they relate to each other (and I'm still getting comfortable with Go), but generally seems ok to me?

Couple high level questions:

  • Is viper the thing reading turbo.json or is this some other config?
  • I noticed a bunch of changes in the tests. Are we keeping track of total coverage somehow to get a summary of whether it went up or down from a PR?

@@ -40,17 +39,33 @@ type ApiClient struct {
// ErrTooManyFailures is returned from remote cache API methods after `maxRemoteFailCount` errors have occurred
var ErrTooManyFailures = errors.New("skipping HTTP Request, too many failures have occurred")

// _maxRemoteFailCount is the number of failed requests before we stop trying to upload/download
// artifacts to the remote cache
const _maxRemoteFailCount = uint64(3)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm embarrassed to admit that I just learned that "unsigned int" has nothing to do with cryptography 😬

TeamID string
TeamSlug string
APIURL string
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👏🏾 I like it

@@ -23,10 +23,9 @@ import (
type ApiClient struct {
// The api's base URL
baseUrl string
Token string
token string
Copy link
Contributor

Choose a reason for hiding this comment

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

Beginner Go question: I know uppercasing is how you export from a package, does lowercasing a struct property have any related effects in terms of public/private? I see you're using .token for both getters and setters later, so there probably isn't, but then I'm curious why it was originally uppercased, and why you changed it 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.

It has the same effect as struct and function names. .token is now only visible in the config package. All of the other usages, including the tests, are in the config package.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see. I thought it would be private to the struct, rather than private to the package. Thanks!

TeamSlug: "my-team-slug",
APIURL: ts.URL,
Token: "my-token",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

not blocking: may be worth moving to a top level constant since it doesn't change between tests.

Greg Soltis and others added 2 commits August 24, 2022 11:51
@gsoltis gsoltis added the pr: automerge Kodiak will merge these automatically after checks pass label Aug 25, 2022
@kodiakhq kodiakhq bot merged commit d4edeb7 into main Aug 25, 2022
@kodiakhq kodiakhq bot deleted the gsoltis/viper branch August 25, 2022 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants