func NewClient()

in internal/output/gcs/gcs.go [81:100]


func NewClient(addr string) (gcsClient *storage.Client, ctx context.Context, cancel context.CancelFunc, err error) {
	ctx, cancel = context.WithCancel(context.Background())
	var h *url.URL
	if addr != "" {
		h, err = url.Parse(addr)
		if err != nil {
			return nil, nil, nil, err
		}
		h.Path = "storage/v1/"
		gcsClient, err = storage.NewClient(ctx, option.WithEndpoint(h.String()), option.WithoutAuthentication())
	} else {
		gcsClient, err = storage.NewClient(ctx)
	}
	if err != nil {
		cancel()
		return nil, nil, nil, fmt.Errorf("failed to create gcs client: %w", err)
	}

	return gcsClient, ctx, cancel, nil
}