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

Generate and use client to make api calls towards resource server #352

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mlguerrero12
Copy link
Contributor

  • Add missing Model property to ResourceType
  • Generate client from resource server api spec
  • Move k8s client to commons

Copy link

openshift-ci bot commented Nov 27, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from mlguerrero12. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@mlguerrero12
Copy link
Contributor Author

@pixelsoccupied @alegacy, PTAL

Copy link
Collaborator

@pixelsoccupied pixelsoccupied left a comment

Choose a reason for hiding this comment

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

good stuff! alarms + resource server connectivity incoming!

internal/service/common/clients/resources/client.gen.go Outdated Show resolved Hide resolved
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 28, 2024
Signed-off-by: Marcelo Guerrero <[email protected]>
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 29, 2024
It generates the client of the Resource Server API
and uses it to get the resourceType list

Signed-off-by: Marcelo Guerrero <[email protected]>
The k8s client can be used by different servers

Signed-off-by: Marcelo Guerrero <[email protected]>
This add nonResourceURLs permissions to get and list
/o2ims-infrastructureInventory/v1/resourceTypes endpoint

Signed-off-by: Marcelo Guerrero <[email protected]>
It includes changes due to communication with the
resource server

Signed-off-by: Marcelo Guerrero <[email protected]>
@mlguerrero12
Copy link
Contributor Author

addressed comments, PTAL again @alegacy, @pixelsoccupied

Copy link

openshift-ci bot commented Nov 29, 2024

@mlguerrero12: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/markdownlint de743ab link true /test markdownlint
ci/prow/scorecard fd59505 link true /test scorecard

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-sigs/prow repository. I understand the commands that are listed here.

Comment on lines +43 to +63
// Set up transport
tr := &http.Transport{
TLSClientConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
// #nosec G402: InsecureSkipVerify set true.
InsecureSkipVerify: utils.GetTLSSkipVerify(),
},
}

if !tr.TLSClientConfig.InsecureSkipVerify {
tr.TLSClientConfig.RootCAs = x509.NewCertPool()
data, err := os.ReadFile(utils.DefaultServiceCAFile)
if err != nil {
// Should never happen
return nil, fmt.Errorf("failed to read CA file: %w", err)
}

tr.TLSClientConfig.RootCAs.AppendCertsFromPEM(data)
}

hc := http.Client{Transport: tr}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have a utility to do this. See GetDefaultTLSConfig in utils

Copy link
Collaborator

Choose a reason for hiding this comment

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

or GetDefaultBackendTransport depending on what you need


tokenPath := utils.DefaultBackendTokenFile

// Use for local development
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that we have a way to deploy the server in-cluster should not be relying so much on these local hacks.

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.

4 participants