Skip to content

Commit

Permalink
use new WithFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
zreigz committed Jul 30, 2024
1 parent 566ed0e commit acb1925
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 4 additions & 2 deletions pkg/api/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type client struct {
ctx context.Context
pluralClient *gqlclient.Client
config config.Config
httpClient *http.Client
}

func NewClient() Client {
Expand All @@ -124,6 +125,7 @@ func FromConfig(conf *config.Config) Client {
pluralClient: gqlclient.NewClient(&httpClient, conf.Url(), nil),
config: *conf,
ctx: context.Background(),
httpClient: &httpClient,
}

}
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func (client *client) CreateRepository(name, publisher string, input *gqlclient.

input.Notes = &notes
}

_, 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
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/api/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit acb1925

Please sign in to comment.