Skip to content

Commit c442b03

Browse files
wip (#60)
1 parent 95e1b94 commit c442b03

File tree

9 files changed

+160
-103
lines changed

9 files changed

+160
-103
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
VERSION=v0.0.113
1+
VERSION=v0.0.114
2+
23
OUT_DIR=dist
34
YEAR?=$(shell date +"%Y")
45

cmd/commands/git-source.go

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ import (
5252

5353
type (
5454
GitSourceCreateOptions struct {
55-
InsCloneOpts *git.CloneOptions
56-
GsCloneOpts *git.CloneOptions
57-
GsName string
58-
RuntimeName string
59-
FullGsPath string
55+
InsCloneOpts *git.CloneOptions
56+
GsCloneOpts *git.CloneOptions
57+
GsName string
58+
RuntimeName string
59+
FullGsPath string
60+
CreateDemoWorkflowTemplate bool
61+
Exclude string
62+
Include string
6063
}
6164

6265
GitSourceDeleteOptions struct {
@@ -152,11 +155,12 @@ func NewGitSourceCreateCommand() *cobra.Command {
152155
ctx := cmd.Context()
153156

154157
return RunGitSourceCreate(ctx, &GitSourceCreateOptions{
155-
InsCloneOpts: insCloneOpts,
156-
GsCloneOpts: gsCloneOpts,
157-
GsName: args[1],
158-
RuntimeName: args[0],
159-
FullGsPath: gsCloneOpts.Path(),
158+
InsCloneOpts: insCloneOpts,
159+
GsCloneOpts: gsCloneOpts,
160+
GsName: args[1],
161+
RuntimeName: args[0],
162+
FullGsPath: gsCloneOpts.Path(),
163+
CreateDemoWorkflowTemplate: false,
160164
})
161165
},
162166
}
@@ -174,40 +178,43 @@ func NewGitSourceCreateCommand() *cobra.Command {
174178
}
175179

176180
func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error {
177-
gsRepo, gsFs, err := opts.GsCloneOpts.GetRepo(ctx)
178-
if err != nil {
179-
return err
180-
}
181+
if opts.CreateDemoWorkflowTemplate {
181182

182-
fi, err := gsFs.ReadDir(".")
183-
if err != nil {
184-
return fmt.Errorf("failed to read files in git-source repo. Err: %w", err)
185-
}
186-
187-
if len(fi) == 0 {
188-
err = createCronExamplePipeline(&gitSourceCronExampleOptions{
189-
runtimeName: opts.RuntimeName,
190-
gsCloneOpts: opts.GsCloneOpts,
191-
gsFs: gsFs,
192-
})
183+
gsRepo, gsFs, err := opts.GsCloneOpts.GetRepo(ctx)
193184
if err != nil {
194-
return fmt.Errorf("failed to create cron example pipeline. Error: %w", err)
185+
return err
195186
}
196187

197-
err = createGithubExamplePipeline(&gitSourceGithubExampleOptions{
198-
runtimeName: opts.RuntimeName,
199-
gsCloneOpts: opts.GsCloneOpts,
200-
gsFs: gsFs,
201-
})
188+
fi, err := gsFs.ReadDir(".")
202189
if err != nil {
203-
return fmt.Errorf("failed to create github example pipeline. Error: %w", err)
190+
return fmt.Errorf("failed to read files in git-source repo. Err: %w", err)
204191
}
205192

206-
commitMsg := fmt.Sprintf("Created demo pipelines in %s Directory", opts.GsCloneOpts.Path())
193+
if len(fi) == 0 {
194+
err = createCronExamplePipeline(&gitSourceCronExampleOptions{
195+
runtimeName: opts.RuntimeName,
196+
gsCloneOpts: opts.GsCloneOpts,
197+
gsFs: gsFs,
198+
})
199+
if err != nil {
200+
return fmt.Errorf("failed to create cron example pipeline. Error: %w", err)
201+
}
207202

208-
log.G(ctx).Info("Pushing demo pipelines to the new git-source repo")
209-
if err := apu.PushWithMessage(ctx, gsRepo, commitMsg); err != nil {
210-
return fmt.Errorf("failed to push demo pipelines to git-source repo: %w", err)
203+
err = createGithubExamplePipeline(&gitSourceGithubExampleOptions{
204+
runtimeName: opts.RuntimeName,
205+
gsCloneOpts: opts.GsCloneOpts,
206+
gsFs: gsFs,
207+
})
208+
if err != nil {
209+
return fmt.Errorf("failed to create github example pipeline. Error: %w", err)
210+
}
211+
212+
commitMsg := fmt.Sprintf("Created demo pipelines in %s Directory", opts.GsCloneOpts.Path())
213+
214+
log.G(ctx).Info("Pushing demo pipelines to the new git-source repo")
215+
if err := apu.PushWithMessage(ctx, gsRepo, commitMsg); err != nil {
216+
return fmt.Errorf("failed to push demo pipelines to git-source repo: %w", err)
217+
}
211218
}
212219
}
213220

@@ -217,7 +224,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
217224
URL: opts.GsCloneOpts.Repo,
218225
}
219226

220-
if err := appDef.CreateApp(ctx, nil, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFGitSourceType); err != nil {
227+
if err := appDef.CreateApp(ctx, nil, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFGitSourceType, opts.Include, ""); err != nil {
221228
return fmt.Errorf("failed to create git-source application. Err: %w", err)
222229
}
223230
log.G(ctx).Infof("Successfully created the git-source: '%s'", opts.GsName)

cmd/commands/runtime.go

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -306,27 +306,14 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
306306

307307
for _, component := range rt.Spec.Components {
308308
log.G(ctx).Infof("Creating component '%s'", component.Name)
309-
if err = component.CreateApp(ctx, opts.KubeFactory, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFComponentType); err != nil {
309+
if err = component.CreateApp(ctx, opts.KubeFactory, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFComponentType, "", ""); err != nil {
310310
return fmt.Errorf("failed to create '%s' application: %w", component.Name, err)
311311
}
312312
}
313313

314-
if opts.IngressHost != "" {
315-
if err = createWorkflowsIngress(ctx, opts.InsCloneOpts, rt); err != nil {
316-
return fmt.Errorf("failed to patch Argo-Workflows ingress: %w", err)
317-
}
318-
}
319-
320-
if err = createCodefreshArgoAgentReporter(ctx, opts.InsCloneOpts, opts, rt); err != nil {
321-
return fmt.Errorf("failed to create argocd-agent-reporter: %w", err)
322-
}
323-
324-
if err = createEventsReporter(ctx, opts.InsCloneOpts, opts, rt); err != nil {
325-
return fmt.Errorf("failed to create events-reporter: %w", err)
326-
}
327-
328-
if err = createWorkflowReporter(ctx, opts.InsCloneOpts, opts); err != nil {
329-
return fmt.Errorf("failed to create workflows-reporter: %w", err)
314+
err = installComponents(ctx, opts, rt)
315+
if err != nil {
316+
return err
330317
}
331318

332319
gsPath := opts.GsCloneOpts.FS.Join(apstore.Default.AppsDir, store.Get().GitSourceName, opts.RuntimeName)
@@ -338,6 +325,23 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
338325
GsName: store.Get().GitSourceName,
339326
RuntimeName: opts.RuntimeName,
340327
FullGsPath: fullGsPath,
328+
CreateDemoWorkflowTemplate: true,
329+
}); err != nil {
330+
return fmt.Errorf("failed to create `%s`: %w", store.Get().GitSourceName, err)
331+
}
332+
333+
mpCloneOpts := &git.CloneOptions{
334+
Repo: store.Get().MarketplaceRepo,
335+
}
336+
mpCloneOpts.Parse()
337+
if err = RunGitSourceCreate(ctx, &GitSourceCreateOptions{
338+
InsCloneOpts: opts.InsCloneOpts,
339+
GsCloneOpts: mpCloneOpts,
340+
GsName: store.Get().MarketplaceGitSourceName,
341+
RuntimeName: opts.RuntimeName,
342+
FullGsPath: store.Get().MarketplaceRepo,
343+
CreateDemoWorkflowTemplate: false,
344+
Include: "**/workflowTemplate.yaml",
341345
}); err != nil {
342346
return fmt.Errorf("failed to create `%s`: %w", store.Get().GitSourceName, err)
343347
}
@@ -355,6 +359,28 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
355359
return nil
356360
}
357361

362+
func installComponents(ctx context.Context, opts *RuntimeInstallOptions, rt *runtime.Runtime) error {
363+
var err error
364+
if opts.IngressHost != "" {
365+
if err = createWorkflowsIngress(ctx, opts.InsCloneOpts, rt); err != nil {
366+
return fmt.Errorf("failed to patch Argo-Workflows ingress: %w", err)
367+
}
368+
}
369+
370+
if err = createCodefreshArgoAgentReporter(ctx, opts.InsCloneOpts, opts, rt); err != nil {
371+
return fmt.Errorf("failed to create argocd-agent-reporter: %w", err)
372+
}
373+
374+
if err = createEventsReporter(ctx, opts.InsCloneOpts, opts, rt); err != nil {
375+
return fmt.Errorf("failed to create events-reporter: %w", err)
376+
}
377+
378+
if err = createWorkflowReporter(ctx, opts.InsCloneOpts, opts); err != nil {
379+
return fmt.Errorf("failed to create workflows-reporter: %w", err)
380+
}
381+
return nil
382+
}
383+
358384
func preInstallationChecks(ctx context.Context, opts *RuntimeInstallOptions) error {
359385
log.G(ctx).Debug("running pre-installation checks...")
360386

@@ -707,7 +733,7 @@ func RunRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
707733

708734
for _, component := range newComponents {
709735
log.G(ctx).Infof("Creating app '%s'", component.Name)
710-
if err = component.CreateApp(ctx, nil, opts.CloneOpts, opts.RuntimeName, store.Get().CFComponentType); err != nil {
736+
if err = component.CreateApp(ctx, nil, opts.CloneOpts, opts.RuntimeName, store.Get().CFComponentType, "", ""); err != nil {
711737
return fmt.Errorf("failed to create '%s' application: %w", component.Name, err)
712738
}
713739
}
@@ -820,7 +846,7 @@ func createEventsReporter(ctx context.Context, cloneOpts *git.CloneOptions, opts
820846
Type: application.AppTypeDirectory,
821847
URL: cloneOpts.URL() + "/" + resPath,
822848
}
823-
if err := appDef.CreateApp(ctx, opts.KubeFactory, cloneOpts, opts.RuntimeName, store.Get().CFComponentType); err != nil {
849+
if err := appDef.CreateApp(ctx, opts.KubeFactory, cloneOpts, opts.RuntimeName, store.Get().CFComponentType,"", ""); err != nil {
824850
return err
825851
}
826852

@@ -875,7 +901,7 @@ func createWorkflowReporter(ctx context.Context, cloneOpts *git.CloneOptions, op
875901
Type: application.AppTypeDirectory,
876902
URL: cloneOpts.URL() + "/" + resPath,
877903
}
878-
if err := appDef.CreateApp(ctx, opts.KubeFactory, cloneOpts, opts.RuntimeName, store.Get().CFComponentType); err != nil {
904+
if err := appDef.CreateApp(ctx, opts.KubeFactory, cloneOpts, opts.RuntimeName, store.Get().CFComponentType, "", ""); err != nil {
879905
return err
880906
}
881907

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.113/cf-linux-amd64.tar.gz | tar zx
23+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.114/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.113/cf-darwin-amd64.tar.gz | tar zx
35+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.114/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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.16
44

55
require (
66
github.com/Masterminds/semver/v3 v3.1.1
7-
github.com/argoproj-labs/applicationset v0.1.0
8-
github.com/argoproj-labs/argocd-autopilot v0.2.18
7+
github.com/argoproj-labs/applicationset v0.2.0
8+
github.com/argoproj-labs/argocd-autopilot v0.2.20
99
github.com/argoproj/argo-cd/v2 v2.1.2
1010
github.com/argoproj/argo-events v1.4.0
1111
github.com/argoproj/argo-workflows/v3 v3.1.6
@@ -30,7 +30,6 @@ require (
3030
)
3131

3232
replace (
33-
github.com/argoproj-labs/applicationset => github.com/argoproj-labs/applicationset v0.0.0-20210614145856-2c62537a8e5a
3433
github.com/argoproj/argo-events => github.com/argoproj/argo-events v0.17.1-0.20210615165534-d403c441bc1d
3534
github.com/argoproj/gitops-engine => github.com/argoproj/gitops-engine v0.3.1-0.20210709004906-a4c77d5c70fb
3635
k8s.io/api => k8s.io/api v0.21.1

0 commit comments

Comments
 (0)