From acb1925fc21c06b254a248749ea8714508bcfd46 Mon Sep 17 00:00:00 2001 From: Lukasz Zajaczkowski Date: Tue, 30 Jul 2024 09:08:06 +0200 Subject: [PATCH] use new WithFiles --- go.mod | 4 +--- go.sum | 4 ++-- pkg/api/artifacts.go | 6 ++++-- pkg/api/charts.go | 4 ++-- pkg/api/client.go | 2 ++ pkg/api/repos.go | 4 ++-- pkg/api/terraform.go | 5 +++-- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 32e68bf7..ebb1ad40 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module github.com/pluralsh/plural-cli go 1.22.0 -replace github.com/pluralsh/gqlclient => /home/lukasz/GolandProjects/plural/gqlclient - require ( cloud.google.com/go/compute v1.23.3 cloud.google.com/go/resourcemanager v1.9.4 @@ -59,7 +57,7 @@ require ( github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/pluralsh/cluster-api-migration v0.2.16 github.com/pluralsh/console/go/client v1.4.0 - github.com/pluralsh/gqlclient v1.12.0 + github.com/pluralsh/gqlclient v1.12.1 github.com/pluralsh/plural-operator v0.5.5 github.com/pluralsh/polly v0.1.8 github.com/pluralsh/terraform-delinker v0.0.2 diff --git a/go.sum b/go.sum index 37722fe3..6df5f01c 100644 --- a/go.sum +++ b/go.sum @@ -1888,8 +1888,8 @@ github.com/pluralsh/console/go/client v1.4.0 h1:Mr/gyU20jrLZZ9diEznv3aU/CJ5wk13q github.com/pluralsh/console/go/client v1.4.0/go.mod h1:lpoWASYsM9keNePS3dpFiEisUHEfObIVlSL3tzpKn8k= github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E= github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s= -github.com/pluralsh/gqlclient v1.12.0 h1:txDplLmtshEpJ8ifAf6i8+V9EAIpSeHZ5TOzm9ppU9c= -github.com/pluralsh/gqlclient v1.12.0/go.mod h1:OEjN9L63x8m3A3eQBv5kVkFgiY9fp2aZ0cgOF0uII58= +github.com/pluralsh/gqlclient v1.12.1 h1:JDOkP9jjqkPdTYdpH5hooG4F8T6FDH90XfipeXJmJFY= +github.com/pluralsh/gqlclient v1.12.1/go.mod h1:OEjN9L63x8m3A3eQBv5kVkFgiY9fp2aZ0cgOF0uII58= github.com/pluralsh/helm-docs v1.11.3-0.20230914191425-6d14ebab8817 h1:J7SGxH6nJGdRoNtqdzhyr2VMpbl4asolul7xqqW++EA= github.com/pluralsh/helm-docs v1.11.3-0.20230914191425-6d14ebab8817/go.mod h1:rLqec59NO7YF57Rq9VlubQHMp7wcRTJhzpkcgs4lOG4= github.com/pluralsh/oauth v0.9.2 h1:tM9hBK4tCnJUeCOgX0ctxBBCS3hiCDPoxkJLODtedmQ= diff --git a/pkg/api/artifacts.go b/pkg/api/artifacts.go index 5e736744..493b1089 100644 --- a/pkg/api/artifacts.go +++ b/pkg/api/artifacts.go @@ -6,6 +6,7 @@ import ( "path/filepath" "github.com/pluralsh/gqlclient" + "github.com/pluralsh/gqlclient/pkg/utils" file "github.com/pluralsh/plural-cli/pkg/utils" "sigs.k8s.io/yaml" @@ -63,11 +64,12 @@ func (client *client) CreateArtifact(repo string, attrs ArtifactAttributes) (Art return artifact, err } - createArtifact, err := client.pluralClient.CreateArtifact(context.Background(), repo, attrs.Name, readme, attrs.Type, attrs.Platform, "blob", &attrs.Arch, gqlclient.WithFiles([]gqlclient.Upload{{ + client.pluralClient.Client.CustomDo = gqlclient.WithFiles([]gqlclient.Upload{{ Field: "blob", Name: attrs.Blob, R: rf, - }})) + }}, client.httpClient) + createArtifact, err := client.pluralClient.CreateArtifact(context.Background(), repo, attrs.Name, readme, attrs.Type, attrs.Platform, "blob", &attrs.Arch) if err != nil { return artifact, err } diff --git a/pkg/api/charts.go b/pkg/api/charts.go index b037f8b2..d61a4b6d 100644 --- a/pkg/api/charts.go +++ b/pkg/api/charts.go @@ -121,11 +121,11 @@ func (client *client) CreateCrd(repo string, chart string, file string) error { Name: file, Field: "blob", } - + client.pluralClient.Client.CustomDo = gqlclient.WithFiles([]gqlclient.Upload{upload}, client.httpClient) _, err = client.pluralClient.CreateCrd(context.Background(), gqlclient.ChartName{ Chart: &chart, Repo: &repo, - }, name, "blob", gqlclient.WithFiles([]gqlclient.Upload{upload})) + }, name, "blob") return err } diff --git a/pkg/api/client.go b/pkg/api/client.go index 666f87d2..1fde814a 100644 --- a/pkg/api/client.go +++ b/pkg/api/client.go @@ -105,6 +105,7 @@ type client struct { ctx context.Context pluralClient *gqlclient.Client config config.Config + httpClient *http.Client } func NewClient() Client { @@ -124,6 +125,7 @@ func FromConfig(conf *config.Config) Client { pluralClient: gqlclient.NewClient(&httpClient, conf.Url(), nil), config: *conf, ctx: context.Background(), + httpClient: &httpClient, } } diff --git a/pkg/api/repos.go b/pkg/api/repos.go index e345004e..38e281e2 100644 --- a/pkg/api/repos.go +++ b/pkg/api/repos.go @@ -143,8 +143,8 @@ func (client *client) CreateRepository(name, publisher string, input *gqlclient. input.Notes = ¬es } - - _, err = client.pluralClient.CreateRepository(context.Background(), name, publisher, *input, gqlclient.WithFiles(uploads)) + client.pluralClient.Client.CustomDo = gqlclient.WithFiles(uploads, client.httpClient) + _, err = client.pluralClient.CreateRepository(context.Background(), name, publisher, *input) return err } diff --git a/pkg/api/terraform.go b/pkg/api/terraform.go index 64c9d714..0b7aa214 100644 --- a/pkg/api/terraform.go +++ b/pkg/api/terraform.go @@ -97,13 +97,14 @@ func (client *client) UploadTerraform(dir, repoName string) (Terraform, error) { defer rf.Close() defer os.Remove(tarFile) - resp, err := client.pluralClient.UploadTerraform(client.ctx, repoName, name, "package", gqlclient.WithFiles([]gqlclient.Upload{ + client.pluralClient.Client.CustomDo = gqlclient.WithFiles([]gqlclient.Upload{ { Field: "package", Name: tarFile, R: rf, }, - })) + }, client.httpClient) + resp, err := client.pluralClient.UploadTerraform(client.ctx, repoName, name, "package") if err != nil { return tf, err }