Restructured testing, print fatal errors

This commit is contained in:
Daniel
2019-05-29 12:13:39 +10:00
parent 2c759b39e6
commit 144da236dc
7 changed files with 39 additions and 7 deletions
+6
View File
@@ -0,0 +1,6 @@
PLUGIN_SERVER=
PLUGIN_CA=
PLUGIN_TOKEN=
PLUGIN_TEMPLATE=
PLUGIN_NAME=
PLUGIN_COMMIT=
+1 -3
View File
@@ -1,6 +1,4 @@
vendor
build/kubano
test
test.sh
.env
.DS_Store
.env
+1 -1
View File
@@ -24,7 +24,7 @@ Add the following [build step](https://docs.drone.io/user-guide/pipeline/steps/)
## Deployment templates
Deployment config files are first interpreted by **aymerick/raymond** ([handlebarsjs](http://handlebarsjs.com/) equivalent). You can use all available raymond expressions and anything you put in settings prefixed with the PLUGIN_* environment variables e.g. `{{PLUGIN.NAMESPACE}}`. See [example/deployment.template.yaml](/example/deployment.template.yaml) for a complete example.
Deployment config files are first interpreted by **aymerick/raymond** ([handlebarsjs](http://handlebarsjs.com/) equivalent). You can use all available raymond expressions and anything you put in settings will be made available in your deployment template e.g. `{{namespace}}`. See [example/deployment.template.yaml](/example/deployment.template.yaml) for a complete example.
#### Adding a service account to Kubernetes that can manage deployments
See [example/Role.yaml](example/Role.yaml), [example/ServiceAccount.yaml](example/ServiceAccount.yaml), [example/RoleBinding.yaml](example/RoleBinding.yaml).
+1 -1
View File
@@ -20,6 +20,6 @@ func main() {
fmt.Printf(os.Getenv("PLUGIN_SKIP_TLS"))
err := plugin.Exec()
if err != nil {
log.Fatal(err)
log.Fatalf("Fatal error: \n%s", err)
}
}
+3 -2
View File
@@ -63,7 +63,8 @@ func (p Plugin) Exec() error {
}
// Parse template
depYaml, err := raymond.Render(string(raw), ctx)
fmt.Printf("%s", depYaml)
fmt.Printf("Updating deployment template: \n%s", depYaml)
if err != nil {
panic(err)
}
@@ -73,6 +74,6 @@ func (p Plugin) Exec() error {
log.Fatal(err.Error())
}
deployment := CreateDeploymentObj(depYaml)
UpdateDeployment(clientset, p.KubeConfig.Namespace, deployment)
err = UpdateDeployment(clientset, p.KubeConfig.Namespace, deployment)
return err
}
Executable
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
go build -o build/kubano
export $(cat .env | xargs) && ./build/kubano
# docker run --env-file=.env drone-kubano
+21
View File
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{name}}
spec:
selector:
matchLabels:
app: {{name}}
replicas: 1
template:
metadata:
labels:
app: {{name}}
spec:
containers:
- name: nginx
image: 10.0.0.24:443/test:example.{{commit}}
ports:
- containerPort: 80
imagePullSecrets:
- name: regcred