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

feat: make proxy configurable #267

Merged
merged 8 commits into from
Nov 27, 2023

Conversation

typeid
Copy link
Member

@typeid typeid commented Nov 22, 2023

What type of PR is this?

cleanup

What this PR does / Why we need it?

We need the proxy to be configurable for programmatic access. Beyond that, this PR also allows passing the whole necessary configuration to create an AWSV2Config, instead of picking up config chunks through ENVs and external config files.

Needed for https://issues.redhat.com/browse/OSD-19388\

Which Jira/Github issue(s) does this PR fix?

Resolves #

Special notes for your reviewer

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR

After these changes I tested the following:
Old flow:

  • ocm backplane cloud credentials
  • ocm backplane cloud console

Non STS clusters:

  • ocm backplane cloud credentials
  • ocm backplane cloud console

New flow:

  • ocm backplane cloud credentials
  • ocm backplane cloud console

@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2023

Codecov Report

Merging #267 (b20b926) into main (5b45914) will decrease coverage by 0.72%.
Report is 2 commits behind head on main.
The diff coverage is 10.04%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #267      +/-   ##
==========================================
- Coverage   48.53%   47.82%   -0.72%     
==========================================
  Files          52       52              
  Lines        3441     3467      +26     
==========================================
- Hits         1670     1658      -12     
- Misses       1510     1548      +38     
  Partials      261      261              
Files Coverage Δ
pkg/cli/config/config.go 61.11% <100.00%> (+3.11%) ⬆️
cmd/ocm-backplane/console/console.go 42.23% <80.00%> (-0.15%) ⬇️
pkg/utils/ocmWrapper.go 0.00% <0.00%> (ø)
pkg/monitoring/monitoring.go 39.47% <40.00%> (-0.32%) ⬇️
cmd/ocm-backplane/config/set.go 15.78% <0.00%> (-0.58%) ⬇️
cmd/ocm-backplane/login/login.go 65.08% <0.00%> (-1.19%) ⬇️
cmd/ocm-backplane/config/get.go 30.00% <0.00%> (-3.34%) ⬇️
pkg/credentials/aws.go 16.66% <0.00%> (-4.39%) ⬇️
cmd/ocm-backplane/cloud/credentials.go 60.81% <0.00%> (+23.12%) ⬆️
pkg/awsutil/sts.go 53.38% <7.14%> (-2.87%) ⬇️
... and 3 more

@typeid typeid changed the title feat: make proxy configurable [WIP] feat: make proxy configurable Nov 22, 2023
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 22, 2023
cmd/ocm-backplane/cloud/common.go Show resolved Hide resolved
cmd/ocm-backplane/cloud/credentials.go Outdated Show resolved Hide resolved
cmd/ocm-backplane/cloud/common.go Outdated Show resolved Hide resolved
pkg/cli/config/config.go Outdated Show resolved Hide resolved
@typeid typeid changed the title [WIP] feat: make proxy configurable feat: make proxy configurable Nov 24, 2023
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 24, 2023
@typeid
Copy link
Member Author

typeid commented Nov 24, 2023

Removed WIP label. Tested that this works programatically and tested that I can still create console/credentials for clusters.

@typeid
Copy link
Member Author

typeid commented Nov 24, 2023

/label tide/merge-method-squash

@openshift-ci openshift-ci bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 24, 2023
if err != nil {
return aws.Credentials{}, fmt.Errorf("failed to assume role sequence: %w", err)
}
return targetCredentials, nil
}

func isIsolatedBackplaneAccess(cluster *cmv1.Cluster) (bool, error) {
func isIsolatedBackplaneAccess(cluster *cmv1.Cluster, ocmConnection *ocmsdk.Connection) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func isIsolatedBackplaneAccess(cluster *cmv1.Cluster, ocmConnection *ocmsdk.Connection) (bool, error) {
func (cfg *QueryConfig) isIsolatedBackplaneAccess(cluster *cmv1.Cluster) (bool, error) {

Any reason to not make this (and kind of all the other functions) methods off of QueryConfig? To me, that's one of the main benefits of defining a QueryConfig in the first place - you don't have to worry about passing the right arguments?

I could be convinced otherwise though, currently I'm thinking as long as the public/external helper functions are methods that's good enough for me (e.g. skip this one and refactor GetAWSV2Config to be a method).

Copy link
Member Author

@typeid typeid Nov 27, 2023

Choose a reason for hiding this comment

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

Agree that it makes sense, I was being a bit too careful with refactoring I suppose.

The following are now members of QueryConfig (and have been moved to common.go:

  • getCloudCredentials -> public
  • getCloudCredentialsFromBackplaneAPI
  • getCloudConsole -> public

I also refactored GetCloudConsole the same way GetCloudCredentials has been refactored to enable calling it from console.go, and moved some logic into the new getCloudConsoleFromBackplaneAPI to make it less confusing.

After these changes I tested the following:
Old flow:

  • ocm backplane cloud credentials
  • ocm backplane cloud console

Non STS clusters:

  • ocm backplane cloud credentials
  • ocm backplane cloud console

New flow:

  • ocm backplane cloud credentials
  • ocm backplane cloud console

Copy link
Contributor

openshift-ci bot commented Nov 27, 2023

@typeid: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link
Contributor

@mjlshen mjlshen left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks!

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 27, 2023
Copy link
Contributor

openshift-ci bot commented Nov 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjlshen, typeid

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 27, 2023
@openshift-merge-bot openshift-merge-bot bot merged commit fc75330 into openshift:main Nov 27, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants