-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: add profile config support #77
base: main
Are you sure you want to change the base?
Conversation
04bd800
to
406f0f3
Compare
Codecov ReportAttention: Patch coverage is
|
6facfe2
to
51e02bd
Compare
|
51e02bd
to
d7a990e
Compare
@coderabbitai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is allowed because it's OSS (I'm saying).
Looks like a solid foundation, with some clearing up required on the access mechanism.
internal/github/profile_test.go
Outdated
) | ||
|
||
// Test that the profile URL is valid | ||
func TestValidProfileURL(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer data tests
main.go
Outdated
github.LoadProfile(ctx, gh, cfg.Server.OrgProfileURL) | ||
|
||
// Start Goroutine to refresh the organization profile every 5 minutes | ||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when this goroutine panics or finishes unexpectedly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I believe newest changes should handle this - we want to log failures but not cascade the panic up to the main process.
@@ -59,6 +59,17 @@ func configureServerRoutes(ctx context.Context, cfg config.Config) (http.Handler | |||
return nil, fmt.Errorf("vendor cache configuration failed: %w", err) | |||
} | |||
|
|||
// Fetch the organization profile from the GitHub repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract this to a function, possibly in the github
package (better factored, easier tests).
The routine should update an instance of the profiles. The vendor
needs to take a ConfigurationStore
(or something) as a parameter so it can request the current configuration as needed.
Configuration access and updates need to be thread safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep - makes sense!
I have updated with this pattern + threadsafe ways to access the config.
bbf2516
to
b7f4c4f
Compare
6eac054
to
b7120ff
Compare
@liamstevens did you work out the coverage issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor items that we can probably do at the end of the reviews.
} | ||
|
||
func (config *ProfileConfig) HasRepository(profileName string, repo string) bool { | ||
profile, ok := config.HasProfile(profileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loves me some comma ok
idiom
var invalidProfile string | ||
|
||
// Test that the | ||
func TestURLDecomposition(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case anyone thinks about it: I was originally going to ask if a table-driven test would be worthwhile, but given it's 2 different cases with little variation, we can probably leave this as-is since there wouldn't be much value setting up that framework.
Yep, I didn't do anything to fix it, but the codecov links stopped 404ing for me. |
bb21766
to
031dc96
Compare
031dc96
to
c463276
Compare
|
||
func LoadProfile(ctx context.Context, gh Client, orgProfileURL string) (ProfileConfig, error) { | ||
// get the profile | ||
profile, err := GetProfile(ctx, gh, orgProfileURL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to beacon out to audit logs when this is updated.
This should be done through the response from GitHub - look at the hashes.
Implements #73