/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
	"github.com/spf13/cobra"
	"github.com/tidbcloud/auto-deploy/internal"
)

var destroyO11yAzureRegionArgs = internal.DestroyAzureRegionK8sArgs{}

// destroyO11yAzureRegionCmd represents the destroy-azure-region-k8s command
var destroyO11yAzureRegionCmd = &cobra.Command{
	Use:   "destroy-o11y-azure-region",
	Short: "Destroy O11y Azure region after deploy",
	Long: `Destroy O11y Azure region after deploy

For example:
deploy-cli destroy-o11y-azure-region                                                                 \
  --region-name eastus                                                                               \
  --cloud-region eastus                                                                              \
  --meta-uri https://devautodeploymeta.blob.core.windows.net/meta/dedicated-regions/eastus/meta.yaml \
  --tenant-id 6c865c34-8ff8-4792-bbca-8c9d15efb29d                                                   \
  --subscription-id 85b598b9-a080-4476-bc96-ba89e64f92d1                                             \
  --client-id 6c865c34-8ff8-4792-bbca-8c9d15efb29d                                                   \
`,
	RunE: func(cmd *cobra.Command, _ []string) error {
		destroyO11yAzureRegionArgs.InstanceName = instance
		destroyO11yAzureRegionArgs.OidcProviderType = oidcProvider
		return internal.DestroyO11yAzureRegionK8s(destroyO11yAzureRegionArgs)
	},
}

func init() {
	rootCmd.AddCommand(destroyO11yAzureRegionCmd)
	destroyO11yAzureRegionCmd.Flags().StringVarP(&destroyO11yAzureRegionArgs.RegionName, "region-name", "n", "", "Deployed region name")
	destroyO11yAzureRegionCmd.Flags().StringVarP(&destroyO11yAzureRegionArgs.MetaURI, "meta-uri", "", "", "Where to store or read metadata of this region")
	destroyO11yAzureRegionCmd.Flags().StringVar(&destroyO11yAzureRegionArgs.TenantId, "tenant-id", "", "Tenant id to destory k8s")
	destroyO11yAzureRegionCmd.Flags().StringVar(&destroyO11yAzureRegionArgs.SubscriptionId, "subscription-id", "", "Subscription id to destory k8s")
	destroyO11yAzureRegionCmd.Flags().StringVar(&destroyO11yAzureRegionArgs.ClientId, "client-id", "", "Client id to destory k8s")
	destroyO11yAzureRegionCmd.Flags().StringVarP(&destroyO11yAzureRegionArgs.Region, "cloud-region", "r", "", "Azure location to destroy k8s, for example: eastus")

	// mark required flag
	for _, flag := range []string{"region-name", "meta-uri", "role-arn", "cloud-region", "tenant-id", "subscription-id", "client-id"} {
		destroyO11yAzureRegionCmd.MarkFlagRequired(flag)
	}
}
