Skip to content

Commit b79a1e1

Browse files
committed
moved scripts around
1 parent cd6ebe6 commit b79a1e1

File tree

8 files changed

+28
-22
lines changed

8 files changed

+28
-22
lines changed

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
.DEFAULT_GOAL := apply
22

3+
# Local build
34
build:
4-
@docker build -t urielc12/argocd-plugin:v0.1.0 .
5-
@kind load docker-image urielc12/argocd-plugin:v0.1.0 --name argo-workflows-plugin-argocd
65
@scripts/build_plugin.sh
76

87
apply: build
9-
@kubectl apply -n argo -f out/argocd-executor-plugin-configmap.yaml
8+
@kubectl apply -n argo -f deployments/argocd-executor-plugin-configmap.yaml
109
@kubectl apply -n argo -f examples/rbac.yaml
1110

1211
submit:
1312
@argo submit -n argo examples/argocd-example-wf.yaml
13+
14+
setup:
15+
@scripts/create_cluster.sh
16+
17+
clean:
18+
@scripts/delete_cluster.sh

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ COPY go.mod ./
1212
COPY go.sum ./
1313
RUN go mod download
1414
COPY . .
15-
RUN GOOS=linux go build -o plugin cmd/main.go
15+
RUN GOOS=linux go build -o plugin cmd/argocd-plugin/main.go
1616

1717
FROM alpine:3.15
1818
WORKDIR /app

cmd/argocd-plugin/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ package main
33
import (
44
"context"
55
"net/http"
6+
7+
"github.com/UrielCohen456/argo-workflows-argocd-executor-plugin/common"
8+
argocd "github.com/UrielCohen456/argo-workflows-argocd-executor-plugin/internal/argocd-plugin"
69
)
710

811
func main() {
9-
ctx := context.Background()
10-
http.HandleFunc("/api/v1/template.execute", ArgocdPlugin(ctx))
12+
ctx := context.WithValue(context.Background(), "namespace", common.Namespace());
13+
http.HandleFunc("/api/v1/template.execute", argocd.ArgocdPlugin(ctx))
1114
http.ListenAndServe(":4355", nil)
1215
}

common/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"strings"
77
)
88

9+
// Returns the namespace the pod runs in.
910
func Namespace() string {
1011
// This way assumes you've set the POD_NAMESPACE environment variable using the downward API.
11-
// This check has to be done first for backwards compatibility with the way InClusterConfig was originally set up
1212
if ns, ok := os.LookupEnv("POD_NAMESPACE"); ok {
1313
return ns
1414
}

internal/argocd/plugin.go renamed to internal/argocd-plugin/plugin.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"context"
55
"fmt"
66
"net/http"
7-
"os/exec"
87

9-
"github.com/UrielCohen456/argo-workflows-argocd-executor-plugin/common"
8+
// "os/exec"
9+
1010
// "k8s.io/apimachinery/pkg/api/errors"
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1212
"k8s.io/client-go/kubernetes"
@@ -15,13 +15,11 @@ import (
1515

1616
func ArgocdPlugin(ctx context.Context) func(w http.ResponseWriter, req *http.Request) {
1717
return func(w http.ResponseWriter, req *http.Request) {
18-
ctx := context.WithValue(ctx, "namespace", common.Namespace());
19-
20-
output, err := exec.Command("argocd").Output()
21-
if err!=nil {
22-
fmt.Println(err.Error())
23-
}
24-
fmt.Println(string(output))
18+
// output, err := exec.Command("argocd").Output()
19+
// if err!=nil {
20+
// fmt.Println(err.Error())
21+
// }
22+
// fmt.Println(string(output))
2523

2624
config, err := rest.InClusterConfig()
2725
if err != nil {

scripts/build_plugin.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/env bash
22

33
argo executor-plugin build ./deployments
4-
# mv cmd/README.md out/
5-
# mv cmd/argocd-executor-plugin-configmap.yaml out/
4+
docker build -t urielc12/argocd-plugin -f ./build/Dockerfile .
5+
kind load docker-image urielc12/argocd-plugin --name argo-workflows-plugin-argocd

scripts/create_cluster.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ kubectl config set-context --current --namespace argo > /dev/null 2>&1
2222
echo "Setting up the argo tools..."
2323
scripts/setup_argo_workflows.sh
2424
scripts/setup_argocd.sh
25-
make apply
2625

2726
SECRET=$(kubectl get sa argo-server -n argo -o=jsonpath='{.secrets[0].name}')
2827
ARGO_TOKEN="Bearer $(kubectl get secret -n argo $SECRET -o=jsonpath='{.data.token}' | base64 --decode)"
@@ -31,9 +30,10 @@ ARGO_TOKEN="Bearer $(kubectl get secret -n argo $SECRET -o=jsonpath='{.data.toke
3130
echo "----------------------------------------------------------------"
3231
echo
3332
echo "Finished creating the cluster enviornment! To get started: "
34-
echo "1. Run 'make submit' to create a workflow running the plugin. "
35-
echo "2. Connect to the argocd server by typing localhost:8080 in your browser"
36-
echo "3. To connect to the argo server instead of using the argo cli: "
33+
echo "1. Run 'make apply' to create the plugin."
34+
echo "2. Run 'make submit' to apply a workflow running the plugin."
35+
echo "3. Connect to the argocd server by typing localhost:8080 in your browser."
36+
echo "4. To connect to the argo server instead of using the argo cli: "
3737
echo "Copy the following token then port forward your argo-server service and use that token to login to it."
3838
echo
3939
echo $ARGO_TOKEN

0 commit comments

Comments
 (0)