in cmd/setupgh.go [24:75]
func newSetUpCmd() *cobra.Command {
sc := &providers.SetUpCmd{}
// setup-ghCmd represents the setup-gh command
var cmd = &cobra.Command{
Use: "setup-gh",
Short: "Automates the Github OIDC setup process",
Long: `This command will automate the Github OIDC setup process by creating an Azure Active Directory
application and service principle, and will configure that application to trust github.`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
gh := providers.NewGhClient()
azCred, err := cred.GetCred()
if err != nil {
return fmt.Errorf("getting credentials: %w", err)
}
az, err := providers.NewAzClient(azCred)
if err != nil {
return fmt.Errorf("creating azure client: %w", err)
}
sc.AzClient = az
err = fillSetUpConfig(sc, gh, az)
if err != nil {
return fmt.Errorf("filling setup config: %w", err)
}
s := spinner.CreateSpinner("--> Setting up Github OIDC...")
s.Start()
err = runProviderSetUp(ctx, sc, s, gh, az)
s.Stop()
if err != nil {
return err
}
log.Info("Draft has successfully set up Github OIDC for your project 😃")
log.Info("Use 'draft generate-workflow' to generate a Github workflow to build and deploy an application on AKS.")
return nil
},
}
f := cmd.Flags()
f.StringVarP(&sc.AppName, "app", "a", emptyDefaultFlagValue, "specify the Azure Active Directory application name")
f.StringVarP(&sc.SubscriptionID, "subscription-id", "s", emptyDefaultFlagValue, "specify the Azure subscription ID")
f.StringVarP(&sc.ResourceGroupName, "resource-group", "r", emptyDefaultFlagValue, "specify the Azure resource group name")
f.StringVarP(&sc.Repo, "gh-repo", "g", emptyDefaultFlagValue, "specify the github repository link")
sc.Provider = provider
return cmd
}