Skip to content

Commit

Permalink
use template for pipeline config generation (#4160)
Browse files Browse the repository at this point in the history
* first pass - adding gh template

* gh completed

* azdo template

* cspell

* pin cspell version due to issue on last release

* add snapshot for pipelines

* more
  • Loading branch information
vhvb1989 authored Aug 3, 2024
1 parent 49a0b64 commit c56e342
Show file tree
Hide file tree
Showing 16 changed files with 896 additions and 155 deletions.
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

0 comments on commit c56e342

Please sign in to comment.