diff --git a/Dockerfile b/Dockerfile index 16b684f..f0cb4df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,11 @@ FROM golang:alpine AS builder WORKDIR /app COPY . . -RUN apt install tar/stable RUN go build . FROM argoproj/argocd:latest WORKDIR /app -COPY --from=builder /bin/tar /bin/tar COPY conf/docker_ocmonitord_conf.json /app/conf/ COPY --from=builder /app/oc-monitord . \ No newline at end of file diff --git a/conf/docker_ocmonitord_conf.json b/conf/docker_ocmonitord_conf.json deleted file mode 100644 index cc39adf..0000000 --- a/conf/docker_ocmonitord_conf.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "oc-catalog": "https://oc-catalog:8087" -} \ No newline at end of file diff --git a/conf/local_ocmonitord_conf.json b/conf/local_ocmonitord_conf.json deleted file mode 100644 index 06ca94a..0000000 --- a/conf/local_ocmonitord_conf.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "oc-catalog": "https://localhost:8087" -} \ No newline at end of file diff --git a/main.go b/main.go index 2ede340..019ff28 100644 --- a/main.go +++ b/main.go @@ -115,6 +115,7 @@ func executeWorkflow(argo_file_path string) { // var stderr io.ReadCloser var err error cmd := exec.Command("argo", "submit", "--watch", "./argo_workflows/"+argo_file_path, "--serviceaccount=argo", "-n", "argo") + fmt.Println(cmd) if stdout, err = cmd.StdoutPipe(); err != nil { wf_logger.Error().Msg("Could not retrieve stdoutpipe " + err.Error()) return @@ -199,18 +200,17 @@ func loadConfig(is_k8s bool, parser *argparse.Parser) { } func setConf(is_k8s bool, o *onion.Onion, parser *argparse.Parser) { - mongo := "" - db := "" if is_k8s { conf.GetConfig().LokiURL = o.GetStringDefault("lokiurl", "http://127.0.0.1:3100") conf.GetConfig().ExecutionID = o.GetString("workflow") - mongo = o.GetStringDefault("mongourl", "mongodb://127.0.0.1:27017") - db = o.GetStringDefault("database", "DC_myDC") + mongo := o.GetStringDefault("mongourl", "mongodb://127.0.0.1:27017") + db := o.GetStringDefault("database", "DC_myDC") + oclib.SetConfig(mongo, db) } else { url := parser.String("u", "url", &argparse.Options{Required: true, Default: "http://127.0.0.1:3100", Help: "Url to the Loki database logs will be sent to"}) workflow := parser.String("w", "workflow", &argparse.Options{Required: true, Help: "Execution ID of the workflow to request from oc-catalog API"}) - mongo = *parser.String("m", "mongo", &argparse.Options{Required: true, Help: "URL to reach the MongoDB"}) - db = *parser.String("d", "database", &argparse.Options{Required: true, Help: "Name of the database to query in MongoDB"}) + mongo := parser.String("m", "mongo", &argparse.Options{Required: true, Default: "mongodb://127.0.0.1:27017", Help: "URL to reach the MongoDB"}) + db := parser.String("d", "database", &argparse.Options{Required: true, Default: "DC_myDC", Help: "Name of the database to query in MongoDB"}) err := parser.Parse(os.Args) if err != nil { fmt.Println(parser.Usage(err)) @@ -218,8 +218,9 @@ func setConf(is_k8s bool, o *onion.Onion, parser *argparse.Parser) { } conf.GetConfig().LokiURL = *url conf.GetConfig().ExecutionID = *workflow + oclib.SetConfig(*mongo, *db) } - oclib.SetConfig(mongo, db) + } func initOnion(o *onion.Onion) *onion.Onion { diff --git a/oc-monitord b/oc-monitord index 0407e84..1e861ac 100755 Binary files a/oc-monitord and b/oc-monitord differ diff --git a/workflow_builder/argo_builder.go b/workflow_builder/argo_builder.go index 9b3c708..850375e 100644 --- a/workflow_builder/argo_builder.go +++ b/workflow_builder/argo_builder.go @@ -26,7 +26,7 @@ type Workflow struct { ApiVersion string `yaml:"apiVersion"` Kind string `yaml:"kind"` Metadata struct { - Name string `yaml:"Name"` + Name string `yaml:"name"` } `yaml:"metadata"` Spec Spec `yaml:"spec,omitempty"` }