mirror of
https://github.com/danielgormly/drone-plugin-kube.git
synced 2026-06-04 18:23:48 +08:00
Restructured testing, print fatal errors
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
PLUGIN_SERVER=
|
||||
PLUGIN_CA=
|
||||
PLUGIN_TOKEN=
|
||||
PLUGIN_TEMPLATE=
|
||||
PLUGIN_NAME=
|
||||
PLUGIN_COMMIT=
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
vendor
|
||||
build/kubano
|
||||
test
|
||||
test.sh
|
||||
.env
|
||||
.DS_Store
|
||||
.env
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
go build -o build/kubano
|
||||
export $(cat .env | xargs) && ./build/kubano
|
||||
|
||||
# docker run --env-file=.env drone-kubano
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user