Skip to content

Commit

Permalink
Bump-go-sdk to v1.0.1 (#730)
Browse files Browse the repository at this point in the history
## 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 -->
  • Loading branch information
ATGardner authored Jan 14, 2024
1 parent fe69468 commit b1fa4d0
Show file tree
Hide file tree
Showing 65 changed files with 334 additions and 324 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.57
VERSION=v0.1.58

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
12 changes: 6 additions & 6 deletions cmd/commands/cluster.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@ import (

"github.com/Masterminds/semver/v3"
apkube "github.com/argoproj-labs/argocd-autopilot/pkg/kube"
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
"github.com/ghodss/yaml"
"github.com/juju/ansiterm"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -275,7 +275,7 @@ func sanitizeClusterName(name string) (string, error) {
}

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

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

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

err = appProxy.AppProxyClusters().CreateArgoRollouts(ctx, opts.server, opts.namespace)
err = appProxy.Cluster().CreateArgoRollouts(ctx, opts.server, opts.namespace)
if err != nil {
return fmt.Errorf("failed to create argo-rollouts on \"%s'\": %w", opts.server, err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/commands/cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@ package commands
import (
"testing"

platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
)

func Test_getSuffixToClusterName(t *testing.T) {
Expand Down
14 changes: 7 additions & 7 deletions cmd/commands/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,7 +41,7 @@ import (
apfs "github.com/argoproj-labs/argocd-autopilot/pkg/fs"
apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git"
aputil "github.com/argoproj-labs/argocd-autopilot/pkg/util"
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -204,7 +204,7 @@ func ensureRuntimeName(ctx context.Context, args []string, filter func(runtime *
}

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

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

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

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

func getRuntime(ctx context.Context, runtimeName string) (*platmodel.Runtime, error) {
rt, err := cfConfig.NewClient().V2().Runtime().Get(ctx, runtimeName)
rt, err := cfConfig.NewClient().GraphQL().Runtime().Get(ctx, runtimeName)
if err != nil {
return nil, fmt.Errorf("failed to get runtime from platform. error: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/completion.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions cmd/commands/component.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,7 @@ import (
"github.com/codefresh-io/cli-v2/pkg/log"
"github.com/codefresh-io/cli-v2/pkg/util"

platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
"github.com/juju/ansiterm"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -71,7 +71,7 @@ func NewComponentListCommand() *cobra.Command {
}

func RunComponentList(ctx context.Context, runtimeName string) error {
components, err := cfConfig.NewClient().V2().Component().List(ctx, runtimeName)
components, err := cfConfig.NewClient().GraphQL().Component().List(ctx, runtimeName)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/commands/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@ import (
"github.com/codefresh-io/cli-v2/pkg/store"
"github.com/codefresh-io/cli-v2/pkg/util"

platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -365,5 +365,5 @@ func runUpdateGitOpsSettings(ctx context.Context, opts *updateGitOpsSettingsOpts
}

platGitProvider := platmodel.GitProviders(apGitProvider)
return cfConfig.NewClient().V2().AccountV2().UpdateCsdpSettings(ctx, platGitProvider, opts.gitApiURL, opts.sharedConfigRepo)
return cfConfig.NewClient().GraphQL().Account().UpdateCsdpSettings(ctx, platGitProvider, opts.gitApiURL, opts.sharedConfigRepo)
}
2 changes: 1 addition & 1 deletion cmd/commands/config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
14 changes: 7 additions & 7 deletions cmd/commands/git-source.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,8 +41,8 @@ import (
sensorsv1alpha1 "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
wf "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow"
wfv1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
apmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model/app-proxy"
apmodel "github.com/codefresh-io/go-sdk/pkg/model/app-proxy"
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
billyUtils "github.com/go-git/go-billy/v5/util"
"github.com/juju/ansiterm"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -233,7 +233,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
appSpecifier := opts.GsCloneOpts.Repo
isInternal := util.StringIndexOf(store.Get().CFInternalGitSources, opts.GsName) > -1

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

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

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

err = appProxy.AppProxyGitSources().Edit(ctx, &apmodel.EditGitSourceInput{
err = appProxy.GitSource().Edit(ctx, &apmodel.EditGitSourceInput{
AppName: opts.GsName,
AppSpecifier: opts.GsCloneOpts.Repo,
Include: opts.Include,
Expand Down
10 changes: 5 additions & 5 deletions cmd/commands/helm.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@ import (
apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git"
apkube "github.com/argoproj-labs/argocd-autopilot/pkg/kube"
"github.com/codefresh-io/go-sdk/pkg/codefresh"
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
"github.com/spf13/cobra"
"helm.sh/helm/v3/pkg/chartutil"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -173,7 +173,7 @@ func validateWithRuntimeToken(ctx context.Context, opts *HelmValidateValuesOptio
return fmt.Errorf("failed creating codefresh client using runtime token: %v", err)
}

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

user, err := cfClient.V2().UsersV2().GetCurrent(ctx)
user, err := cfClient.GraphQL().User().GetCurrent(ctx)
if err != nil {
return "", "", err
}
Expand Down Expand Up @@ -321,7 +321,7 @@ func getPlatformCertFile(ctx context.Context, opts *HelmValidateValuesOptions, c
}

func checkRuntimeName(ctx context.Context, cfClient codefresh.Codefresh, runtimeName string) error {
_, err := cfClient.V2().Runtime().Get(ctx, runtimeName)
_, err := cfClient.GraphQL().Runtime().Get(ctx, runtimeName)
if err != nil {
if strings.Contains(err.Error(), "does not exist") {
log.G(ctx).Debugf("Runtime name \"%s\" is available for a new install", runtimeName)
Expand Down
4 changes: 2 additions & 2 deletions cmd/commands/helm_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Codefresh Authors.
// Copyright 2024 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -26,7 +26,7 @@ import (
gitmocks "github.com/codefresh-io/cli-v2/pkg/git/mocks"

kubemocks "github.com/argoproj-labs/argocd-autopilot/pkg/kube/mocks"
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"helm.sh/helm/v3/pkg/chartutil"
Expand Down
Loading

0 comments on commit b1fa4d0

Please sign in to comment.