Skip to content

Commit 27c6ff8

Browse files
CR-9598 (#258)
* bump * bump * error handle * e2e * empty byte array * uninstall log * log * bump * using WriteFile * fixed path * rename and fixed error log * bump * codegen * triggering e2e
1 parent 52ec590 commit 27c6ff8

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
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.238
1+
VERSION=v0.0.239
22

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

cmd/commands/git-source.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
apu "github.com/codefresh-io/cli-v2/pkg/util/aputil"
4343
ingressutil "github.com/codefresh-io/cli-v2/pkg/util/ingress"
4444
wfutil "github.com/codefresh-io/cli-v2/pkg/util/workflow"
45+
billyUtils "github.com/go-git/go-billy/v5/util"
4546
"github.com/juju/ansiterm"
4647
"github.com/spf13/cobra"
4748
corev1 "k8s.io/api/core/v1"
@@ -210,7 +211,11 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
210211

211212
if opts.CreateDemoResources {
212213
if err := createDemoResources(ctx, opts, gsRepo, gsFs); err != nil {
213-
return fmt.Errorf("failed to create git source demo resources: %w", err)
214+
return fmt.Errorf("failed to create git-source demo resources: %w", err)
215+
}
216+
} else {
217+
if err := createPlaceholderIfNeeded(ctx, opts, gsRepo, gsFs); err != nil {
218+
return fmt.Errorf("failed to create a git-source placeholder: %w", err)
214219
}
215220
}
216221

@@ -223,6 +228,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
223228
if err := appDef.CreateApp(ctx, nil, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFGitSourceType, opts.Include, ""); err != nil {
224229
return fmt.Errorf("failed to create git-source application. Err: %w", err)
225230
}
231+
226232
log.G(ctx).Infof("Successfully created git-source: '%s'", opts.GsName)
227233

228234
return nil
@@ -258,6 +264,7 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
258264
commitMsg := fmt.Sprintf("Created demo pipelines in %s Directory", opts.GsCloneOpts.Path())
259265

260266
log.G(ctx).Info("Pushing demo pipelines to the new git-source repo")
267+
261268
if err := apu.PushWithMessage(ctx, gsRepo, commitMsg); err != nil {
262269
return fmt.Errorf("failed to push demo pipelines to git-source repo: %w", err)
263270
}
@@ -266,6 +273,28 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
266273
return nil
267274
}
268275

276+
func createPlaceholderIfNeeded(ctx context.Context, opts *GitSourceCreateOptions, gsRepo git.Repository, gsFs fs.FS) error {
277+
fi, err := gsFs.ReadDir(".")
278+
if err != nil {
279+
return fmt.Errorf("failed to read files in git-source repo. Err: %w", err)
280+
}
281+
282+
if len(fi) == 0 {
283+
if err = billyUtils.WriteFile(gsFs, "DUMMY", []byte{}, 0666); err != nil {
284+
return fmt.Errorf("failed to write the git-source placeholder file. Err: %w", err)
285+
}
286+
287+
commitMsg := fmt.Sprintf("Created a placeholder file in %s Directory", opts.GsCloneOpts.Path())
288+
289+
log.G(ctx).Info("Pushing placeholder file to the default-git-source repo")
290+
if err := apu.PushWithMessage(ctx, gsRepo, commitMsg); err != nil {
291+
return fmt.Errorf("failed to push placeholder file to git-source repo: %w", err)
292+
}
293+
}
294+
295+
return nil
296+
}
297+
269298
func createCronExamplePipeline(opts *gitSourceCronExampleOptions) error {
270299
err := createDemoWorkflowTemplate(opts.gsFs)
271300
if err != nil {

cmd/commands/runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ func RunRuntimeUninstall(ctx context.Context, opts *RuntimeUninstallOptions) err
11511151
return err
11521152
}
11531153

1154-
log.G(ctx).Infof("Uninstalling runtime '%s'", opts.RuntimeName)
1154+
log.G(ctx).Infof("Uninstalling runtime '%s' - this process may take a few minutes...", opts.RuntimeName)
11551155

11561156
err = apcmd.RunRepoUninstall(ctx, &apcmd.RepoUninstallOptions{
11571157
Namespace: opts.RuntimeName,

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.238/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.239/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.238/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.239/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.1
8-
version: 0.0.238
8+
version: 0.0.239
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

0 commit comments

Comments
 (0)