2019-12-03 17:50:15 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-12-09 17:56:02 +00:00
|
|
|
"github.com/kelseyhightower/envconfig"
|
2019-12-03 17:50:15 +00:00
|
|
|
"os"
|
|
|
|
|
2019-12-09 17:56:02 +00:00
|
|
|
"github.com/pelotech/drone-helm3/internal/helm"
|
2019-12-03 17:50:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2019-12-09 17:56:02 +00:00
|
|
|
var c helm.Config
|
2019-12-03 17:50:15 +00:00
|
|
|
|
2019-12-09 17:56:02 +00:00
|
|
|
if err := envconfig.Process("plugin", &c); err != nil {
|
2019-12-03 17:50:15 +00:00
|
|
|
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
2019-12-09 17:56:02 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make the plan
|
|
|
|
plan, err := helm.NewPlan(c)
|
|
|
|
if err != nil {
|
2019-12-16 23:46:37 +00:00
|
|
|
fmt.Fprintf(os.Stderr, "%w\n", err)
|
|
|
|
os.Exit(1)
|
2019-12-03 17:50:15 +00:00
|
|
|
}
|
|
|
|
|
2019-12-09 17:56:02 +00:00
|
|
|
// Execute the plan
|
|
|
|
err = plan.Execute()
|
2019-12-05 22:35:25 +00:00
|
|
|
|
2019-12-09 17:56:02 +00:00
|
|
|
// Expect the plan to go off the rails
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, err.Error())
|
|
|
|
// Throw away the plan
|
|
|
|
os.Exit(1)
|
2019-12-05 22:35:25 +00:00
|
|
|
}
|
2019-12-03 17:50:15 +00:00
|
|
|
}
|