Skip to content

Commit 0ae2db8

Browse files
authored
fix git-source edit command (#239)
* fixed git-source edit * copy username from ins to gs clone opts
1 parent 894a0ce commit 0ae2db8

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
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.220
1+
VERSION=v0.0.221
22

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

cmd/commands/git-source.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ type (
8989
ingressHost string
9090
ingressClass string
9191
}
92+
93+
dirConfig struct {
94+
application.Config
95+
Exclude string `json:"exclude"`
96+
Include string `json:"include"`
97+
}
9298
)
9399

94100
func NewGitSourceCommand() *cobra.Command {
@@ -258,7 +264,7 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
258264
}
259265

260266
func createCronExamplePipeline(opts *gitSourceCronExampleOptions) error {
261-
err := createDemoWorkflowTemplate(opts.gsFs, opts.runtimeName)
267+
err := createDemoWorkflowTemplate(opts.gsFs)
262268
if err != nil {
263269
return fmt.Errorf("failed to create demo workflowTemplate: %w", err)
264270
}
@@ -278,7 +284,7 @@ func createCronExamplePipeline(opts *gitSourceCronExampleOptions) error {
278284
return fmt.Errorf("failed to create cron example trigger. Error: %w", err)
279285
}
280286

281-
sensor, err := createCronExampleSensor(triggers, opts.runtimeName)
287+
sensor, err := createCronExampleSensor(triggers)
282288
if err != nil {
283289
return fmt.Errorf("failed to create cron example sensor. Error: %w", err)
284290
}
@@ -311,7 +317,7 @@ func createCronExampleEventSource() *eventsourcev1alpha1.EventSource {
311317
}
312318
}
313319

314-
func createCronExampleSensor(triggers []sensorsv1alpha1.Trigger, runtimeName string) (*sensorsv1alpha1.Sensor, error) {
320+
func createCronExampleSensor(triggers []sensorsv1alpha1.Trigger) (*sensorsv1alpha1.Sensor, error) {
315321
dependencies := []sensorsv1alpha1.EventDependency{
316322
{
317323
Name: store.Get().CronExampleDependencyName,
@@ -585,20 +591,20 @@ func RunGitSourceEdit(ctx context.Context, opts *GitSourceEditOptions) error {
585591
if err != nil {
586592
return fmt.Errorf("failed to clone the installation repo, attemptint to edit git-source %s. Err: %w", opts.GsName, err)
587593
}
588-
589-
c := &application.Config{}
590-
err = fs.ReadJson(fs.Join(apstore.Default.AppsDir, opts.GsName, opts.RuntimeName, "config.json"), c)
594+
c := &dirConfig{}
595+
fileName := fs.Join(apstore.Default.AppsDir, opts.GsName, opts.RuntimeName, "config_dir.json")
596+
err = fs.ReadJson(fileName, c)
591597
if err != nil {
592-
return fmt.Errorf("failed to read the config.json of git-source: %s. Err: %w", opts.GsName, err)
598+
return fmt.Errorf("failed to read the %s of git-source: %s. Err: %w", fileName, opts.GsName, err)
593599
}
594600

595601
c.SrcPath = opts.GsCloneOpts.Path()
596602
c.SrcRepoURL = opts.GsCloneOpts.URL()
597603
c.SrcTargetRevision = opts.GsCloneOpts.Revision()
598604

599-
err = fs.WriteJson(fs.Join(apstore.Default.AppsDir, opts.GsName, opts.RuntimeName, "config.json"), c)
605+
err = fs.WriteJson(fileName, c)
600606
if err != nil {
601-
return fmt.Errorf("failed to write the updated config.json of git-source: %s. Err: %w", opts.GsName, err)
607+
return fmt.Errorf("failed to write the updated %s of git-source: %s. Err: %w", fileName, opts.GsName, err)
602608
}
603609

604610
log.G(ctx).Info("Pushing updated GitSource to the installation repo")
@@ -609,7 +615,7 @@ func RunGitSourceEdit(ctx context.Context, opts *GitSourceEditOptions) error {
609615
return nil
610616
}
611617

612-
func createDemoWorkflowTemplate(gsFs fs.FS, runtimeName string) error {
618+
func createDemoWorkflowTemplate(gsFs fs.FS) error {
613619
wfTemplate := &wfv1alpha1.WorkflowTemplate{
614620
TypeMeta: metav1.TypeMeta{
615621
Kind: wf.WorkflowTemplateKind,

cmd/commands/runtime.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
307307
return err
308308
}
309309

310+
if opts.GsCloneOpts.Auth.Username == "" {
311+
opts.GsCloneOpts.Auth.Username = opts.InsCloneOpts.Auth.Username
312+
}
313+
310314
if opts.GsCloneOpts.Auth.Password == "" {
311315
opts.GsCloneOpts.Auth.Password = opts.InsCloneOpts.Auth.Password
312316
}

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.220/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.221/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.220/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.221/cf-darwin-amd64.tar.gz | tar zx
4040

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

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

0 commit comments

Comments
 (0)