Skip to content

Commit

Permalink
fixing gitsource (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
roi-codefresh authored Aug 5, 2021
1 parent ddf1d72 commit 760757a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 147 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.0.51
VERSION=v0.0.52
OUT_DIR=dist
YEAR?=$(shell date +"%Y")

Expand Down
144 changes: 2 additions & 142 deletions cmd/commands/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions docs/releases/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion manifests/argo-cd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion manifests/runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 760757a

Please sign in to comment.