Skip to content

Commit e967bd4

Browse files
CR-6063-gs-validation (#70)
* bump * lowercase validation * for runtime also, and moved isLower to common * isValid * removed redundant * bump * isValid s * isValid with err * removed replace * bump sdk * tidy
1 parent 0417655 commit e967bd4

File tree

8 files changed

+30
-7
lines changed

8 files changed

+30
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.72
1+
VERSION=v0.0.73
22
OUT_DIR=dist
33
YEAR?=$(shell date +"%Y")
44

cmd/commands/common.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package commands
1616

1717
import (
1818
"os"
19+
"regexp"
1920

2021
"github.com/codefresh-io/cli-v2/pkg/config"
2122
"github.com/codefresh-io/cli-v2/pkg/util"
@@ -49,3 +50,7 @@ func presetRequiredFlags(cmd *cobra.Command) {
4950
})
5051
cmd.Flags().SortFlags = false
5152
}
53+
54+
func IsValid(s string) (bool, error) {
55+
return regexp.MatchString(`^[a-z]([-a-z0-9]{0,61}[a-z0-9])?$`, s)
56+
}

cmd/commands/git-source.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ func NewGitSourceCreateCommand() *cobra.Command {
110110
log.G(ctx).Fatal("must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow")
111111
}
112112

113+
isValid, err := IsValid(args[1])
114+
if err != nil {
115+
log.G(ctx).Fatal("failed to check the validity of the git-source name")
116+
}
117+
118+
if !isValid {
119+
log.G(ctx).Fatal("git-source name cannot have any uppercase letters, must start with a character, end with character or number, and be shorter than 63 chars")
120+
}
121+
113122
if gsCloneOpts.Auth.Password == "" {
114123
gsCloneOpts.Auth.Password = insCloneOpts.Auth.Password
115124
}

cmd/commands/runtime.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ func NewRuntimeInstallCommand() *cobra.Command {
140140
log.G(ctx).Fatal("must enter runtime name")
141141
}
142142

143+
isValid, err := IsValid(args[1])
144+
if err != nil {
145+
log.G(ctx).Fatal("failed to check the validity of the runtime name")
146+
}
147+
148+
if !isValid {
149+
log.G(ctx).Fatal("runtime name cannot have any uppercase letters, must start with a character, end with character or number, and be shorter than 63 chars")
150+
}
151+
143152
if versionStr != "" {
144153
version, err = semver.NewVersion(versionStr)
145154
if err != nil {

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cf version
2020
### Linux
2121
```bash
2222
# download and extract the binary
23-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.72/cf-linux-amd64.tar.gz | tar zx
23+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.73/cf-linux-amd64.tar.gz | tar zx
2424

2525
# move the binary to your $PATH
2626
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -32,7 +32,7 @@ cf version
3232
### Mac
3333
```bash
3434
# download and extract the binary
35-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.72/cf-darwin-amd64.tar.gz | tar zx
35+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.73/cf-darwin-amd64.tar.gz | tar zx
3636

3737
# move the binary to your $PATH
3838
mv ./cf-darwin-amd64 /usr/local/bin/cf

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/argoproj/argo-events v1.4.0
1111
github.com/argoproj/argo-workflows/v3 v3.1.6
1212
github.com/briandowns/spinner v1.16.0
13-
github.com/codefresh-io/go-sdk v0.32.1
13+
github.com/codefresh-io/go-sdk v0.32.2
1414
github.com/fatih/color v1.12.0
1515
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
1616
github.com/go-git/go-billy/v5 v5.3.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
269269
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
270270
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
271271
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
272-
github.com/codefresh-io/go-sdk v0.32.1 h1:1ZkuAjcUjExaTuXGfvldpE9ldOMFowhImaqjF2drmTw=
273-
github.com/codefresh-io/go-sdk v0.32.1/go.mod h1:CcoVmTFWHGkbrSW8LyOGB/vJe5Vzr3iC/pNE2QIBTyg=
272+
github.com/codefresh-io/go-sdk v0.32.2 h1:74RlRp6cpqwU8sf4l1vG2Xiv8ohnaLQjREkW0BAUwcU=
273+
github.com/codefresh-io/go-sdk v0.32.2/go.mod h1:CcoVmTFWHGkbrSW8LyOGB/vJe5Vzr3iC/pNE2QIBTyg=
274274
github.com/colinmarc/hdfs v1.1.4-0.20180802165501-48eb8d6c34a9/go.mod h1:0DumPviB681UcSuJErAbDIOx6SIaJWj463TymfZG02I=
275275
github.com/colinmarc/hdfs v1.1.4-0.20180805212432-9746310a4d31/go.mod h1:vSBumefK4HA5uiRSwNP+3ofgrEoScpCS2MMWcWXEuQ4=
276276
github.com/container-storage-interface/spec v1.3.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=

manifests/runtime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: "{{ namespace }}"
66
spec:
77
defVersion: 1.0.0
8-
version: 0.0.72
8+
version: 0.0.73
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

0 commit comments

Comments
 (0)