diff --git a/.gitignore b/.gitignore
index 473eba8..f97aab7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,5 +23,5 @@ go.work
__debug_bin
-workflows_argo/
+argo_workflows/*
*.xml
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..0956568
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,18 @@
+FROM golang:alpine AS builder
+LABEL maintainer="IRT PFN"
+ENV DOCKER_ENVIRONMENT=true
+WORKDIR /app
+
+COPY . .
+COPY conf/docker_scheduler.json /etc/oc/scheduler.json
+
+RUN go build .
+
+FROM golang:alpine
+WORKDIR /app
+
+COPY --from=builder /app/oc-scheduler .
+COPY conf/docker_scheduler.json /etc/oc/scheduler.json
+
+ENTRYPOINT ["/app/oc-scheduler"]
+
diff --git a/conf/conf.go b/conf/conf.go
new file mode 100644
index 0000000..9923b38
--- /dev/null
+++ b/conf/conf.go
@@ -0,0 +1,59 @@
+package conf
+
+import (
+ "sync"
+
+ "github.com/beego/beego/logs"
+ "github.com/goraz/onion"
+)
+
+type Config struct {
+ OcCatalogUrl string
+ Logs string
+}
+
+var instance *Config
+var once sync.Once
+
+const defaultConfigFile = "/app/conf/scheduler.json"
+const localConfigFile = "./conf/local_scheduler.json"
+
+
+func init(){
+
+ configFile := ""
+ var o *onion.Onion
+
+ l3 := onion.NewEnvLayerPrefix("_", "OCSCHEDULER_")
+ l2, err := onion.NewFileLayer(defaultConfigFile, nil)
+ if err == nil {
+ logs.Info("Config file found : " + defaultConfigFile)
+ configFile = defaultConfigFile
+ }
+ l1, err := onion.NewFileLayer(localConfigFile, nil)
+ if err == nil {
+ logs.Info("Local config file found " + localConfigFile + ", overriding default file")
+ configFile = localConfigFile
+ }
+ if configFile == "" {
+ logs.Info("No config file found, using env")
+ o = onion.New(l3)
+ } else if l1 == nil && l2 == nil {
+ o = onion.New(l1, l2, l3)
+ } else if l1 == nil {
+ o = onion.New(l2, l3)
+ } else if l2 == nil {
+ o = onion.New(l1, l3)
+ }
+
+ GetConfig().OcCatalogUrl = o.GetStringDefault("oc-catalog", "https://localhost:49618")
+ GetConfig().Logs = o.GetStringDefault("loglevel", "info")
+
+}
+
+func GetConfig() *Config {
+ once.Do(func() {
+ instance = &Config{}
+ })
+ return instance
+}
diff --git a/conf/docker_scheduler.json b/conf/docker_scheduler.json
new file mode 100644
index 0000000..fab15e5
--- /dev/null
+++ b/conf/docker_scheduler.json
@@ -0,0 +1,3 @@
+{
+ "oc-catalog" : "http://oc-catalog:49618/"
+}
\ No newline at end of file
diff --git a/conf/local_scheduler.json b/conf/local_scheduler.json
new file mode 100644
index 0000000..56fe196
--- /dev/null
+++ b/conf/local_scheduler.json
@@ -0,0 +1,3 @@
+{
+ "oc-catalog" : "http://localhost:49618/"
+}
\ No newline at end of file
diff --git a/docs/classe_scheduler.puml b/docs/classe_scheduler.puml
new file mode 100644
index 0000000..d686034
--- /dev/null
+++ b/docs/classe_scheduler.puml
@@ -0,0 +1,86 @@
+@startuml
+namespace main {
+ class ArgoBuilder << (S,Aquamarine) >> {
+ - graph Graph
+ - branches [][]string
+
+ + Workflow Workflow
+
+ - createTemplates()
+ - createDAGstep()
+ - createVolumes()
+ - getDependency(current_computing_id string) []string
+
+ + CreateDAG() bool
+
+ }
+ class Container << (S,Aquamarine) >> {
+ + Image string
+ + Command []string
+ + Args []string
+ + VolumeMounts []VolumeMount
+
+ }
+ class Dag << (S,Aquamarine) >> {
+ + Tasks []Task
+
+ }
+
+ class Link << (S,Aquamarine) >> {
+ + Src string
+ + Dst string
+
+ }
+ class Parameter << (S,Aquamarine) >> {
+ + Name string
+ + Value string
+
+ }
+ class Spec << (S,Aquamarine) >> {
+ + Entrypoint string
+ + Arguments []Parameter
+ + Volumes []VolumeClaimTemplate
+ + Templates []Template
+
+ }
+ class Task << (S,Aquamarine) >> {
+ + Name string
+ + Template string
+ + Dependencies []string
+ + Arguments struct{[]Parameter}
+
+ }
+ class Template << (S,Aquamarine) >> {
+ + Name string
+ + Inputs struct{[]Parameter}
+ + Container Container
+ + Dag Dag
+
+ }
+ class VolumeClaimTemplate << (S,Aquamarine) >> {
+ + Metadata struct{string}
+ + Spec VolumeSpec
+
+ }
+ class VolumeMount << (S,Aquamarine) >> {
+ + Name string
+ + MountPath string
+
+ }
+ class VolumeSpec << (S,Aquamarine) >> {
+ + AccessModes []string
+ + Resources struct{struct{string}}
+
+ }
+
+ class Workflow << (S,Aquamarine) >> {
+ + ApiVersion string
+ + Kind string
+ + Metadata struct{string}
+ + Spec Spec
+
+ }
+}
+
+
+@enduml
diff --git a/go.mod b/go.mod
index 96a72ba..bf20f89 100644
--- a/go.mod
+++ b/go.mod
@@ -16,6 +16,7 @@ require (
github.com/Klathmon/StructToMap v0.0.0-20140724123129-3d0229e2dce7 // indirect
github.com/antihax/optional v1.0.0 // indirect
github.com/aws/aws-sdk-go v1.36.29 // indirect
+ github.com/beego/beego v1.12.12 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
diff --git a/go.sum b/go.sum
index 6bc19a6..32b2b77 100644
--- a/go.sum
+++ b/go.sum
@@ -33,6 +33,7 @@ github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/
github.com/aws/aws-sdk-go v1.36.29 h1:lM1G3AF1+7vzFm0n7hfH8r2+750BTo+6Lo6FtPB7kzk=
github.com/aws/aws-sdk-go v1.36.29/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
+github.com/beego/beego v1.12.12 h1:ARY1sNVSS23N0mEQIhSqRDTyyDlx95JY0V3GogBbZbQ=
github.com/beego/beego v1.12.12/go.mod h1:QURFL1HldOcCZAxnc1cZ7wrplsYR5dKPHFjmk6WkLAs=
github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI=
github.com/beego/beego/v2 v2.2.0 h1:x2yCNL9x74vqAXRdFBw5HCzB8AwownALpBWEOitivow=
diff --git a/main.go b/main.go
index e6acb80..ec9d540 100644
--- a/main.go
+++ b/main.go
@@ -5,7 +5,8 @@ import (
"os"
"time"
- "github.com/goraz/onion"
+ conf "oc-scheduler/conf"
+
"github.com/rs/zerolog"
)
@@ -15,19 +16,9 @@ func main() {
output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339}
log = zerolog.New(output).With().Timestamp().Logger()
- var o *onion.Onion
- l2 := onion.NewEnvLayerPrefix("_", "OC-SCHED")
- l1, err := onion.NewFileLayer("config.json", nil)
- if err != nil {
- log.Info().Msg("no config file found, using env")
- o = onion.New(l2)
- } else {
- o = onion.New(l1, l2)
- }
- loglevel := o.GetStringDefault("loglevel", "info")
- apiurl := o.GetStringDefault("apiurl", "http://localhost:49618/")
- _ = loglevel
-
+ app_conf := conf.GetConfig()
+ apiurl := app_conf.OcCatalogUrl
+
var g Graph
list, err := g.GetGraphList(apiurl)
diff --git a/oc-scheduler b/oc-scheduler
new file mode 100755
index 0000000..9e423e5
Binary files /dev/null and b/oc-scheduler differ