func fetchClients()

in cmd/root.go [300:328]


func fetchClients(ctx context.Context, basePath string, authedClient *http.Client) (*pkg.Clients, error) {
	opt := getRetryableClientOption(3, 5*time.Second, 30*time.Second, authedClient)
	computeService, err := compute.NewService(ctx, opt)
	if err != nil {
		return nil, err
	}
	containerService, err := container.NewService(ctx, opt)
	if err != nil {
		return nil, err
	}

	// Retry for up-to 5 minutes for Compute Beta API calls.
	betaOpt := getRetryableClientOption(5, 5*time.Second, 160*time.Second, authedClient)
	computeServiceBeta, err := computebeta.NewService(ctx, betaOpt)
	if err != nil {
		return nil, err
	}

	if basePath != "" {
		containerService.BasePath = basePath
	}
	return &pkg.Clients{
		Compute: &pkg.Compute{
			V1:    computeService,
			Beta: computeServiceBeta,
		},
		Container: &pkg.Container{V1: containerService},
	}, nil
}