Browse Source

Fix openshift context and add a comment

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
pull/2844/head
m.nabokikh 3 years ago
parent
commit
7208e28192
  1. 2
      .github/workflows/ci.yaml
  2. 4
      connector/openshift/openshift.go

2
.github/workflows/ci.yaml

@ -73,6 +73,8 @@ jobs:
run: make deps
# Ensure that generated files were committed.
# It can help us determine, that the code is in the intermediate state, which should not be tested.
# Thus, heavy jobs like creating a kind cluster and testing / linting will be skipped.
- name: Verify
run: make verify

4
connector/openshift/openshift.go

@ -82,11 +82,11 @@ func (c *Config) OpenWithHTTPClient(id string, logger log.Logger,
httpClient *http.Client,
) (conn connector.Connector, err error) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
wellKnownURL := strings.TrimSuffix(c.Issuer, "/") + wellKnownURLPath
req, err := http.NewRequest(http.MethodGet, wellKnownURL, nil)
if err != nil {
cancel()
return nil, fmt.Errorf("failed to create a request to OpenShift endpoint %w", err)
}
@ -110,14 +110,12 @@ func (c *Config) OpenWithHTTPClient(id string, logger log.Logger,
resp, err := openshiftConnector.httpClient.Do(req.WithContext(ctx))
if err != nil {
cancel()
return nil, fmt.Errorf("failed to query OpenShift endpoint %w", err)
}
defer resp.Body.Close()
if err := json.NewDecoder(resp.Body).Decode(&metadata); err != nil {
cancel()
return nil, fmt.Errorf("discovery through endpoint %s failed to decode body: %w",
wellKnownURL, err)
}

Loading…
Cancel
Save