-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
41 lines (36 loc) · 1.02 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
Copyright © 2022 Andre Kruger
*/
package cmd
import (
"fmt"
"strings"
"github.com/AndreGKruger/k8generate/internal/generate/service"
"github.com/spf13/cobra"
)
var (
Appname string
Serviceport string
Appenv string
Namespace string
)
// serviceCmd represents the service command
var serviceCmd = &cobra.Command{
Use: "service",
Short: "Generates a k8_service.yaml file",
Long: `The service command generates a k8_service.yaml file.
The file is generated in the directory ./kubernetes/{Appenv}/k8_service.yaml
For example: kubernetes/production/k8_service.yaml .`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("generating kubernetes service file ...")
s := service.New(strings.ToLower(Appname), strings.ToLower(Serviceport), strings.ToLower(Appenv), strings.ToLower(Namespace))
err := s.Generate()
if err != nil {
fmt.Println(err)
}
fmt.Printf("kubernetes service file generated at ./kubernetes/%s/k8_service.yaml", Appenv)
},
}
func init() {
rootCmd.AddCommand(serviceCmd)
}