From 760757ac119493d2f5189a4b446a3aa0796705fb Mon Sep 17 00:00:00 2001 From: roi-codefresh <60569147+roi-codefresh@users.noreply.github.com> Date: Thu, 5 Aug 2021 15:48:15 +0300 Subject: [PATCH] fixing gitsource (#49) --- Makefile | 2 +- cmd/commands/runtime.go | 144 +-------------------------- docs/releases/release_notes.md | 4 +- manifests/argo-cd/kustomization.yaml | 2 +- manifests/runtime.yaml | 2 +- 5 files changed, 7 insertions(+), 147 deletions(-) diff --git a/Makefile b/Makefile index 0170ed011..838b5f820 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=v0.0.51 +VERSION=v0.0.52 OUT_DIR=dist YEAR?=$(shell date +"%Y") diff --git a/cmd/commands/runtime.go b/cmd/commands/runtime.go index e1b8e7f72..ed72cd686 100644 --- a/cmd/commands/runtime.go +++ b/cmd/commands/runtime.go @@ -803,155 +803,15 @@ func createDemoWorkflowTemplate(ctx context.Context, gsCloneOpts *git.CloneOptio } func createGitSource(ctx context.Context, insCloneOpts *git.CloneOptions, gsCloneOpts *git.CloneOptions, gsName, runtimeName, cfBaseURL string) error { - var err error - - insRepo, insFs, err := insCloneOpts.GetRepo(ctx) - if err != nil { - return err - } - - resPath := insFs.Join(apstore.Default.AppsDir, gsName, runtimeName, "resources") - eventSourceName := gsName + "-event-source" - gsSyncName := gsName + "-synchronize" - selectors := []eventsutil.CreateSelectorOptions{ - { - Key: "app.kubernetes.io/instance", - Operation: "==", - Value: gsSyncName, - }, - } - eventSource := eventsutil.CreateEventSource(&eventsutil.CreateEventSourceOptions{ - Name: eventSourceName, - Namespace: runtimeName, - ServiceAccountName: store.Get().CodefreshSA, - EventBusName: store.Get().EventBusName, - Resource: map[string]eventsutil.CreateResourceEventSourceOptions{ - // "clusterWorkflowTemplate": { - // Group: "argoproj.io", - // Version: "v1alpha1", - // Resource: "clusterworkflowtemplates", - // Namespace: runtimeName, - // Selectors: selectors, - // }, - "cronWorkflow": { - Group: "argoproj.io", - Version: "v1alpha1", - Resource: "cronworkflows", - Namespace: runtimeName, - Selectors: selectors, - }, - "workflowTemplate": { - Group: "argoproj.io", - Version: "v1alpha1", - Resource: "workflowtemplates", - Namespace: runtimeName, - Selectors: selectors, - }, - "workflow": { - Group: "argoproj.io", - Version: "v1alpha1", - Resource: "workflows", - Namespace: runtimeName, - Selectors: selectors, - }, - "appProject": { - Group: "argoproj.io", - Version: "v1alpha1", - Resource: "appprojects", - Namespace: runtimeName, - Selectors: selectors, - }, - "application": { - Group: "argoproj.io", - Version: "v1alpha1", - Resource: "applications", - Namespace: runtimeName, - Selectors: selectors, - }, - "eventBus": { - Group: "argoproj.io", - Version: "v1alpha1", - Resource: "eventbus", - Namespace: runtimeName, - Selectors: selectors, - }, - "eventSource": { - Group: "argoproj.io", - Version: "v1alpha1", - Resource: "eventsources", - Namespace: runtimeName, - Selectors: selectors, - }, - "sensor": { - Group: "argoproj.io", - Version: "v1alpha1", - Resource: "sensors", - Namespace: runtimeName, - Selectors: selectors, - }, - "rollout": { - Group: "argoproj.io", - Version: "v1alpha1", - Resource: "rollouts", - Namespace: runtimeName, - Selectors: selectors, - }, - }, - }) - if err := insFs.WriteYamls(insFs.Join(resPath, "event-source.yaml"), eventSource); err != nil { - return err - } - - sensor := eventsutil.CreateSensor(&eventsutil.CreateSensorOptions{ - Name: gsName + "-sensor", - Namespace: runtimeName, - EventSourceName: eventSourceName, - EventBusName: store.Get().EventBusName, - TriggerURL: cfBaseURL + store.Get().EventReportingEndpoint, - Triggers: []string{ - // "clusterWorkflowTemplate", - "workflowTemplate", - "workflow", - "appProject", - "application", - "eventBus", - "eventSource", - "sensor", - "rollout", - }, - }) - if err = insFs.WriteYamls(insFs.Join(resPath, "sensor.yaml"), sensor); err != nil { - return err - } - gsPath := gsCloneOpts.FS.Join(apstore.Default.AppsDir, gsName, runtimeName) fullGsPath := gsCloneOpts.FS.Join(gsCloneOpts.FS.Root(), gsPath)[1:] - syncApp := cdutil.CreateApp(&cdutil.CreateAppOptions{ - Name: gsSyncName, - Namespace: runtimeName, - Project: runtimeName, - SyncWave: 10, - RepoURL: gsCloneOpts.URL(), - Revision: gsCloneOpts.Revision(), - SrcPath: fullGsPath, - }) - if err = insFs.WriteYamls(insFs.Join(resPath, gsName+"-synchronize.yaml"), syncApp); err != nil { - return err - } - - _, err = insRepo.Persist(ctx, &git.PushOptions{ - CommitMsg: fmt.Sprintf("Created %s Resources", gsName), - }) - if err != nil { - return err - } appDef := &runtime.AppDef{ Name: gsName, Type: application.AppTypeDirectory, - URL: insCloneOpts.URL() + insFs.Join(insFs.Root(), resPath), + URL: gsCloneOpts.URL() + fullGsPath, } - if err = appDef.CreateApp(ctx, nil, insCloneOpts, runtimeName, store.Get().CFGitSourceType, nil); err != nil { + if err := appDef.CreateApp(ctx, nil, insCloneOpts, runtimeName, store.Get().CFGitSourceType, nil); err != nil { return fmt.Errorf("failed to create git-source: %w", err) } diff --git a/docs/releases/release_notes.md b/docs/releases/release_notes.md index e1c002055..665ab599a 100644 --- a/docs/releases/release_notes.md +++ b/docs/releases/release_notes.md @@ -8,7 +8,7 @@ ### Linux ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.51/cf-linux-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.52/cf-linux-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-linux-amd64 /usr/local/bin/cf @@ -20,7 +20,7 @@ cf version ### Mac ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.51/cf-darwin-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.52/cf-darwin-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-darwin-amd64 /usr/local/bin/cf diff --git a/manifests/argo-cd/kustomization.yaml b/manifests/argo-cd/kustomization.yaml index 4e8b7e454..09d9d5125 100644 --- a/manifests/argo-cd/kustomization.yaml +++ b/manifests/argo-cd/kustomization.yaml @@ -14,7 +14,7 @@ configMapGenerator: - name: argocd-cm behavior: merge literals: - - "timeout.reconciliation=10s" + - "timeout.reconciliation=20s" - "accounts.admin=apiKey,login" # need to be able to generate apikey for generic eventsource - name: argocd-cmd-params-cm behavior: merge diff --git a/manifests/runtime.yaml b/manifests/runtime.yaml index d955bf018..e763c1446 100644 --- a/manifests/runtime.yaml +++ b/manifests/runtime.yaml @@ -5,7 +5,7 @@ metadata: namespace: "{{ namespace }}" spec: defVersion: 1.0.0 - version: 0.0.51 + version: 0.0.52 bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd components: - name: events