MCPcopy Index your code
hub / github.com/rilldata/rill / Client

Method Client

cli/pkg/cmdutil/helper.go:173–208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

171}
172
173func (h *Helper) Client() (*client.Client, error) {
174 // The admin token and URL may have changed (e.g. if the user did a separate login or env switch).
175 // Reload the admin config from disk to get the latest values.
176 err := h.ReloadAdminConfig()
177 if err != nil {
178 return nil, err
179 }
180
181 // Compute and cache a hash of the admin config values to detect changes.
182 // If the hash has changed, we should close the existing client.
183 hash := hashStr(h.AdminToken(), h.AdminURL())
184 if h.adminClient != nil && h.adminClientHash != hash {
185 _ = h.adminClient.Close()
186 h.adminClient = nil
187 h.adminClientHash = hash
188 }
189 h.adminClientHash = hash
190
191 // Make a new client if we don't have one.
192 if h.adminClient == nil {
193 cliVersion := h.Version.Number
194 if cliVersion == "" {
195 cliVersion = "unknown"
196 }
197
198 userAgent := fmt.Sprintf("rill-cli/%v", cliVersion)
199 c, err := client.New(h.AdminURL(), h.AdminToken(), userAgent)
200 if err != nil {
201 return nil, err
202 }
203
204 h.adminClient = c
205 }
206
207 return h.adminClient, nil
208}
209
210// Telemetry returns a client for recording events.
211// Note: It should only be used for parts of the CLI that run on users' local computer because:

Callers 15

CurrentUserIDMethod · 0.95
InferProjectsMethod · 0.95
OpenRuntimeClientMethod · 0.95
GitSignatureMethod · 0.95
UploadRepoFunction · 0.45
GitConfigMethod · 0.45
PushToNewManagedRepoMethod · 0.45
PushToGithubMethod · 0.45
DeployProjectMethod · 0.45
RedeployProjectMethod · 0.45
GetCurrentUserMethod · 0.45

Calls 6

ReloadAdminConfigMethod · 0.95
AdminTokenMethod · 0.95
AdminURLMethod · 0.95
NewFunction · 0.92
hashStrFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected