Commit 8a22345e authored by lukasburgey's avatar lukasburgey
Browse files

Merge branch 'dev'

parents 69339277 35c8c2ac
Pipeline #88046 passed with stages
in 1 minute and 22 seconds
image: golang:1.13-alpine
stages: stages:
- lint - lint
- build - build
- deploy - deploy
lint: lint:
image: golang:1.12-alpine
stage: lint stage: lint
script: script:
- apk add --no-cache git make - apk add --no-cache git make
- make lint - make lint
build: build:
image: golang:1.12-alpine
stage: build stage: build
script: script:
- apk add --no-cache git make - apk add --no-cache git make
- make build-static - make build-static
- ./feudalClient --version
artifacts: artifacts:
paths: paths:
- feudalClient - feudalClient
# this needs a volume mounted to the docker runner like so: # this needs a volume mounted to the docker runner like so:
# volumes = ["/path/to/binaries:/deployDestination:rw"] # volumes = ["/path/to/binaries:/deployDestination:rw"]
deploy-dev: deploy-dev:
stage: deploy stage: deploy
only: only:
...@@ -33,6 +32,20 @@ deploy-dev: ...@@ -33,6 +32,20 @@ deploy-dev:
dependencies: dependencies:
- build - build
script: script:
- ls /deployDestination - mkdir -p /deployDestination/dev
- cp feudalClient /deployDestination/dev
- date -Iseconds > /deployDestination/dev/lastCIDeploy
# this needs a volume mounted to the docker runner like so:
# volumes = ["/path/to/binaries:/deployDestination:rw"]
deploy-master:
stage: deploy
only:
- master
environment:
name: master
dependencies:
- build
script:
- cp feudalClient /deployDestination - cp feudalClient /deployDestination
- date -Iseconds > /deployDestination/lastCIDeploy - date -Iseconds > /deployDestination/lastCIDeploy
PROJECT_NAME := "feudalClient" PROJECT_NAME := feudalClient
PKG := "git.scc.kit.edu/feudal/$(PROJECT_NAME)" PKG := "git.scc.kit.edu/feudal/$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
VERSION := $(shell git describe --tags) VERSION := $(shell git describe --tags)
SCRIPT_VERSION := $(shell cat go.mod | grep feudalScripts | awk '{print $$2}') SCRIPT_VERSION := $(shell cat go.mod | grep feudalScripts | awk '{print $$2}')
LDFLAGS := "-X 'main.version=$(VERSION)' -X 'main.scriptsVersion=$(SCRIPT_VERSION)'" LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.scriptsVersion=$(SCRIPT_VERSION)'
.PHONY: all dep build clean test lint .PHONY: all dep build clean test lint
...@@ -22,11 +21,11 @@ test: ## Run unittests ...@@ -22,11 +21,11 @@ test: ## Run unittests
# link dynamically # link dynamically
build: dep go.mod ## Build the binary file build: dep go.mod ## Build the binary file
go build -i -v -ldflags=$(LDFLAGS) $(PKG) go build -v -ldflags="$(LDFLAGS)" .
# link statically # link statically
build-static: dep go.mod ## Build the binary file build-static: dep go.mod ## Build the binary file
@CGO_ENABLED=0 GOOS=linux go build -v -ldflags='$(LDFLAGS) -extldflags -static' $(PKG) CGO_ENABLED=0 GOOS=linux go build -v -ldflags="$(LDFLAGS) -extldflags '-static'" .
clean: ## Remove previous build clean: ## Remove previous build
@rm -f $(PROJECT_NAME) @rm -f $(PROJECT_NAME)
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"log" "log"
"git.scc.kit.edu/feudal/feudalClient/config" "git.scc.kit.edu/feudal/feudalClient/config"
"git.scc.kit.edu/feudal/feudalScripts/v2" scripts "git.scc.kit.edu/feudal/feudalScripts/v3"
) )
type ( type (
...@@ -31,7 +31,7 @@ type ( ...@@ -31,7 +31,7 @@ type (
Service config.Service `json:"service"` Service config.Service `json:"service"`
// Optional Answers by the users. Must have the same keys as the related Questionnaire // Optional Answers by the users. Must have the same keys as the related Questionnaire
Answers map[string]string `json:"answers,omitempty"` Answers map[string]interface{} `json:"answers,omitempty"`
} }
// Reply is used to patch the fields of the DeploymentState // Reply is used to patch the fields of the DeploymentState
...@@ -52,6 +52,11 @@ type ( ...@@ -52,6 +52,11 @@ type (
// Maps a question name to a description of the question // Maps a question name to a description of the question
Questionnaire map[string]string `json:"questionnaire,omitempty"` Questionnaire map[string]string `json:"questionnaire,omitempty"`
// Questionnaire requested by the script
// Ignored when State is not Questionnaire
// Maps a question name to a description of the question
QuestionnaireAnswers map[string]interface{} `json:"questionnaire_answers,omitempty"`
// Credentials for the user // Credentials for the user
// Ignored when State is not Deployed // Ignored when State is not Deployed
// Maps a credential name to a credential value // Maps a credential name to a credential value
......
module git.scc.kit.edu/feudal/feudalClient module git.scc.kit.edu/feudal/feudalClient
require ( require (
git.scc.kit.edu/feudal/feudalScripts/v2 v2.0.0 git.scc.kit.edu/feudal/feudalScripts/v3 v3.0.2
github.com/alecthomas/jsonschema v0.0.0-20190122210438-a6952de1bbe6 github.com/alecthomas/jsonschema v0.0.0-20190122210438-a6952de1bbe6
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
...@@ -11,6 +11,8 @@ require ( ...@@ -11,6 +11,8 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.1.0 github.com/xeipuuv/gojsonschema v1.1.0
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/tools v0.0.0-20200430040329-4b814e061378 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/yaml.v2 v2.2.5 gopkg.in/yaml.v2 v2.2.5
) )
......
git.scc.kit.edu/feudal/feudalScripts/v2 v2.0.0 h1:3907HJ9XEZSuEZ0oAuijssG9SGFjAdmyDt8P7SlFFZY= git.scc.kit.edu/feudal/feudalScripts/v3 v3.0.0 h1:MvwKkIynre4Rg5zVaKwpFXv50fXxpXkZglrZ2yacnKQ=
git.scc.kit.edu/feudal/feudalScripts/v2 v2.0.0/go.mod h1:EVXrOHOlnw3VZ02LZQDSN7bxldpJ7p31tfKZ5zqAEXA= git.scc.kit.edu/feudal/feudalScripts/v3 v3.0.0/go.mod h1:rj5YO36zT8JfJK5PDMhjq+zKKGF9pxq8anyW7GbzkP4=
git.scc.kit.edu/feudal/feudalScripts/v3 v3.0.1-0.20200501173837-ae08b1d51119 h1:wp7TWn6ojR8Lk+2+AVDPS4QscUGgjp6Bk6nbXkP2h9E=
git.scc.kit.edu/feudal/feudalScripts/v3 v3.0.1-0.20200501173837-ae08b1d51119/go.mod h1:rj5YO36zT8JfJK5PDMhjq+zKKGF9pxq8anyW7GbzkP4=
git.scc.kit.edu/feudal/feudalScripts/v3 v3.0.1 h1:h1tNd6ZM68WyspHKqVAJa2NP2bBw6uZ/tsfYGPM+puA=
git.scc.kit.edu/feudal/feudalScripts/v3 v3.0.1/go.mod h1:rj5YO36zT8JfJK5PDMhjq+zKKGF9pxq8anyW7GbzkP4=
git.scc.kit.edu/feudal/feudalScripts/v3 v3.0.2 h1:pbsvaLoFBY+lQWjgJS/tPPl06ez/glOlB2VrBcFfPgw=
git.scc.kit.edu/feudal/feudalScripts/v3 v3.0.2/go.mod h1:rj5YO36zT8JfJK5PDMhjq+zKKGF9pxq8anyW7GbzkP4=
github.com/alecthomas/jsonschema v0.0.0-20190122210438-a6952de1bbe6 h1:xadBCbc8D9mmkaNfCsEBHbIoCjbayJXJNsY1JjPjNio= github.com/alecthomas/jsonschema v0.0.0-20190122210438-a6952de1bbe6 h1:xadBCbc8D9mmkaNfCsEBHbIoCjbayJXJNsY1JjPjNio=
github.com/alecthomas/jsonschema v0.0.0-20190122210438-a6952de1bbe6/go.mod h1:qpebaTNSsyUn5rPSJMsfqEtDw71TTggXM6stUDI16HA= github.com/alecthomas/jsonschema v0.0.0-20190122210438-a6952de1bbe6/go.mod h1:qpebaTNSsyUn5rPSJMsfqEtDw71TTggXM6stUDI16HA=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
...@@ -23,6 +29,29 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo ...@@ -23,6 +29,29 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.1.0 h1:ngVtJC9TY/lg0AA/1k48FYhBrhRoFlEmWzsehpNAaZg= github.com/xeipuuv/gojsonschema v1.1.0 h1:ngVtJC9TY/lg0AA/1k48FYhBrhRoFlEmWzsehpNAaZg=
github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7 h1:EBZoQjiKKPaLbPrbpssUfuHtwM6KV/vb4U85g/cigFY=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200430040329-4b814e061378 h1:9PP65Qh7XP8c0HOR8HZXX5mlFDjSC/BMYUGNokeqEjM=
golang.org/x/tools v0.0.0-20200430040329-4b814e061378/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"os" "os"
"git.scc.kit.edu/feudal/feudalClient/config" "git.scc.kit.edu/feudal/feudalClient/config"
"git.scc.kit.edu/feudal/feudalScripts/v2" scripts "git.scc.kit.edu/feudal/feudalScripts/v3"
"github.com/alecthomas/jsonschema" "github.com/alecthomas/jsonschema"
"github.com/xeipuuv/gojsonschema" "github.com/xeipuuv/gojsonschema"
) )
......
...@@ -15,7 +15,7 @@ import ( ...@@ -15,7 +15,7 @@ import (
"git.scc.kit.edu/feudal/feudalClient/config" "git.scc.kit.edu/feudal/feudalClient/config"
deps "git.scc.kit.edu/feudal/feudalClient/deployments" deps "git.scc.kit.edu/feudal/feudalClient/deployments"
"git.scc.kit.edu/feudal/feudalClient/indent" "git.scc.kit.edu/feudal/feudalClient/indent"
scripts "git.scc.kit.edu/feudal/feudalScripts/v2" scripts "git.scc.kit.edu/feudal/feudalScripts/v3"
) )
type ( type (
...@@ -158,7 +158,12 @@ func (sink *Sink) handleDep(dep deps.Dep) (output scripts.Output, err error) { ...@@ -158,7 +158,12 @@ func (sink *Sink) handleDep(dep deps.Dep) (output scripts.Output, err error) {
dep.Log("Output: %s", indent.Indent(stdoutBytes)) dep.Log("Output: %s", indent.Indent(stdoutBytes))
} }
err = json.Unmarshal(stdoutBytes, &output) err = scripts.UnmarshalOutput(stdoutBytes, &output)
if err != nil {
return
}
err = scripts.SanityCheck(&input, &output)
if err != nil { if err != nil {
return return
} }
...@@ -208,6 +213,7 @@ func (sink *Sink) depHandler() { ...@@ -208,6 +213,7 @@ func (sink *Sink) depHandler() {
} }
if output.Questionnaire != nil && output.State == scripts.Questionnaire { if output.Questionnaire != nil && output.State == scripts.Questionnaire {
reply.Questionnaire = output.Questionnaire reply.Questionnaire = output.Questionnaire
reply.QuestionnaireAnswers = output.QuestionnaireAnswers
} }
if output.Credentials != nil && output.State == scripts.Deployed { if output.Credentials != nil && output.State == scripts.Deployed {
reply.Credentials = output.Credentials reply.Credentials = output.Credentials
...@@ -262,7 +268,10 @@ func (sink *Sink) sendReply(reply deps.Reply) (err error) { ...@@ -262,7 +268,10 @@ func (sink *Sink) sendReply(reply deps.Reply) (err error) {
body = []byte{} body = []byte{}
} }
if resp.StatusCode != 200 { if resp.StatusCode == 404 {
reply.Log("sendReply failed: (status: %v, body: %s), will not retry!", resp.StatusCode, body)
return
} else if resp.StatusCode != 200 {
err = fmt.Errorf("sendReply failed: (status: %v, body: %s)", resp.StatusCode, body) err = fmt.Errorf("sendReply failed: (status: %v, body: %s)", resp.StatusCode, body)
return return
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment