Skip to content

Commit 3396930

Browse files
Fix agent installation (#98)
* fix path * fix agent installation
1 parent a21c807 commit 3396930

File tree

4 files changed

+13
-28
lines changed

4 files changed

+13
-28
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.96
1+
VERSION=v0.0.97
22
OUT_DIR=dist
33
YEAR?=$(shell date +"%Y")
44

cmd/commands/runtime.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -798,15 +798,7 @@ func createCodefreshArgoAgentReporter(ctx context.Context, cloneOpts *git.CloneO
798798
return fmt.Errorf("failed to create codefresh token: %w", err)
799799
}
800800

801-
resPath := cloneOpts.FS.Join(apstore.Default.AppsDir, store.Get().ArgoCDAgentReporterName, opts.RuntimeName, "resources")
802-
appDef := &runtime.AppDef{
803-
Name: store.Get().ArgoCDAgentReporterName,
804-
Type: application.AppTypeDirectory,
805-
URL: cloneOpts.URL() + "/" + resPath,
806-
}
807-
if err := appDef.CreateApp(ctx, opts.KubeFactory, cloneOpts, opts.RuntimeName, store.Get().CFComponentType); err != nil {
808-
return err
809-
}
801+
resPath := cloneOpts.FS.Join(apstore.Default.AppsDir, store.Get().ArgoCDAgentReporterName, "base")
810802

811803
r, _, err := cloneOpts.GetRepo(ctx)
812804
if err != nil {
@@ -1049,16 +1041,12 @@ func createCodefreshArgoDashboardAgent(ctx context.Context, path string, cloneOp
10491041
if err != nil {
10501042
return err
10511043
}
1052-
resource, err := argodashboardutil.CreateAgentResource()
1053-
if err != nil {
1054-
return err
1055-
}
10561044

10571045
kust := argodashboardutil.CreateAgentResourceKustomize(&argodashboardutil.CreateAgentOptions{Namespace: rt.Namespace, Name: rt.Name})
10581046

10591047
if err = kustutil.WriteKustomization(fs, &kust, path); err != nil {
10601048
return err
10611049
}
10621050

1063-
return billyUtils.WriteFile(fs, fs.Join(path, "argocd-agent.yaml"), resource, 0666)
1051+
return nil
10641052
}

manifests/runtime.yaml

Lines changed: 4 additions & 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.93
8+
version: 0.0.97
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events
@@ -18,3 +18,6 @@ spec:
1818
- name: workflows
1919
type: kustomize
2020
url: github.com/codefresh-io/cli-v2/manifests/argo-workflows
21+
- name: argocd-agent
22+
type: kustomize
23+
url: github.com/codefresh-io/cli-v2/manifests/argo-agent

pkg/util/argo-agent/util.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ package util
1616

1717
import (
1818
"fmt"
19-
"github.com/codefresh-io/cli-v2/pkg/store"
20-
"io/ioutil"
2119
appsv1 "k8s.io/api/apps/v1"
2220
v1 "k8s.io/api/core/v1"
2321
rbacv1 "k8s.io/api/rbac/v1"
@@ -32,14 +30,6 @@ type (
3230
}
3331
)
3432

35-
func CreateAgentResource() ([]byte, error) {
36-
yamlFile, err := ioutil.ReadFile(store.ArgoAgentURL)
37-
if err != nil {
38-
return nil, err
39-
}
40-
return []byte(yamlFile), err
41-
}
42-
4333
func addPatch(patches []kusttypes.Patch, gvk kustid.Gvk, patch string) []kusttypes.Patch {
4434
return append(patches, kusttypes.Patch{
4535
Target: &kusttypes.Selector{
@@ -61,6 +51,10 @@ func CreateAgentResourceKustomize(options *CreateAgentOptions) kusttypes.Kustomi
6151

6252
namespaceReplacement := fmt.Sprintf(`- op: replace
6353
path: /metadata/namespace
54+
value: %s`, options.Namespace)
55+
56+
crbNamespaceReplacement := fmt.Sprintf(`- op: replace
57+
path: /subjects/0/namespace
6458
value: %s`, options.Namespace)
6559

6660
hostReplacement := fmt.Sprintf(`- op: replace
@@ -71,7 +65,7 @@ func CreateAgentResourceKustomize(options *CreateAgentOptions) kusttypes.Kustomi
7165
path: /data/integration
7266
value: argocd-%s`, options.Name)
7367

74-
kust.Resources = append(kust.Resources, "./argocd-agent.yaml")
68+
kust.Resources = append(kust.Resources, "https://raw.githubusercontent.com/codefresh-io/cli-v2/main/manifests/argo-agent/agent.yaml")
7569

7670
kust.Patches = addPatch(kust.Patches, kustid.Gvk{
7771
Group: appsv1.SchemeGroupVersion.Group,
@@ -88,7 +82,7 @@ func CreateAgentResourceKustomize(options *CreateAgentOptions) kusttypes.Kustomi
8882
Group: rbacv1.SchemeGroupVersion.Group,
8983
Version: v1.SchemeGroupVersion.Version,
9084
Kind: "ClusterRoleBinding",
91-
}, namespaceReplacement)
85+
}, crbNamespaceReplacement)
9286

9387
kust.Patches = addPatch(kust.Patches, kustid.Gvk{
9488
Version: v1.SchemeGroupVersion.Version,

0 commit comments

Comments
 (0)