This repository was archived by the owner on Mar 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
WIP: Init project #2
Open
tribock
wants to merge
7
commits into
master
Choose a base branch
from
init_project
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
55535a5
create branch for project init
tribock 06507f2
proposal for runner structure
ab6ce3b
start implementing kubernetes executor
4c32966
struggling with versions of scheme package in k8s...
6e200cc
new states
9c17ad6
align to the api proto doc
b86be7a
hopp
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| # runner | ||
| [](https://app.fossa.io/projects/git%2Bgithub.com%2Fyabslabs%2Frunner?ref=badge_shield) | ||
|
|
||
| ## implemented executors | ||
|
|
||
| ## executors to be implemented | ||
|
|
||
| - docker | ||
| - kubernetes | ||
| - shell (what shell?) | ||
|
|
||
| ## project structure | ||
|
|
||
| ## License | ||
| [](https://app.fossa.io/projects/git%2Bgithub.com%2Fyabslabs%2Frunner?ref=badge_large) | ||
| [](https://app.fossa.io/projects/git%2Bgithub.com%2Fyabslabs%2Frunner?ref=badge_large) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Common Package | ||
|
|
||
| This package fakes the common Package until it's fully implemented. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Copyright (c) 2018 VRSG | Verwaltungsrechenzentrum AG, St.Gallen | ||
| * All Rights Reserved. | ||
| */ | ||
|
|
||
| package common | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "io/ioutil" | ||
| "os" | ||
|
|
||
| "google.golang.org/grpc/codes" | ||
| "google.golang.org/grpc/status" | ||
| ) | ||
|
|
||
| type ConfigReader interface { | ||
| Unmarshal(data []byte, o interface{}) error | ||
| } | ||
|
|
||
| type ValidateableConfiguration interface { | ||
| Validate() error | ||
| } | ||
|
|
||
| type ConfigReaderFunc func(data []byte, o interface{}) error | ||
|
|
||
| func (c ConfigReaderFunc) Unmarshal(data []byte, o interface{}) error { | ||
| return c(data, o) | ||
| } | ||
|
|
||
| func readConfigFile(configReader ConfigReader, configFile string, obj interface{}) error { | ||
| configFile = os.ExpandEnv(configFile) | ||
|
|
||
| if _, err := os.Stat(configFile); err != nil { | ||
| fmt.Println("CONF-3e126710", err, configFile) | ||
| return nil | ||
| } | ||
|
|
||
| configStr, err := ioutil.ReadFile(configFile) //nolint: gosec | ||
|
|
||
| if err != nil { | ||
| return status.Errorf(codes.Internal, "failed to read config file %s: %v", configFile, err) | ||
| } | ||
|
|
||
| configStr = []byte(os.ExpandEnv(string(configStr))) | ||
|
|
||
| if err := configReader.Unmarshal(configStr, obj); err != nil { | ||
| return status.Errorf(codes.Internal, "error parse config file %s: %v", configFile, err) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // ReadConfig deserializes each configfile to the target obj using the configReader | ||
| // env vars are replaced in the file path | ||
| func ReadConfig(configReader ConfigReader, obj interface{}, configFiles ...string) error { | ||
| for _, cf := range configFiles { | ||
| if err := readConfigFile(configReader, cf, obj); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| if validateable, ok := obj.(ValidateableConfiguration); ok { | ||
| if err := validateable.Validate(); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| Copyright 2018 tribock. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
| package logging | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
| const ( | ||
| fieldLogID = "abraxasLogID" | ||
| ) | ||
|
|
||
| func WithError(id string, err error) *logrus.Entry { | ||
| return WithID(id).WithError(err) | ||
| } | ||
|
|
||
| func WithID(id string) *logrus.Entry { | ||
| return logrus.WithField(fieldLogID, id) | ||
| } | ||
|
|
||
| func WithIDFields(id string, fields ...interface{}) *logrus.Entry { | ||
| m := Pairs(fields...) | ||
| m[fieldLogID] = id | ||
| return logrus.WithFields(m) | ||
| } | ||
|
|
||
| func Pairs(kv ...interface{}) map[string]interface{} { | ||
| if len(kv)%2 == 1 { | ||
| panic(fmt.Sprintf("Pairs got the odd number of input pairs for metadata: %d", len(kv))) | ||
| } | ||
|
|
||
| v := map[string]interface{}{} | ||
| var key string | ||
| for i, s := range kv { | ||
| if i%2 == 0 { | ||
| key = fmt.Sprint(s) | ||
| continue | ||
| } | ||
|
|
||
| v[key] = s | ||
| } | ||
| return v | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package common | ||
|
|
||
| // JobStatus that represents the Status of a Job | ||
| type JobStatus int | ||
|
|
||
| // JobStatus implementation as enum | ||
| const ( | ||
| UNKNOWN JobStatus = iota | ||
| CREATED | ||
| PENDING | ||
| RUNNING | ||
| FAILED | ||
| SUCCESS | ||
| CANCELED | ||
| SKIPPED | ||
| MANUAL | ||
| STUCK | ||
| RETRIED | ||
| PAUSED | ||
| SUSPENDED | ||
| ) | ||
|
|
||
| type Job struct { | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package configuration | ||
|
|
||
| import ( | ||
| "git.workshop21.ch/go/abraxas/configuration/yaml" | ||
| ) | ||
|
|
||
| type Config struct { | ||
| Env string | ||
| GRPCPort string | ||
| GatewayPort string | ||
| ImageBaseUrl string | ||
| HttpsPort int32 | ||
| } | ||
|
|
||
| func ReadConfig() (*Config, error) { | ||
| config := &Config{} | ||
| err := yaml.ReadConfig(config, | ||
| "./config/config.yaml") | ||
| return config, err | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * Copyright (c) 2018 VRSG | Verwaltungsrechenzentrum AG, St.Gallen | ||
| * All Rights Reserved. | ||
| */ | ||
|
|
||
| package yaml | ||
|
|
||
| import ( | ||
| "git.workshop21.ch/go/abraxas/configuration" | ||
| "github.com/ghodss/yaml" | ||
| ) | ||
|
|
||
| var ConfigReader = configuration.ConfigReaderFunc(yamlUnmarshalNoOpts) | ||
|
|
||
| func yamlUnmarshalNoOpts(y []byte, o interface{}) error { | ||
| return yaml.Unmarshal(y, o) | ||
| } | ||
|
|
||
| func ReadConfig(obj interface{}, configFiles ...string) error { | ||
| return configuration.ReadConfig(ConfigReader, obj, configFiles...) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package executors | ||
|
|
||
| type ExecutionEngine struct { | ||
| Executors []Executor | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package executors | ||
|
|
||
| import ( | ||
| "github.com/yabslabs/runner/common" | ||
| "github.com/yabslabs/runner/executors/kubernetes" | ||
| "github.com/yabslabs/runner/runner" | ||
| ) | ||
|
|
||
| var types = []Executor{&kubernetes.KubernetesExecutor{}} | ||
|
|
||
| type Executor interface { | ||
| GetKind() string | ||
| GetStatus() runner.RunnerStatus | ||
| GetJobStatus() common.JobStatus | ||
| Run(common.Job) common.JobStatus | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fforootd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is aligned to the yabs/api, looks good