Skip to content

Commit a33091e

Browse files
authored
CR-16263-check-values (#688)
* updated to version `0.1.43`
1 parent a983bd4 commit a33091e

29 files changed

+2086
-623
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.42
1+
VERSION=v0.1.43
22

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

cmd/commands/cluster.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/codefresh-io/cli-v2/pkg/util"
2929
kubeutil "github.com/codefresh-io/cli-v2/pkg/util/kube"
3030
kustutil "github.com/codefresh-io/cli-v2/pkg/util/kust"
31-
"github.com/codefresh-io/go-sdk/pkg/codefresh/model"
31+
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
3232
"github.com/ghodss/yaml"
3333

3434
"github.com/Masterminds/semver/v3"
@@ -185,7 +185,7 @@ func runClusterAdd(ctx context.Context, opts *ClusterAddOptions) error {
185185

186186
csdpToken := cfConfig.GetCurrentContext().Token
187187
addClusterRef := version.String()
188-
if runtime.InstallationType == model.InstallationTypeHelm {
188+
if runtime.InstallationType == platmodel.InstallationTypeHelm {
189189
addClusterRef = "stable"
190190
}
191191

@@ -288,7 +288,7 @@ func ensureNoClusterNameDuplicates(ctx context.Context, name string, runtimeName
288288
return name, nil
289289
}
290290

291-
func getSuffixToClusterName(clusters []model.Cluster, name string, tempName string, counter int) int {
291+
func getSuffixToClusterName(clusters []platmodel.Cluster, name string, tempName string, counter int) int {
292292
for _, cluster := range clusters {
293293
if cluster.Metadata.Name == tempName {
294294
counter++

cmd/commands/cluster_test.go

Lines changed: 31 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package commands
1717
import (
1818
"testing"
1919

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

2323
func Test_getSuffixToClusterName(t *testing.T) {
@@ -29,14 +29,14 @@ func Test_getSuffixToClusterName(t *testing.T) {
2929
cluster2.Metadata.Name = "test-cluster-1"
3030
cluster3.Metadata.Name = "test-cluster-2"
3131

32-
clusters := []model.Cluster{
32+
clusters := []platmodel.Cluster{
3333
cluster1,
3434
cluster2,
3535
cluster3,
3636
}
3737

3838
type args struct {
39-
clusters []model.Cluster
39+
clusters []platmodel.Cluster
4040
name string
4141
tempName string
4242
counter int
@@ -67,43 +67,25 @@ func Test_getSuffixToClusterName(t *testing.T) {
6767
}
6868

6969
func Test_sanitizeClusterName(t *testing.T) {
70-
type args struct {
71-
name string
72-
}
73-
tests := []struct {
70+
tests := map[string]struct {
7471
name string
75-
args args
7672
want string
7773
wantErr bool
7874
}{
79-
{
80-
name: "should return sanitized string",
81-
args: args{
82-
name: "^-.Test!@-:cluster&*`;')test.cluster(-12_3=+::±§.",
83-
},
84-
want: "test----cluster------test-cluster--12-3",
85-
wantErr: false,
86-
},
87-
{
88-
name: "should return sanitized string",
89-
args: args{
90-
name: "^-.123test!@-:cluster&*`;')test.cluster(-12_3=+::±§.",
91-
},
75+
"should return sanitized string": {
76+
name: "^-.123test!@-:cluster&*`;')test.cluster(-12_3=+::±§.",
9277
want: "test----cluster------test-cluster--12-3",
9378
wantErr: false,
9479
},
95-
{
96-
name: "should return error of sanitization failed",
97-
args: args{
98-
name: "12345",
99-
},
80+
"should return error of sanitization failed": {
81+
name: "12345",
10082
want: "",
10183
wantErr: true,
10284
},
10385
}
104-
for _, tt := range tests {
105-
t.Run(tt.name, func(t *testing.T) {
106-
got, err := sanitizeClusterName(tt.args.name)
86+
for name, tt := range tests {
87+
t.Run(name, func(t *testing.T) {
88+
got, err := sanitizeClusterName(tt.name)
10789

10890
if (err != nil) != tt.wantErr {
10991
t.Errorf("sanitizeClusterName() error = %v, wantErr %v", err, tt.wantErr)
@@ -116,63 +98,44 @@ func Test_sanitizeClusterName(t *testing.T) {
11698
}
11799

118100
func Test_validateClusterName(t *testing.T) {
119-
type args struct {
120-
name string
121-
}
122-
tests := []struct {
101+
tests := map[string]struct {
123102
name string
124-
args args
125103
wantErr bool
126104
}{
127-
{
128-
name: "name should be valid",
129-
args: args{
130-
name: "test-cluster-123",
131-
},
105+
"name should be valid": {
106+
name: "test-cluster-123",
132107
wantErr: false,
133108
},
134-
{
135-
name: "name should not be valid (contains uppercase)",
136-
args: args{
137-
name: "Test-cluster",
138-
},
109+
"name should not be valid (contains uppercase)": {
110+
name: "Test-cluster",
139111
wantErr: true,
140112
},
141-
{
142-
name: "name should not be valid (contains invalid chars)",
143-
args: args{
144-
name: "test-cluster:test/cluster.123#",
145-
},
113+
"name should not be valid (contains invalid chars)": {
114+
name: "test-cluster:test/cluster.123#",
146115
wantErr: true,
147116
},
148-
{
149-
name: "name should not be valid (begins with numeric char)",
150-
args: args{
151-
name: "2test-cluster",
152-
},
117+
"name should not be valid (begins with numeric char)": {
118+
name: "2test-cluster",
153119
wantErr: true,
154120
},
155-
{
156-
name: "name should not be valid (too long)",
157-
args: args{
158-
name: "this-cluster-name-is-too-long-1-this-cluster-name-is-too-long-1-this-cluster-name-is-too-long-1-123",
159-
},
121+
"name should not be valid (too long)": {
122+
name: "this-cluster-name-is-too-long-1-this-cluster-name-is-too-long-1-this-cluster-name-is-too-long-1-123",
160123
wantErr: true,
161124
},
162125
}
163-
for _, tt := range tests {
164-
t.Run(tt.name, func(t *testing.T) {
165-
if err := validateClusterName(tt.args.name); (err != nil) != tt.wantErr {
126+
for name, tt := range tests {
127+
t.Run(name, func(t *testing.T) {
128+
if err := validateClusterName(tt.name); (err != nil) != tt.wantErr {
166129
t.Errorf("validateClusterName() error = %v, wantErr %v", err, tt.wantErr)
167130
}
168131
})
169132
}
170133
}
171134

172-
func getEmptyClusterEntity() model.Cluster {
135+
func getEmptyClusterEntity() platmodel.Cluster {
173136
empty := ""
174-
return model.Cluster{
175-
Metadata: &model.ObjectMeta{
137+
return platmodel.Cluster{
138+
Metadata: &platmodel.ObjectMeta{
176139
Group: "",
177140
Version: "",
178141
Kind: "",
@@ -188,9 +151,9 @@ func getEmptyClusterEntity() model.Cluster {
188151
Created: &empty,
189152
UID: &empty,
190153
},
191-
Errors: []model.Error{},
192-
ReferencedBy: []model.BaseEntity{},
193-
References: []model.BaseEntity{},
154+
Errors: []platmodel.Error{},
155+
ReferencedBy: []platmodel.BaseEntity{},
156+
References: []platmodel.BaseEntity{},
194157
Server: "",
195158
Namespaces: []string{},
196159
}

cmd/commands/common.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ import (
3535
"github.com/codefresh-io/cli-v2/pkg/store"
3636
"github.com/codefresh-io/cli-v2/pkg/util"
3737
apu "github.com/codefresh-io/cli-v2/pkg/util/aputil"
38-
routingutil "github.com/codefresh-io/cli-v2/pkg/util/routing"
3938
"github.com/codefresh-io/cli-v2/pkg/util/kube"
39+
routingutil "github.com/codefresh-io/cli-v2/pkg/util/routing"
4040

4141
"github.com/argoproj-labs/argocd-autopilot/pkg/fs"
4242
"github.com/argoproj-labs/argocd-autopilot/pkg/git"
@@ -57,7 +57,7 @@ var (
5757
//go:embed assets/workflows-route-patch.json
5858
workflowsRoutePatch []byte
5959

60-
cfConfig *config.Config
60+
cfConfig config.Config
6161

6262
GREEN = "\033[32m"
6363
RED = "\033[31m"
@@ -299,11 +299,13 @@ func ensureGitRuntimeToken(cmd *cobra.Command, gitProvider cfgit.Provider, clone
299299
} else {
300300
err = gitProvider.VerifyRuntimeToken(ctx, cloneOpts.Auth)
301301
}
302+
302303
if err != nil {
303304
// in case when we get invalid value from env variable TOKEN we clean
304305
cloneOpts.Auth.Password = ""
305306
return fmt.Errorf(errMessage, err)
306307
}
308+
307309
if cloneOpts.Auth.Username == "" && gitProvider.Type() == cfgit.BITBUCKET {
308310
return fmt.Errorf("must provide a git user using --git-user for bitbucket cloud")
309311
}
@@ -318,7 +320,7 @@ func ensureGitRuntimeToken(cmd *cobra.Command, gitProvider cfgit.Provider, clone
318320
func ensureGitUserToken(ctx context.Context, opts *RuntimeInstallOptions) error {
319321
if opts.GitIntegrationRegistrationOpts.Token == "" {
320322
opts.GitIntegrationRegistrationOpts.Token = opts.InsCloneOpts.Auth.Password
321-
currentUser, err := cfConfig.GetCurrentContext().GetUser(ctx)
323+
currentUser, err := cfConfig.GetUser(ctx)
322324
if err != nil {
323325
return fmt.Errorf("failed to get current user from platform: %w", err)
324326
}
@@ -441,7 +443,7 @@ func ensureAccessMode(ctx context.Context, opts *RuntimeInstallOptions) error {
441443
handleCliStep(reporter.InstallStepPreCheckEnsureIngressClass, "-skipped (ingressless)-", nil, true, false)
442444
handleCliStep(reporter.InstallStepPreCheckEnsureIngressHost, "-skipped (ingressless)-", nil, true, false)
443445
opts.featuresToInstall = append(opts.featuresToInstall, runtime.InstallFeatureIngressless)
444-
accountId, err := cfConfig.GetCurrentContext().GetAccountId(ctx)
446+
accountId, err := cfConfig.GetAccountId(ctx)
445447
if err != nil {
446448
return fmt.Errorf("failed creating ingressHost for tunnel: %w", err)
447449
}

cmd/commands/component.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
"github.com/codefresh-io/go-sdk/pkg/codefresh/model"
26+
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
2727
"github.com/juju/ansiterm"
2828
"github.com/spf13/cobra"
2929
)
@@ -90,7 +90,7 @@ func RunComponentList(ctx context.Context, runtimeName string) error {
9090
return tb.Flush()
9191
}
9292

93-
func printComponents(w io.Writer, components []model.Component) error {
93+
func printComponents(w io.Writer, components []platmodel.Component) error {
9494
_, err := fmt.Fprintln(w, "NAME\tHEALTH STATUS\tSYNC STATUS\tVERSION")
9595
if err != nil {
9696
return err
@@ -105,7 +105,7 @@ func printComponents(w io.Writer, components []model.Component) error {
105105
return nil
106106
}
107107

108-
func printComponent(w io.Writer, c model.Component) error {
108+
func printComponent(w io.Writer, c platmodel.Component) error {
109109
name := c.Metadata.Name
110110
healthStatus := "N/A"
111111
syncStatus := "N/A"

0 commit comments

Comments
 (0)