Commit 8873a29a authored by Muhammad Umair Khan's avatar Muhammad Umair Khan
Browse files

feat(meepctl): add optional <app> argument to deploy and delete core commands

parent c1e71474
Loading
Loading
Loading
Loading
+23 −8
Original line number Diff line number Diff line
@@ -43,12 +43,11 @@ const deleteExample = ` # Delete dependency containers

// deleteCmd represents the delete command
var deleteCmd = &cobra.Command{
	Use:       "delete <group>",
	Use:     "delete <group> [app]",
	Short:   "Delete containers from the K8s cluster",
	Long:    deleteDesc,
	Example: deleteExample,
	Args:      cobra.ExactValidArgs(1),
	ValidArgs: nil,
	Args:    cobra.RangeArgs(1, 2),
	Run:     deleteRun,
}

@@ -79,11 +78,19 @@ func deleteRun(cmd *cobra.Command, args []string) {
	}

	group := args[0]
	var targetApp string
	if len(args) > 1 {
		targetApp = args[1]
	}

	v, _ := cmd.Flags().GetBool("verbose")
	t, _ := cmd.Flags().GetBool("time")
	if v {
		fmt.Println("Delete called")
		fmt.Println("[arg]  group:", group)
		if targetApp != "" {
			fmt.Println("[arg]  app:", targetApp)
		}
		fmt.Println("[flag] verbose:", v)
		fmt.Println("[flag] time:", t)
	}
@@ -91,8 +98,16 @@ func deleteRun(cmd *cobra.Command, args []string) {
	start := time.Now()
	switch group {
	case "core":
		if targetApp != "" {
			k8sDelete(targetApp, cmd)
		} else {
			deleteApps(deleteData.coreApps, cmd)
		}
	case "dep":
		if targetApp != "" {
			fmt.Println("Error: Individual app deletion not supported for 'dep' group")
			return
		}
		deleteApps(deleteData.depApps, cmd)
	}

+66 −46
Original line number Diff line number Diff line
@@ -62,12 +62,11 @@ const deployExample = ` # Deploy AdvantEDGE dependencies

// deployCmd represents the deploy command
var deployCmd = &cobra.Command{
	Use:       "deploy <group>",
	Use:     "deploy <group> [app]",
	Short:   "Deploy containers on the K8s cluster",
	Long:    deployDesc,
	Example: deployExample,
	Args:      cobra.ExactValidArgs(1),
	ValidArgs: nil,
	Args:    cobra.RangeArgs(1, 2),
	Run:     deployRun,
}

@@ -107,6 +106,11 @@ func deployRun(cmd *cobra.Command, args []string) {
	}

	group := args[0]
	var targetApp string
	if len(args) > 1 {
		targetApp = args[1]
	}

	deployData.registry, _ = cmd.Flags().GetString("registry")
	deployData.tag, _ = cmd.Flags().GetString("tag")
	f, _ := cmd.Flags().GetBool("force")
@@ -115,6 +119,9 @@ func deployRun(cmd *cobra.Command, args []string) {
	if v {
		fmt.Println("Deploy called")
		fmt.Println("[arg]  group:", group)
		if targetApp != "" {
			fmt.Println("[arg]  app:", targetApp)
		}
		fmt.Println("[arg]  registry:", deployData.registry)
		fmt.Println("[arg]  tag:", deployData.tag)
		fmt.Println("[flag] force:", f)
@@ -141,8 +148,16 @@ func deployRun(cmd *cobra.Command, args []string) {
	// Deploy microservices
	switch group {
	case "core":
		if targetApp != "" {
			deploySingleApp(targetApp, cmd)
		} else {
			deployCore(cmd)
		}
	case "dep":
		if targetApp != "" {
			fmt.Println("Error: Individual app deployment not supported for 'dep' group")
			return
		}
		createCRD(cmd)
		deployDep(cmd)
	}
@@ -195,6 +210,12 @@ func deployCore(cobraCmd *cobra.Command) {
	deployCodeCovStorage(cobraCmd)

	for _, app := range deployData.coreApps {
		deploySingleApp(app, cobraCmd)
	}
}

// Deploy a single core app
func deploySingleApp(app string, cobraCmd *cobra.Command) {
	chart := deployData.gitdir + "/" + utils.RepoCfg.GetString("repo.core.go-apps."+app+".chart")
	codecov := utils.RepoCfg.GetBool("repo.core.go-apps." + app + ".codecov")
	onboardedapp := utils.RepoCfg.GetBool("repo.core.go-apps." + app + ".onboardedapp")
@@ -235,7 +256,6 @@ func deployCore(cobraCmd *cobra.Command) {

	k8sDeploy(app, chart, coreFlags, cobraCmd)
}
}

// Create CRDs
func createCRD(cobraCmd *cobra.Command) {