diff --git a/README.md b/README.md index 774d0c4..800ef83 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ # runner [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fyabslabs%2Frunner.svg?type=shield)](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 -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fyabslabs%2Frunner.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fyabslabs%2Frunner?ref=badge_large) \ No newline at end of file +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fyabslabs%2Frunner.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fyabslabs%2Frunner?ref=badge_large) diff --git a/common/README.MD b/common/README.MD new file mode 100644 index 0000000..7a5c58a --- /dev/null +++ b/common/README.MD @@ -0,0 +1,3 @@ +# Common Package + +This package fakes the common Package until it's fully implemented. \ No newline at end of file diff --git a/common/config.go b/common/config.go new file mode 100644 index 0000000..ab1c191 --- /dev/null +++ b/common/config.go @@ -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 +} diff --git a/common/logging/logging.go b/common/logging/logging.go new file mode 100644 index 0000000..c7fb9d5 --- /dev/null +++ b/common/logging/logging.go @@ -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 +} diff --git a/common/types.go b/common/types.go new file mode 100644 index 0000000..d3c78d1 --- /dev/null +++ b/common/types.go @@ -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 { +} diff --git a/configuration/config.go b/configuration/config.go new file mode 100644 index 0000000..bc98d7e --- /dev/null +++ b/configuration/config.go @@ -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 +} diff --git a/configuration/yaml/config.go b/configuration/yaml/config.go new file mode 100644 index 0000000..efd26cb --- /dev/null +++ b/configuration/yaml/config.go @@ -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...) +} diff --git a/executors/engine.go b/executors/engine.go new file mode 100644 index 0000000..6432c9f --- /dev/null +++ b/executors/engine.go @@ -0,0 +1,5 @@ +package executors + +type ExecutionEngine struct { + Executors []Executor +} diff --git a/executors/executor_types.go b/executors/executor_types.go new file mode 100644 index 0000000..e5bbb12 --- /dev/null +++ b/executors/executor_types.go @@ -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 +} diff --git a/executors/kubernetes/kubernetes.go b/executors/kubernetes/kubernetes.go new file mode 100644 index 0000000..e08ceac --- /dev/null +++ b/executors/kubernetes/kubernetes.go @@ -0,0 +1,161 @@ +package kubernetes + +import ( + "fmt" + "io/ioutil" + "io" + "os" + + "github.com/yabslabs/runner/common" + "github.com/yabslabs/runner/runner" + "sigs.k8s.io/controller-runtime/pkg/client/config" + + "github.com/sirupsen/logrus" + api "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/kubernetes/scheme" + restclient "k8s.io/client-go/rest" +) + +// RemoteExecutor defines the interface accepted by the Exec command - provided for test stubbing +type RemoteExecutor interface { + Execute(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool) error +} + +// DefaultRemoteExecutor is the standard implementation of remote command execution +type DefaultRemoteExecutor struct{} + +func (*DefaultRemoteExecutor) Execute(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool) error { + exec, err := remotecommand.NewSPDYExecutor(config, method, url) + if err != nil { + return err + } + + return exec.Stream(remotecommand.StreamOptions{ + Stdin: stdin, + Stdout: stdout, + Stderr: stderr, + Tty: tty, + }) +} + + +func (e *KubernetesExecutor) GetKind() string { + return "Kubernetes Executor" +} + +func (e *KubernetesExecutor) GetStatus() runner.RunnerStatus { + return 1 +} + +func (e *KubernetesExecutor) GetJobStatus() common.JobStatus { + return 1 +} + +func (e *KubernetesExecutor) Run(job common.Job) common.JobStatus { + pod, err := e.Client.CoreV1().Pods(e.Namespace).Get(e.PodName, metav1.GetOptions{}) + if err != nil { + return err + } + + if pod.Status.Phase != api.PodRunning { + return fmt.Errorf("Pod '%s' (on namespace '%s') is not running and cannot execute commands; current phase is '%s'", + e.PodName, e.Namespace, pod.Status.Phase) + } + + containerName := e.ContainerName + if len(containerName) == 0 { + logrus.Infof("defaulting container name to '%s'", pod.Spec.Containers[0].Name) + containerName = pod.Spec.Containers[0].Name + } + + // TODO: refactor with terminal helpers from the edit utility once that is merged + var stdin io.Reader + if e.Stdin { + stdin = e.In + } + + // TODO: consider abstracting into a client invocation or client helper + req := e.Client.CoreV1().RESTClient().Post(). + Resource("pods"). + Name(pod.Name). + Namespace(pod.Namespace). + SubResource("exec"). + Param("container", containerName) + req.VersionedParams(&api.PodExecOptions{ + Container: containerName, + Command: e.Command, + Stdin: stdin != nil, + Stdout: e.Out != nil, + Stderr: e.Err != nil, + }, scheme.ParameterCodec) + + return e.Executor.Execute("POST", req.URL(), e.Config, stdin, e.Out, e.Err, false) + +} + +type KubernetesExecutor struct { + Namespace string + PodName string + ContainerName string + Stdin bool + Command []string + + In io.Reader + Out io.Writer + Err io.Writer + + Executor RemoteExecutor + Client *kubernetes.Clientset + Config *restclient.Config +} + +func CreateKubernetesExecutor()(*KubernetesExecutor, error){ + config, err := configuration.ReadConfig() + if err != nil { + log.Error(err, "unable to set up client config") + return nil, err + } + cfg, err := config.GetConfig() + if err != nil { + log.Error(err, "unable to set up client config") + return nil, err + } + hostname, err := os.Hostname() + if err != nil { + log.Error(err, "unable to get hostname") + return nil, err + } + clientset, err := GetClientSet(cfg) + if err != nil { + log.Error(err, "unable to get clientset") + return nil, err + } + namespace, err := GetNamespaceFromFile() + if err != nil { + log.Error(err, "unable to read namespacefile") + return nil, err + } + return KubernetesExecutor{ + PodName: hostname, + Client: clientset, + Config: cfg, + Namespace: namespace, + }, nil +} + + +func GetClientSet(config *rest.Config) (*kubernetes.Clientset, error) { + return kubernetes.NewForConfig(config) +} + +func GetNamespaceFromFile()(string,error){ + + b, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace") + if err != nil { + fmt.Print(err) + + } + return b,err +} \ No newline at end of file diff --git a/executors/register.go b/executors/register.go new file mode 100644 index 0000000..cce226e --- /dev/null +++ b/executors/register.go @@ -0,0 +1,8 @@ +package executors + +func (e *ExecutionEngine) RegisterTypes() error { + for _, eType := range types { + e.Executors = append(e.Executors, eType) + } + return nil +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..52ec596 --- /dev/null +++ b/go.mod @@ -0,0 +1,40 @@ +module github.com/yabslabs/runner + +require ( + git.workshop21.ch/go/abraxas v0.0.0-20190128134023-1863c65a9857 + github.com/aws/aws-sdk-go v1.16.26 // indirect + github.com/ghodss/yaml v1.0.0 + github.com/go-logr/logr v0.1.0 // indirect + github.com/go-logr/zapr v0.1.0 // indirect + github.com/gogo/protobuf v1.2.0 // indirect + github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect + github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect + github.com/googleapis/gnostic v0.2.0 // indirect + github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect + github.com/imdario/mergo v0.3.7 // indirect + github.com/json-iterator/go v1.1.5 // indirect + github.com/kubernetes/client-go v10.0.0+incompatible // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/onsi/ginkgo v1.7.0 // indirect + github.com/onsi/gomega v1.4.3 // indirect + github.com/peterbourgon/diskv v2.0.1+incompatible // indirect + github.com/sirupsen/logrus v1.3.0 + github.com/spf13/pflag v1.0.3 // indirect + go.uber.org/atomic v1.3.2 // indirect + go.uber.org/multierr v1.1.0 // indirect + go.uber.org/zap v1.9.1 // indirect + golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3 // indirect + golang.org/x/oauth2 v0.0.0-20190130055435-99b60b757ec1 // indirect + golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect + google.golang.org/genproto v0.0.0-20190201180003-4b09977fb922 // indirect + google.golang.org/grpc v1.18.0 + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.2.2 // indirect + k8s.io/api v0.0.0-20190202010521-49be0e3344fe + k8s.io/apimachinery v0.0.0-20190201131811-df262fa1a1ba + k8s.io/client-go v10.0.0+incompatible + k8s.io/klog v0.1.0 // indirect + sigs.k8s.io/controller-runtime v0.1.10 + sigs.k8s.io/yaml v1.1.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..f651ad3 --- /dev/null +++ b/go.sum @@ -0,0 +1,129 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +git.workshop21.ch/go/abraxas v0.0.0-20190128134023-1863c65a9857 h1:72Z2G3jKFRTT36EpEvhgwGmgClLh7UFHFuHQxDYSu6A= +git.workshop21.ch/go/abraxas v0.0.0-20190128134023-1863c65a9857/go.mod h1:Lqyx4cwsMgIB9TRiM3Q9a51H9moThwP5LqBoqE7Hn7o= +github.com/aws/aws-sdk-go v1.16.26 h1:GWkl3rkRO/JGRTWoLLIqwf7AWC4/W/1hMOUZqmX0js4= +github.com/aws/aws-sdk-go v1.16.26/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= +github.com/go-logr/zapr v0.1.0 h1:h+WVe9j6HAA01niTJPA/kKH0i7e0rLZBCwauQFcRE54= +github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= +github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= +github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f h1:ShTPMJQes6tubcjzGMODIVG5hlrCeImaBnZzKF2N8SM= +github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= +github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kubernetes/client-go v10.0.0+incompatible h1:JyUQ2lK3g7vKdhEswzIYwJ7EkJ0J3A+uXbuRNAXhtbk= +github.com/kubernetes/client-go v10.0.0+incompatible/go.mod h1:kszVi2i+FeqECZHhjpkV5h5zM0GnURfJv897YzgoAQ8= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME= +github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3 h1:ulvT7fqt0yHWzpJwI57MezWnYDVpCAYBVuYst/L+fAY= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190130055435-99b60b757ec1 h1:VeAkjQVzKLmu+JnFcK96TPbkuaTIqwGGAzQ9hgwPjVg= +golang.org/x/oauth2 v0.0.0-20190130055435-99b60b757ec1/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190201180003-4b09977fb922 h1:mBVYJnbrXLA/ZCBTCe7PtEgAUP+1bg92qTaFoPHdz+8= +google.golang.org/genproto v0.0.0-20190201180003-4b09977fb922/go.mod h1:L3J43x8/uS+qIUoksaLKe6OS3nUKxOKuIFz1sl2/jx4= +google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= +google.golang.org/grpc v1.18.0 h1:IZl7mfBGfbhYx2p2rKRtYgDFw6SBz+kclmxYrCksPPA= +google.golang.org/grpc v1.18.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/api v0.0.0-20190202010521-49be0e3344fe h1:opb90qg6JfThmDQtvFn4mWVy1Q/GNle1zMO+rKUn/eI= +k8s.io/api v0.0.0-20190202010521-49be0e3344fe/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= +k8s.io/api v0.0.0-20190216013246-4fc7e53fae8a h1:vxHq33HWIr/JR166gKceHkczAgNZM87meP/X8Is8+Mw= +k8s.io/apimachinery v0.0.0-20190201131811-df262fa1a1ba h1:HEhywVhwcfpe9vpG7nc3wxA/YG6pb1W9zkvmFxs+320= +k8s.io/apimachinery v0.0.0-20190201131811-df262fa1a1ba/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= +k8s.io/client-go v10.0.0+incompatible h1:F1IqCqw7oMBzDkqlcBymRq1450wD0eNqLE9jzUrIi34= +k8s.io/client-go v10.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= +k8s.io/klog v0.1.0 h1:I5HMfc/DtuVaGR1KPwUrTc476K8NCqNBldC7H4dYEzk= +k8s.io/klog v0.1.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +sigs.k8s.io/controller-runtime v0.1.10 h1:amLOmcekVdnsD1uIpmgRqfTbQWJ2qxvQkcdeFhcotn4= +sigs.k8s.io/controller-runtime v0.1.10/go.mod h1:HFAYoOh6XMV+jKF1UjFwrknPbowfyHEHHRdJMf2jMX8= +sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/main.go b/main.go new file mode 100644 index 0000000..e770995 --- /dev/null +++ b/main.go @@ -0,0 +1,9 @@ +package main + +import ( + "github.com/yabslabs/runner/common/logging" +) + +func main() { + logging.WithID("YABS-Runner-000").Info("runner started") +} diff --git a/runner/runner.go b/runner/runner.go new file mode 100644 index 0000000..133c37b --- /dev/null +++ b/runner/runner.go @@ -0,0 +1,13 @@ +package runner + +// RunnerStatus that represents the Status of a Runner +type RunnerStatus int + +// RunnerStatus implementation as enum +const ( + UNKNOWN RunnerStatus = iota + ACTIVE + PAUSED + ONLINE + OFFLINE +)