GitOps for k8s
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

generate.go 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // +build ignore
  2. package main
  3. import (
  4. "fmt"
  5. "io/ioutil"
  6. "log"
  7. "net/http"
  8. "os"
  9. "github.com/shurcooL/vfsgen"
  10. "github.com/fluxcd/flux/install"
  11. )
  12. func main() {
  13. usage := func() {
  14. fmt.Fprintf(os.Stderr, "usage: %s {embedded-templates,deploy}\n", os.Args[0])
  15. os.Exit(1)
  16. }
  17. if len(os.Args) != 2 {
  18. usage()
  19. }
  20. switch os.Args[1] {
  21. case "embedded-templates":
  22. var fs http.FileSystem = http.Dir("templates/")
  23. err := vfsgen.Generate(fs, vfsgen.Options{
  24. Filename: "generated_templates.gogen.go",
  25. PackageName: "install",
  26. VariableName: "templates",
  27. })
  28. if err != nil {
  29. log.Fatalln(err)
  30. }
  31. case "deploy":
  32. params := install.TemplateParameters{
  33. GitURL: "git@github.com:weaveworks/flux-get-started",
  34. GitBranch: "master",
  35. }
  36. manifests, err := install.FillInTemplates(params)
  37. if err != nil {
  38. fmt.Fprintf(os.Stderr, "error: failed to fill in templates: %s\n", err)
  39. os.Exit(1)
  40. }
  41. for fileName, contents := range manifests {
  42. if err := ioutil.WriteFile(fileName, contents, 0600); err != nil {
  43. fmt.Fprintf(os.Stderr, "error: failed to write deploy file %s: %s\n", fileName, err)
  44. os.Exit(1)
  45. }
  46. }
  47. default:
  48. usage()
  49. }
  50. }