diff --git a/cmd/identify_ingress.go b/cmd/identify_ingress.go index 1a69b64c..6c97a7d3 100644 --- a/cmd/identify_ingress.go +++ b/cmd/identify_ingress.go @@ -1,12 +1,19 @@ package cmd import ( + "encoding/json" "fmt" "github.com/spf13/cobra" "github.com/uselagoon/build-deploy-tool/internal/lagoon" ) +type ingressIdentifyJSON struct { + primary string `json:"primary"` + secondary []string `json:"secondary"` + autogenerated []string `json:"autogenerated"` +} + var primaryIngressIdentify = &cobra.Command{ Use: "primary-ingress", Aliases: []string{"pi"}, @@ -21,6 +28,26 @@ var primaryIngressIdentify = &cobra.Command{ }, } +var ingressIdentify = &cobra.Command{ + Use: "ingress", + Aliases: []string{"i"}, + Short: "Identify all ingress for a specific environment", + RunE: func(cmd *cobra.Command, args []string) error { + primary, secondary, autogen, err := IdentifyPrimaryIngress(false) + if err != nil { + return err + } + ret := ingressIdentifyJSON{ + primary: primary, + secondary: secondary, + autogenerated: autogen, + } + retJSON, _ := json.Marshal(ret) + fmt.Println(string(retJSON)) + return nil + }, +} + // IdentifyPrimaryIngress . func IdentifyPrimaryIngress(debug bool) (string, []string, []string, error) { activeEnv := false @@ -126,4 +153,5 @@ func generateRoutes(lagoonEnvVars []lagoon.EnvironmentVariable, func init() { identifyCmd.AddCommand(primaryIngressIdentify) + identifyCmd.AddCommand(ingressIdentify) }