MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / NewClientFactory

Function NewClientFactory

pkg/apiclient/client_factory.go:78–109  ·  view source on GitHub ↗
(httpClient *http.Client, host string, credentials octopusApiClient.ICredential, spaceNameOrID string, ask question.AskProvider)

Source from the content-addressed store, hash-verified

76}
77
78func NewClientFactory(httpClient *http.Client, host string, credentials octopusApiClient.ICredential, spaceNameOrID string, ask question.AskProvider) (ClientFactory, error) {
79 // httpClient is allowed to be nil; it is passed through to the go-octopusdeploy library which falls back to a default httpClient
80 if host == "" {
81 return nil, cliErrors.NewArgumentNullOrEmptyError("host")
82 }
83
84 if credentials == nil {
85 return nil, cliErrors.NewArgumentNullOrEmptyError("credentials")
86 }
87
88 // space is allowed to be blank, we will prompt for a space in interactive mode, or error if not
89 if ask == nil {
90 return nil, cliErrors.NewArgumentNullOrEmptyError("ask")
91 }
92
93 hostUrl, err := url.Parse(host)
94 if err != nil {
95 return nil, err
96 }
97
98 clientImpl := &Client{
99 HttpClient: httpClient,
100 SystemClient: nil,
101 SpaceScopedClient: nil,
102 ApiUrl: hostUrl,
103 Credentials: credentials,
104 SpaceNameOrID: spaceNameOrID,
105 ActiveSpace: nil,
106 Ask: ask,
107 }
108 return clientImpl, nil
109}
110
111// NewClientFactoryFromConfig Creates a new Client wrapper structure by reading the viper config.
112// specifies nil for the HTTP Client, so this is not for unit tests; use NewClientFactory(... instead)

Calls

no outgoing calls