From 254108a7e45fa0c5ab729bd7a91f49493d861dfa Mon Sep 17 00:00:00 2001 From: mdrakos Date: Thu, 21 Nov 2024 11:25:09 -0800 Subject: [PATCH] Rename to gqlclient --- internal/{graphql => gqlclient}/error.go | 2 +- internal/{graphql => gqlclient}/graphql.go | 2 +- internal/{graphql => gqlclient}/graphql_json_test.go | 2 +- .../{graphql => gqlclient}/graphql_multipart_test.go | 2 +- .../{graphql => gqlclient}/graphql_shared_test.go | 2 +- internal/{graphql => gqlclient}/graphql_test.go | 2 +- pkg/platform/api/graphql/graphql.go | 6 +++--- pkg/platform/api/graphql/request/publish.go | 8 ++++---- pkg/platform/api/hasura_inventory/inventory.go | 6 +++--- pkg/platform/api/mediator/mediator.go | 6 +++--- pkg/platform/api/vulnerabilities/vulnerabilities.go | 6 +++--- pkg/platform/model/buildplanner/build.go | 12 ++++++------ pkg/platform/model/buildplanner/buildplanner.go | 6 +++--- pkg/platform/model/svc.go | 10 +++++----- 14 files changed, 36 insertions(+), 36 deletions(-) rename internal/{graphql => gqlclient}/error.go (95%) rename internal/{graphql => gqlclient}/graphql.go (99%) rename internal/{graphql => gqlclient}/graphql_json_test.go (99%) rename internal/{graphql => gqlclient}/graphql_multipart_test.go (99%) rename internal/{graphql => gqlclient}/graphql_shared_test.go (97%) rename internal/{graphql => gqlclient}/graphql_test.go (99%) diff --git a/internal/graphql/error.go b/internal/gqlclient/error.go similarity index 95% rename from internal/graphql/error.go rename to internal/gqlclient/error.go index b8031b24c8..f5c9e66a17 100644 --- a/internal/graphql/error.go +++ b/internal/gqlclient/error.go @@ -1,4 +1,4 @@ -package graphql +package gqlclient import "fmt" diff --git a/internal/graphql/graphql.go b/internal/gqlclient/graphql.go similarity index 99% rename from internal/graphql/graphql.go rename to internal/gqlclient/graphql.go index 283e6c0b1e..bb1003465a 100644 --- a/internal/graphql/graphql.go +++ b/internal/gqlclient/graphql.go @@ -29,7 +29,7 @@ // // httpclient := &http.Client{} // client := graphql.NewClient("https://machinebox.io/graphql", graphql.WithHTTPClient(httpclient)) -package graphql +package gqlclient import ( "bytes" diff --git a/internal/graphql/graphql_json_test.go b/internal/gqlclient/graphql_json_test.go similarity index 99% rename from internal/graphql/graphql_json_test.go rename to internal/gqlclient/graphql_json_test.go index b2fbdda289..4dce0b22c2 100644 --- a/internal/graphql/graphql_json_test.go +++ b/internal/gqlclient/graphql_json_test.go @@ -1,4 +1,4 @@ -package graphql +package gqlclient import ( "context" diff --git a/internal/graphql/graphql_multipart_test.go b/internal/gqlclient/graphql_multipart_test.go similarity index 99% rename from internal/graphql/graphql_multipart_test.go rename to internal/gqlclient/graphql_multipart_test.go index a6734748ad..bf05030ecd 100644 --- a/internal/graphql/graphql_multipart_test.go +++ b/internal/gqlclient/graphql_multipart_test.go @@ -1,4 +1,4 @@ -package graphql +package gqlclient import ( "context" diff --git a/internal/graphql/graphql_shared_test.go b/internal/gqlclient/graphql_shared_test.go similarity index 97% rename from internal/graphql/graphql_shared_test.go rename to internal/gqlclient/graphql_shared_test.go index e20d924709..da62126795 100644 --- a/internal/graphql/graphql_shared_test.go +++ b/internal/gqlclient/graphql_shared_test.go @@ -1,4 +1,4 @@ -package graphql +package gqlclient type TestRequest struct { q string diff --git a/internal/graphql/graphql_test.go b/internal/gqlclient/graphql_test.go similarity index 99% rename from internal/graphql/graphql_test.go rename to internal/gqlclient/graphql_test.go index 0bc1875361..9cde0c9abf 100644 --- a/internal/graphql/graphql_test.go +++ b/internal/gqlclient/graphql_test.go @@ -1,4 +1,4 @@ -package graphql +package gqlclient import ( "context" diff --git a/pkg/platform/api/graphql/graphql.go b/pkg/platform/api/graphql/graphql.go index 878a9d6653..f0e01183cb 100644 --- a/pkg/platform/api/graphql/graphql.go +++ b/pkg/platform/api/graphql/graphql.go @@ -1,14 +1,14 @@ package graphql import ( - "github.com/ActiveState/cli/internal/graphql" + "github.com/ActiveState/cli/internal/gqlclient" "github.com/ActiveState/cli/pkg/platform/api" "github.com/ActiveState/cli/pkg/platform/authentication" ) -func New(auth *authentication.Auth) *graphql.Client { +func New(auth *authentication.Auth) *gqlclient.Client { url := api.GetServiceURL(api.ServiceGraphQL) - c := graphql.New(url.String(), 0) + c := gqlclient.New(url.String(), 0) c.SetTokenProvider(auth) return c } diff --git a/pkg/platform/api/graphql/request/publish.go b/pkg/platform/api/graphql/request/publish.go index 966d210ce8..551bdb9e06 100644 --- a/pkg/platform/api/graphql/request/publish.go +++ b/pkg/platform/api/graphql/request/publish.go @@ -9,7 +9,7 @@ import ( "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/fileutils" - "github.com/ActiveState/cli/internal/graphql" + "github.com/ActiveState/cli/internal/gqlclient" "github.com/ActiveState/cli/internal/locale" yamlcomment "github.com/zijiren233/yaml-comment" "gopkg.in/yaml.v3" @@ -187,11 +187,11 @@ func (p *PublishInput) Close() error { return p.file.Close() } -func (p *PublishInput) Files() []graphql.File { +func (p *PublishInput) Files() []gqlclient.File { if p.file == nil { - return []graphql.File{} + return []gqlclient.File{} } - return []graphql.File{ + return []gqlclient.File{ { Field: "variables.input.file", // this needs to map to the graphql input, eg. variables.input.file Name: p.Variables.Name, diff --git a/pkg/platform/api/hasura_inventory/inventory.go b/pkg/platform/api/hasura_inventory/inventory.go index dbca50e093..b4ddd8dc71 100644 --- a/pkg/platform/api/hasura_inventory/inventory.go +++ b/pkg/platform/api/hasura_inventory/inventory.go @@ -1,13 +1,13 @@ package inventory import ( - "github.com/ActiveState/cli/internal/graphql" + "github.com/ActiveState/cli/internal/gqlclient" "github.com/ActiveState/cli/pkg/platform/api" "github.com/ActiveState/cli/pkg/platform/authentication" ) -func New(auth *authentication.Auth) *graphql.Client { - client := graphql.New(api.GetServiceURL(api.ServiceHasuraInventory).String(), 0) +func New(auth *authentication.Auth) *gqlclient.Client { + client := gqlclient.New(api.GetServiceURL(api.ServiceHasuraInventory).String(), 0) if auth != nil && auth.Authenticated() { client.SetTokenProvider(auth) diff --git a/pkg/platform/api/mediator/mediator.go b/pkg/platform/api/mediator/mediator.go index 67d744fdec..193f43a45b 100644 --- a/pkg/platform/api/mediator/mediator.go +++ b/pkg/platform/api/mediator/mediator.go @@ -1,14 +1,14 @@ package mediator import ( - "github.com/ActiveState/cli/internal/graphql" + "github.com/ActiveState/cli/internal/gqlclient" "github.com/ActiveState/cli/pkg/platform/api" "github.com/ActiveState/cli/pkg/platform/authentication" ) -func New(auth *authentication.Auth) *graphql.Client { +func New(auth *authentication.Auth) *gqlclient.Client { url := api.GetServiceURL(api.ServiceMediator) - c := graphql.New(url.String(), 0) + c := gqlclient.New(url.String(), 0) if auth != nil { c.SetTokenProvider(auth) } diff --git a/pkg/platform/api/vulnerabilities/vulnerabilities.go b/pkg/platform/api/vulnerabilities/vulnerabilities.go index 9861444cba..7e49978dc2 100644 --- a/pkg/platform/api/vulnerabilities/vulnerabilities.go +++ b/pkg/platform/api/vulnerabilities/vulnerabilities.go @@ -1,13 +1,13 @@ package vulnerabilities import ( - "github.com/ActiveState/cli/internal/graphql" + "github.com/ActiveState/cli/internal/gqlclient" "github.com/ActiveState/cli/pkg/platform/api" "github.com/ActiveState/cli/pkg/platform/authentication" ) -func New(auth *authentication.Auth) *graphql.Client { - client := graphql.New(api.GetServiceURL(api.ServiceVulnerabilities).String(), 0) +func New(auth *authentication.Auth) *gqlclient.Client { + client := gqlclient.New(api.GetServiceURL(api.ServiceVulnerabilities).String(), 0) // Most requests to this service require authentication if auth != nil && auth.Authenticated() { diff --git a/pkg/platform/model/buildplanner/build.go b/pkg/platform/model/buildplanner/build.go index a9d6c9ad3b..9abd93156d 100644 --- a/pkg/platform/model/buildplanner/build.go +++ b/pkg/platform/model/buildplanner/build.go @@ -9,7 +9,7 @@ import ( "time" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/graphql" + "github.com/ActiveState/cli/internal/gqlclient" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/internal/rtutils/ptr" @@ -49,7 +49,7 @@ func (c *Commit) BuildScript() *buildscript.BuildScript { return c.buildscript } -func (c *client) Run(req graphql.Request, resp interface{}) error { +func (c *client) Run(req gqlclient.Request, resp interface{}) error { return c.gqlClient.Run(req, resp) } @@ -152,11 +152,11 @@ func (b *BuildPlanner) fetchCommit(commitID strfmt.UUID, owner, project string, // "data": null // } func processBuildPlannerError(bpErr error, fallbackMessage string) error { - graphqlErr := &graphql.GraphErr{} - if errors.As(bpErr, graphqlErr) { - code, ok := graphqlErr.Extensions[codeExtensionKey].(string) + gqlclientErr := &gqlclient.GraphErr{} + if errors.As(bpErr, gqlclientErr) { + code, ok := gqlclientErr.Extensions[codeExtensionKey].(string) if ok && code == clientDeprecationErrorKey { - return &response.BuildPlannerError{Err: locale.NewExternalError("err_buildplanner_deprecated", "Encountered deprecation error: {{.V0}}", graphqlErr.Message)} + return &response.BuildPlannerError{Err: locale.NewExternalError("err_buildplanner_deprecated", "Encountered deprecation error: {{.V0}}", gqlclientErr.Message)} } } if locale.IsInputError(bpErr) { diff --git a/pkg/platform/model/buildplanner/buildplanner.go b/pkg/platform/model/buildplanner/buildplanner.go index 04533bbe6a..6233807447 100644 --- a/pkg/platform/model/buildplanner/buildplanner.go +++ b/pkg/platform/model/buildplanner/buildplanner.go @@ -3,7 +3,7 @@ package buildplanner import ( "time" - "github.com/ActiveState/cli/internal/graphql" + "github.com/ActiveState/cli/internal/gqlclient" "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/pkg/platform/api" "github.com/ActiveState/cli/pkg/platform/authentication" @@ -12,7 +12,7 @@ import ( const clientDeprecationErrorKey = "CLIENT_DEPRECATION_ERROR" type client struct { - gqlClient *graphql.Client + gqlClient *gqlclient.Client } type BuildPlanner struct { @@ -40,7 +40,7 @@ func NewBuildPlannerModel(auth *authentication.Auth, cache cacher) *BuildPlanner bpURL := api.GetServiceURL(api.ServiceBuildPlanner).String() logging.Debug("Using build planner at: %s", bpURL) - gqlClient := graphql.NewWithOpts(bpURL, 0, graphql.WithHTTPClient(api.NewHTTPClient())) + gqlClient := gqlclient.NewWithOpts(bpURL, 0, gqlclient.WithHTTPClient(api.NewHTTPClient())) if auth != nil && auth.Authenticated() { gqlClient.SetTokenProvider(auth) diff --git a/pkg/platform/model/svc.go b/pkg/platform/model/svc.go index 1fde4a4576..c0ed10b850 100644 --- a/pkg/platform/model/svc.go +++ b/pkg/platform/model/svc.go @@ -10,8 +10,8 @@ import ( "github.com/ActiveState/cli/internal/condition" "github.com/ActiveState/cli/internal/errs" + "github.com/ActiveState/cli/internal/gqlclient" "github.com/ActiveState/cli/internal/graph" - "github.com/ActiveState/cli/internal/graphql" "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/internal/profile" "github.com/ActiveState/cli/internal/rtutils/ptr" @@ -22,7 +22,7 @@ import ( var SvcTimeoutMinimal = time.Millisecond * 500 type SvcModel struct { - client *graphql.Client + client *gqlclient.Client } // NewSvcModel returns a model for all client connections to a State Svc. This function returns an error if the State service is not yet ready to communicate. @@ -30,7 +30,7 @@ func NewSvcModel(port string) *SvcModel { localURL := "http://127.0.0.1" + port + "/query" return &SvcModel{ - client: graphql.NewWithOpts(localURL, 0, graphql.WithHTTPClient(&http.Client{})), + client: gqlclient.NewWithOpts(localURL, 0, gqlclient.WithHTTPClient(&http.Client{})), } } @@ -39,12 +39,12 @@ func (m *SvcModel) EnableDebugLog() { m.client.EnableDebugLog() } -func (m *SvcModel) request(ctx context.Context, request graphql.Request, resp interface{}) error { +func (m *SvcModel) request(ctx context.Context, request gqlclient.Request, resp interface{}) error { defer profile.Measure("SvcModel:request", time.Now()) err := m.client.RunWithContext(ctx, request, resp) if err != nil { - reqError := &graphql.RequestError{} + reqError := &gqlclient.RequestError{} if errors.As(err, &reqError) && (!condition.BuiltViaCI() || condition.InTest()) { vars, err := request.Vars() if err != nil {