Skip to content

Commit b1fa4d0

Browse files
authored
Bump-go-sdk to v1.0.1 (#730)
## What updated go-sdk dependency to `v1.0.1` ## Why new go-sdk has breaking changes, but more simpler to maintain and extend ## Notes <!-- Add any additional notes here -->
1 parent fe69468 commit b1fa4d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+334
-324
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.1.57
1+
VERSION=v0.1.58
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/cluster.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import (
3131

3232
"github.com/Masterminds/semver/v3"
3333
apkube "github.com/argoproj-labs/argocd-autopilot/pkg/kube"
34-
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
34+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
3535
"github.com/ghodss/yaml"
3636
"github.com/juju/ansiterm"
3737
"github.com/spf13/cobra"
@@ -275,7 +275,7 @@ func sanitizeClusterName(name string) (string, error) {
275275
}
276276

277277
func ensureNoClusterNameDuplicates(ctx context.Context, name string, runtimeName string) (string, error) {
278-
clusters, err := cfConfig.NewClient().V2().Cluster().List(ctx, runtimeName)
278+
clusters, err := cfConfig.NewClient().GraphQL().Cluster().List(ctx, runtimeName)
279279
if err != nil {
280280
return "", fmt.Errorf("failed to get clusters list: %w", err)
281281
}
@@ -479,7 +479,7 @@ func runClusterRemove(ctx context.Context, opts *ClusterRemoveOptions) error {
479479
return err
480480
}
481481

482-
err = appProxy.AppProxyClusters().Delete(ctx, opts.server, opts.runtimeName)
482+
err = appProxy.Cluster().Delete(ctx, opts.server, opts.runtimeName)
483483
if err != nil {
484484
return fmt.Errorf("failed to remove cluster: %w", err)
485485
}
@@ -511,7 +511,7 @@ func newClusterListCommand() *cobra.Command {
511511
}
512512

513513
func runClusterList(ctx context.Context, runtimeName string) error {
514-
clusters, err := cfConfig.NewClient().V2().Cluster().List(ctx, runtimeName)
514+
clusters, err := cfConfig.NewClient().GraphQL().Cluster().List(ctx, runtimeName)
515515
if err != nil {
516516
return fmt.Errorf("failed to list clusters: %w", err)
517517
}
@@ -619,7 +619,7 @@ func runCreateArgoRollouts(ctx context.Context, opts *ClusterCreateArgoRolloutsO
619619
return err
620620
}
621621

622-
err = appProxy.AppProxyClusters().CreateArgoRollouts(ctx, opts.server, opts.namespace)
622+
err = appProxy.Cluster().CreateArgoRollouts(ctx, opts.server, opts.namespace)
623623
if err != nil {
624624
return fmt.Errorf("failed to create argo-rollouts on \"%s'\": %w", opts.server, err)
625625
}

cmd/commands/cluster_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@ package commands
1717
import (
1818
"testing"
1919

20-
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
20+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
2121
)
2222

2323
func Test_getSuffixToClusterName(t *testing.T) {

cmd/commands/common.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ import (
4141
apfs "github.com/argoproj-labs/argocd-autopilot/pkg/fs"
4242
apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git"
4343
aputil "github.com/argoproj-labs/argocd-autopilot/pkg/util"
44-
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
44+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
4545
"github.com/manifoldco/promptui"
4646
"github.com/spf13/cobra"
4747
"github.com/spf13/pflag"
@@ -204,7 +204,7 @@ func ensureRuntimeName(ctx context.Context, args []string, filter func(runtime *
204204
}
205205

206206
func getRuntimeNameFromUserSelect(ctx context.Context, filter func(runtime *platmodel.Runtime) bool) (string, error) {
207-
runtimes, err := cfConfig.NewClient().V2().Runtime().List(ctx)
207+
runtimes, err := cfConfig.NewClient().GraphQL().Runtime().List(ctx)
208208
if err != nil {
209209
return "", err
210210
}
@@ -226,7 +226,7 @@ func getRuntimeNameFromUserSelect(ctx context.Context, filter func(runtime *plat
226226
}
227227

228228
templates := &promptui.SelectTemplates{
229-
Active: fmt.Sprintf("%s {{ .Metadata.Name | underline }}{{ if ne .InstallationType \"HELM\" }}{{ printf \" (%%s)\" .InstallationType | underline }}{{ end }}", promptui.IconSelect),
229+
Active: fmt.Sprintf("%s {{ .Metadata.Name | underline }}{{ if ne .InstallationType \"HELM\" }}{{ printf \" (%%s)\" .InstallationType | underline }}{{ end }}", promptui.IconSelect),
230230
Inactive: " {{ .Metadata.Name }}{{ if ne .InstallationType \"HELM\" }}{{ printf \" (%s)\" .InstallationType }}{{ end }}",
231231
Selected: "{{ .Metadata.Name | yellow }}",
232232
}
@@ -721,7 +721,7 @@ func isValidationError(err error) bool {
721721
}
722722

723723
func getIscRepo(ctx context.Context) (string, error) {
724-
currentUser, err := cfConfig.NewClient().V2().UsersV2().GetCurrent(ctx)
724+
currentUser, err := cfConfig.NewClient().GraphQL().User().GetCurrent(ctx)
725725
if err != nil {
726726
return "", fmt.Errorf("failed to get current user from platform: %w", err)
727727
}
@@ -734,7 +734,7 @@ func getIscRepo(ctx context.Context) (string, error) {
734734
}
735735

736736
func suggestIscRepo(ctx context.Context, suggestedSharedConfigRepo string) (string, error) {
737-
setIscRepoResponse, err := cfConfig.NewClient().V2().Runtime().SetSharedConfigRepo(ctx, suggestedSharedConfigRepo)
737+
setIscRepoResponse, err := cfConfig.NewClient().GraphQL().Runtime().SetSharedConfigRepo(ctx, suggestedSharedConfigRepo)
738738
if err != nil {
739739
return "", fmt.Errorf("failed to set shared config repo. Error: %w", err)
740740
}
@@ -769,7 +769,7 @@ func ensureRuntimeOnKubeContext(ctx context.Context, kubeconfig string, runtimeN
769769
}
770770

771771
func getRuntime(ctx context.Context, runtimeName string) (*platmodel.Runtime, error) {
772-
rt, err := cfConfig.NewClient().V2().Runtime().Get(ctx, runtimeName)
772+
rt, err := cfConfig.NewClient().GraphQL().Runtime().Get(ctx, runtimeName)
773773
if err != nil {
774774
return nil, fmt.Errorf("failed to get runtime from platform. error: %w", err)
775775
}

cmd/commands/completion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cmd/commands/component.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import (
2323
"github.com/codefresh-io/cli-v2/pkg/log"
2424
"github.com/codefresh-io/cli-v2/pkg/util"
2525

26-
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
26+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
2727
"github.com/juju/ansiterm"
2828
"github.com/spf13/cobra"
2929
)
@@ -71,7 +71,7 @@ func NewComponentListCommand() *cobra.Command {
7171
}
7272

7373
func RunComponentList(ctx context.Context, runtimeName string) error {
74-
components, err := cfConfig.NewClient().V2().Component().List(ctx, runtimeName)
74+
components, err := cfConfig.NewClient().GraphQL().Component().List(ctx, runtimeName)
7575
if err != nil {
7676
return err
7777
}

cmd/commands/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import (
2525
"github.com/codefresh-io/cli-v2/pkg/store"
2626
"github.com/codefresh-io/cli-v2/pkg/util"
2727

28-
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
28+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
2929
"github.com/spf13/cobra"
3030
)
3131

@@ -365,5 +365,5 @@ func runUpdateGitOpsSettings(ctx context.Context, opts *updateGitOpsSettingsOpts
365365
}
366366

367367
platGitProvider := platmodel.GitProviders(apGitProvider)
368-
return cfConfig.NewClient().V2().AccountV2().UpdateCsdpSettings(ctx, platGitProvider, opts.gitApiURL, opts.sharedConfigRepo)
368+
return cfConfig.NewClient().GraphQL().Account().UpdateCsdpSettings(ctx, platGitProvider, opts.gitApiURL, opts.sharedConfigRepo)
369369
}

cmd/commands/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cmd/commands/git-source.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -41,8 +41,8 @@ import (
4141
sensorsv1alpha1 "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
4242
wf "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow"
4343
wfv1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
44-
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
45-
apmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model/app-proxy"
44+
apmodel "github.com/codefresh-io/go-sdk/pkg/model/app-proxy"
45+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
4646
billyUtils "github.com/go-git/go-billy/v5/util"
4747
"github.com/juju/ansiterm"
4848
"github.com/spf13/cobra"
@@ -233,7 +233,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
233233
appSpecifier := opts.GsCloneOpts.Repo
234234
isInternal := util.StringIndexOf(store.Get().CFInternalGitSources, opts.GsName) > -1
235235

236-
err = appProxy.AppProxyGitSources().Create(ctx, &apmodel.CreateGitSourceInput{
236+
err = appProxy.GitSource().Create(ctx, &apmodel.CreateGitSourceInput{
237237
AppName: opts.GsName,
238238
AppSpecifier: appSpecifier,
239239
DestServer: store.Get().InClusterServerURL,
@@ -302,7 +302,7 @@ func RunGitSourceList(ctx context.Context, runtimeName string, includeInternal b
302302
return fmt.Errorf("there is no runtime by the name: %s", runtimeName)
303303
}
304304

305-
gitSources, err := cfConfig.NewClient().V2().GitSource().List(ctx, runtimeName)
305+
gitSources, err := cfConfig.NewClient().GraphQL().GitSource().List(ctx, runtimeName)
306306
if err != nil {
307307
return fmt.Errorf("failed to get git-sources list. Err: %w", err)
308308
}
@@ -405,7 +405,7 @@ func RunGitSourceDelete(ctx context.Context, opts *GitSourceDeleteOptions) error
405405
return err
406406
}
407407

408-
err = appProxy.AppProxyGitSources().Delete(ctx, opts.GsName)
408+
err = appProxy.GitSource().Delete(ctx, opts.GsName)
409409
if err != nil {
410410
return fmt.Errorf("failed to delete git-source: %w", err)
411411
}
@@ -483,7 +483,7 @@ func RunGitSourceEdit(ctx context.Context, opts *GitSourceEditOptions) error {
483483
return err
484484
}
485485

486-
err = appProxy.AppProxyGitSources().Edit(ctx, &apmodel.EditGitSourceInput{
486+
err = appProxy.GitSource().Edit(ctx, &apmodel.EditGitSourceInput{
487487
AppName: opts.GsName,
488488
AppSpecifier: opts.GsCloneOpts.Repo,
489489
Include: opts.Include,

cmd/commands/helm.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import (
3434
apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git"
3535
apkube "github.com/argoproj-labs/argocd-autopilot/pkg/kube"
3636
"github.com/codefresh-io/go-sdk/pkg/codefresh"
37-
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
37+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
3838
"github.com/spf13/cobra"
3939
"helm.sh/helm/v3/pkg/chartutil"
4040
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -173,7 +173,7 @@ func validateWithRuntimeToken(ctx context.Context, opts *HelmValidateValuesOptio
173173
return fmt.Errorf("failed creating codefresh client using runtime token: %v", err)
174174
}
175175

176-
_, err = cfClient.V2().Runtime().Get(ctx, runtimeName)
176+
_, err = cfClient.GraphQL().Runtime().Get(ctx, runtimeName)
177177
if err != nil {
178178
return fmt.Errorf("failed getting runtime from platform: %w", err)
179179
}
@@ -193,7 +193,7 @@ func validateWithUserToken(ctx context.Context, opts *HelmValidateValuesOptions,
193193
return "", "", fmt.Errorf("failed creating codefresh client using user token: %w", err)
194194
}
195195

196-
user, err := cfClient.V2().UsersV2().GetCurrent(ctx)
196+
user, err := cfClient.GraphQL().User().GetCurrent(ctx)
197197
if err != nil {
198198
return "", "", err
199199
}
@@ -321,7 +321,7 @@ func getPlatformCertFile(ctx context.Context, opts *HelmValidateValuesOptions, c
321321
}
322322

323323
func checkRuntimeName(ctx context.Context, cfClient codefresh.Codefresh, runtimeName string) error {
324-
_, err := cfClient.V2().Runtime().Get(ctx, runtimeName)
324+
_, err := cfClient.GraphQL().Runtime().Get(ctx, runtimeName)
325325
if err != nil {
326326
if strings.Contains(err.Error(), "does not exist") {
327327
log.G(ctx).Debugf("Runtime name \"%s\" is available for a new install", runtimeName)

cmd/commands/helm_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Codefresh Authors.
1+
// Copyright 2024 The Codefresh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import (
2626
gitmocks "github.com/codefresh-io/cli-v2/pkg/git/mocks"
2727

2828
kubemocks "github.com/argoproj-labs/argocd-autopilot/pkg/kube/mocks"
29-
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
29+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
3030
"github.com/golang/mock/gomock"
3131
"github.com/stretchr/testify/assert"
3232
"helm.sh/helm/v3/pkg/chartutil"

0 commit comments

Comments
 (0)