MCPcopy Create free account
hub / github.com/containers/image / newOpenshiftClient

Function newOpenshiftClient

openshift/openshift.go:32–66  ·  view source on GitHub ↗

newOpenshiftClient creates a new openshiftClient for the specified reference.

(ref openshiftReference)

Source from the content-addressed store, hash-verified

30
31// newOpenshiftClient creates a new openshiftClient for the specified reference.
32func newOpenshiftClient(ref openshiftReference) (*openshiftClient, error) {
33 // We have already done this parsing in ParseReference, but thrown away
34 // httpClient. So, parse again.
35 // (We could also rework/split restClientFor to "get base URL" to be done
36 // in ParseReference, and "get httpClient" to be done here. But until/unless
37 // we support non-default clusters, this is good enough.)
38
39 // Overall, this is modelled on openshift/origin/pkg/cmd/util/clientcmd.New().ClientConfig() and openshift/origin/pkg/client.
40 cmdConfig := defaultClientConfig()
41 logrus.Debugf("cmdConfig: %#v", cmdConfig)
42 restConfig, err := cmdConfig.ClientConfig()
43 if err != nil {
44 return nil, err
45 }
46 // REMOVED: SetOpenShiftDefaults (values are not overridable in config files, so hard-coded these defaults.)
47 logrus.Debugf("restConfig: %#v", restConfig)
48 baseURL, httpClient, err := restClientFor(restConfig)
49 if err != nil {
50 return nil, err
51 }
52 logrus.Debugf("URL: %#v", *baseURL)
53
54 if httpClient == nil {
55 httpClient = http.DefaultClient
56 }
57
58 return &openshiftClient{
59 ref: ref,
60 baseURL: baseURL,
61 httpClient: httpClient,
62 bearerToken: restConfig.BearerToken,
63 username: restConfig.Username,
64 password: restConfig.Password,
65 }, nil
66}
67
68func (c *openshiftClient) close() {
69 c.httpClient.CloseIdleConnections()

Callers 2

newImageSourceFunction · 0.85
newImageDestinationFunction · 0.85

Calls 3

defaultClientConfigFunction · 0.85
restClientForFunction · 0.85
ClientConfigMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…