Skip to content

Commit a808952

Browse files
prevent-git-src-repo-collisions (#111)
* exisitng git-src repo handling * removed redundant * bump * comment * temp change * tested: creates a separate repo * tested * bump * using store * changed Contains to HasSuffix * using Parse * without ns in demo resources * parse gsCloneOpts in Run * underscore * no replace * removed redundant
1 parent bb0a4be commit a808952

File tree

5 files changed

+30
-29
lines changed

5 files changed

+30
-29
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.106
1+
VERSION=v0.0.107
22
OUT_DIR=dist
33
YEAR?=$(shell date +"%Y")
44

cmd/commands/git-source.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ import (
4848

4949
type (
5050
GitSourceCreateOptions struct {
51-
InsCloneOpts *git.CloneOptions
52-
GsCloneOpts *git.CloneOptions
53-
GsName string
54-
RuntimeName string
55-
FullGsPath string
51+
InsCloneOpts *git.CloneOptions
52+
GsCloneOpts *git.CloneOptions
53+
GsName string
54+
RuntimeName string
55+
FullGsPath string
5656
}
5757

5858
GitSourceDeleteOptions struct {
@@ -70,9 +70,9 @@ type (
7070
}
7171

7272
gitSourceCronExampleOptions struct {
73-
runtimeName string
74-
gsCloneOpts *git.CloneOptions
75-
gsFs fs.FS
73+
runtimeName string
74+
gsCloneOpts *git.CloneOptions
75+
gsFs fs.FS
7676
}
7777
)
7878

@@ -176,9 +176,9 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
176176

177177
if len(fi) == 0 {
178178
err = createCronExamplePipeline(&gitSourceCronExampleOptions{
179-
runtimeName: opts.RuntimeName,
180-
gsCloneOpts: opts.GsCloneOpts,
181-
gsFs: gsFs,
179+
runtimeName: opts.RuntimeName,
180+
gsCloneOpts: opts.GsCloneOpts,
181+
gsFs: gsFs,
182182
})
183183
if err != nil {
184184
return fmt.Errorf("failed to create cron example pipeline. Error: %w", err)
@@ -197,6 +197,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
197197
Type: application.AppTypeDirectory,
198198
URL: opts.GsCloneOpts.Repo,
199199
}
200+
200201
if err := appDef.CreateApp(ctx, nil, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFGitSourceType); err != nil {
201202
return fmt.Errorf("failed to create git-source application. Err: %w", err)
202203
}
@@ -211,17 +212,16 @@ func createCronExamplePipeline(opts *gitSourceCronExampleOptions) error {
211212
return fmt.Errorf("failed to create demo workflowTemplate: %w", err)
212213
}
213214

214-
eventSourceFilePath := opts.gsFs.Join("resources", store.Get().CronExampleEventSourceFileName)
215-
sensorFilePath := opts.gsFs.Join("resources",store.Get().CronExampleSensorFileName)
215+
eventSourceFilePath := opts.gsFs.Join(opts.gsCloneOpts.Path(), store.Get().CronExampleEventSourceFileName)
216+
sensorFilePath := opts.gsFs.Join(opts.gsCloneOpts.Path(), store.Get().CronExampleSensorFileName)
216217

217218
eventSource := &eventsourcev1alpha1.EventSource{
218219
TypeMeta: metav1.TypeMeta{
219220
Kind: eventsourcereg.Kind,
220221
APIVersion: eventsourcereg.Group + "/v1alpha1",
221222
},
222223
ObjectMeta: metav1.ObjectMeta{
223-
Name: store.Get().CronExampleEventSourceName,
224-
Namespace: opts.runtimeName,
224+
Name: store.Get().CronExampleEventSourceName,
225225
},
226226
Spec: eventsourcev1alpha1.EventSourceSpec{
227227
EventBusName: store.Get().EventBusName,
@@ -272,8 +272,7 @@ func createCronExampleSensor(triggers []sensorsv1alpha1.Trigger, runtimeName str
272272
APIVersion: sensorreg.Group + "/v1alpha1",
273273
},
274274
ObjectMeta: metav1.ObjectMeta{
275-
Name: "cron",
276-
Namespace: runtimeName,
275+
Name: "cron",
277276
},
278277
Spec: sensorsv1alpha1.SensorSpec{
279278
EventBusName: "codefresh-eventbus",

cmd/commands/runtime.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,13 @@ func NewRuntimeInstallCommand() *cobra.Command {
139139
}
140140

141141
insCloneOpts.Parse()
142-
if gsCloneOpts.Repo == "" {
143-
host, orgRepo, _, _, _, suffix, _ := aputil.ParseGitUrl(insCloneOpts.Repo)
144-
gsCloneOpts.Repo = host + orgRepo + "_git-source" + suffix + "/resources"
145-
}
146-
147-
gsCloneOpts.Parse()
148142
},
149143
RunE: func(cmd *cobra.Command, args []string) error {
150144
var (
151145
version *semver.Version
152146
err error
153147
)
148+
154149
ctx := cmd.Context()
155150
if len(args) < 1 {
156151
log.G(ctx).Fatal("must enter runtime name")
@@ -172,8 +167,15 @@ func NewRuntimeInstallCommand() *cobra.Command {
172167
}
173168
}
174169

170+
runtimeName := args[0]
171+
if gsCloneOpts.Repo == "" {
172+
host, orgRepo, _, _, _, suffix, _ := aputil.ParseGitUrl(insCloneOpts.Repo)
173+
gsCloneOpts.Repo = host + orgRepo + "_git-source" + suffix + "/resources" + "_" + runtimeName
174+
}
175+
gsCloneOpts.Parse()
176+
175177
return RunRuntimeInstall(ctx, &RuntimeInstallOptions{
176-
RuntimeName: args[0],
178+
RuntimeName: runtimeName,
177179
IngressHost: ingressHost,
178180
Version: version,
179181
Insecure: true,

docs/releases/release_notes.md

Lines changed: 3 additions & 3 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.106/cf-linux-amd64.tar.gz | tar zx
23+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.107/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,11 +32,11 @@ 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.106/cf-darwin-amd64.tar.gz | tar zx
35+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.107/cf-darwin-amd64.tar.gz | tar zx
3636

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

4040
# check the installation
4141
cf version
42-
```
42+
```

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.106
8+
version: 0.0.107
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

0 commit comments

Comments
 (0)