Skip to content
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

Insert middleware to allow org and prod id on requests #142

Merged
merged 18 commits into from Dec 20, 2022

Conversation

JolisaBrownHashiCorp
Copy link
Contributor

πŸ› οΈ Description

These code changes include added middleware to allow organization and project id collected from a user's profile to attach to client requests.

πŸ”— External Links

HCE-652 : Middleware package that injects the saved project ID/org ID into every SDK request

πŸ‘ Definition of Done

  • SDK added
  • SDK updated
  • Tests added?
  • Docs updated?

@JolisaBrownHashiCorp JolisaBrownHashiCorp requested a review from a team December 9, 2022 18:16
@@ -84,6 +100,15 @@ func New(cfg Config) (runtime *httptransport.Runtime, err error) {
transport = &roundTripperWithSourceChannel{OriginalRoundTripper: transport, SourceChannel: sourceChannel}
}

if cfg.Profile().OrganizationID != "" || cfg.Profile().ProjectID != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make sure we have validation that these are always set together. Both populated, or both empty.

ProjectID string
}

func (rt *roundTripperWithProfile) RoundTrip(req *http.Request) (*http.Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would like to see a refactor where we only overwrite the Roundtrip function once. Maybe a single struct called roundTripperWithMiddleware with sourceChannel and profile middleware functions as its fields?

@bcmdarroch bcmdarroch force-pushed the insert-middleware-package-hce-652 branch from 53f7d71 to 1ad9e50 Compare December 16, 2022 16:40
Copy link
Contributor

@bcmdarroch bcmdarroch left a comment

Choose a reason for hiding this comment

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

πŸŽ‰ πŸ™Œ

@JolisaBrownHashiCorp JolisaBrownHashiCorp merged commit 1d28ede into main Dec 20, 2022
@JolisaBrownHashiCorp JolisaBrownHashiCorp deleted the insert-middleware-package-hce-652 branch December 20, 2022 20:10
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.

None yet

3 participants