Skip to content

Commit

Permalink
Merge pull request #35 from uselagoon/route-ids
Browse files Browse the repository at this point in the history
add command to generate and return all routes
  • Loading branch information
shreddedbacon authored May 22, 2022
2 parents d95d006 + 0bf1ee5 commit 210bde7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cmd/identify_ingress.go
Original file line number Diff line number Diff line change
@@ -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"},
Expand All @@ -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
Expand Down Expand Up @@ -126,4 +153,5 @@ func generateRoutes(lagoonEnvVars []lagoon.EnvironmentVariable,

func init() {
identifyCmd.AddCommand(primaryIngressIdentify)
identifyCmd.AddCommand(ingressIdentify)
}

0 comments on commit 210bde7

Please sign in to comment.