Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use template for pipeline config generation #4160

Merged
1 change: 1 addition & 0 deletions cli/azd/.vscode/cspell-azd-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,5 @@ webfrontend
westus2
wireinject
yacspin
ymlt
zerr
6 changes: 4 additions & 2 deletions cli/azd/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"go.lintTool": "golangci-lint",
"go.testTimeout": "10m",
"files.associations": {
"*.bicept": "go-template"
}
"*.bicept": "go-template",
"*.yamlt": "go-template",
"*.ymlt": "go-template"
}
}
43 changes: 41 additions & 2 deletions cli/azd/pkg/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package pipeline

import (
"context"
"fmt"
"maps"
"path/filepath"
"slices"
Expand Down Expand Up @@ -161,8 +162,6 @@ func mergeProjectVariablesAndSecrets(
const (
gitHubDisplayName string = "GitHub"
azdoDisplayName string = "Azure DevOps"
gitHubLabel string = "github"
azdoLabel string = "azdo"
envPersistedKey string = "AZD_PIPELINE_PROVIDER"
defaultPipelineFileName string = "azure-dev.yml"
gitHubDirectory string = ".github"
Expand All @@ -175,3 +174,43 @@ var (
gitHubYml string = filepath.Join(gitHubWorkflowsDirectory, defaultPipelineFileName)
azdoYml string = filepath.Join(azdoPipelinesDirectory, defaultPipelineFileName)
)

type ciProviderType string

const (
ciProviderGitHubActions ciProviderType = "github"
ciProviderAzureDevOps ciProviderType = "azdo"
)

func toCiProviderType(provider string) (ciProviderType, error) {
result := ciProviderType(provider)
if result == ciProviderGitHubActions || result == ciProviderAzureDevOps {
return result, nil
}
return "", fmt.Errorf("invalid ci provider type %s", provider)
}

type infraProviderType string

const (
infraProviderBicep infraProviderType = "bicep"
infraProviderTerraform infraProviderType = "terraform"
infraProviderUndefined infraProviderType = ""
)

func toInfraProviderType(provider string) (infraProviderType, error) {
result := infraProviderType(provider)
if result == infraProviderBicep || result == infraProviderTerraform || result == infraProviderUndefined {
return result, nil
}
return "", fmt.Errorf("invalid infra provider type %s", provider)
}

type projectProperties struct {
CiProvider ciProviderType
InfraProvider infraProviderType
RepoRoot string
HasAppHost bool
BranchName string
AuthType PipelineAuthType
}
Loading
Loading