Skip to content

Commit

Permalink
Support exporting CircleCI pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuGongpu committed Jul 22, 2020
1 parent 9d26446 commit bf49be9
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
4 changes: 3 additions & 1 deletion internal/cmdexport/cmdexport.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
"sort"
"strings"

"github.com/spf13/cobra"

"github.com/GoogleContainerTools/kpt/internal/cmdexport/orchestrators"
"github.com/GoogleContainerTools/kpt/internal/cmdexport/types"
"github.com/GoogleContainerTools/kpt/internal/docs/generated/fndocs"
"github.com/spf13/cobra"
)

// The `kpt fn export` command.
Expand Down Expand Up @@ -137,6 +138,7 @@ func supportedOrchestrators() map[string]orchestrators.Pipeline {
"gitlab-ci": new(orchestrators.GitLabCI),
"jenkins": new(orchestrators.Jenkins),
"tekton": new(orchestrators.TektonPipeline),
"circleci": new(orchestrators.CircleCI),
}
}

Expand Down
68 changes: 66 additions & 2 deletions internal/cmdexport/cmdexport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ var testCases = []TestCase{
{
description: "fails on not providing working orchestrator",
params: []string{"dir"},
err: "--workflow flag is required. It must be one of cloud-build, github-actions, gitlab-ci, jenkins, tekton",
err: "--workflow flag is required. It must be one of circleci, cloud-build, github-actions, gitlab-ci, jenkins, tekton",
},
{
description: "fails on an unsupported workflow orchestrator",
params: []string{".", "--workflow", "random-orchestrator"},
err: "unsupported orchestrator random-orchestrator. It must be one of cloud-build, github-actions, gitlab-ci, jenkins, tekton",
err: "unsupported orchestrator random-orchestrator. It must be one of circleci, cloud-build, github-actions, gitlab-ci, jenkins, tekton",
},
{
description: "exports a GitHub Actions pipeline",
Expand Down Expand Up @@ -276,6 +276,70 @@ pipeline {
}
}
}
`,
},
{
description: "exports a CircleCI workflow",
params: []string{
"resources",
"-w",
"circleci",
},
expected: `
version: "2.1"
orbs:
kpt:
executors:
kpt-container:
docker:
- image: gongpu/kpt:latest
commands:
kpt-fn-run:
steps:
- run: kpt fn run resources
jobs:
run-functions:
executor: kpt-container
steps:
- setup_remote_docker
- kpt-fn-run
workflows:
main:
jobs:
- kpt/run-functions
`,
},
{
description: "exports a CircleCI workflow with fn-path",
params: []string{
"resources",
"--fn-path",
"config/functions.yaml",
"-w",
"circleci",
},
expected: `
version: "2.1"
orbs:
kpt:
executors:
kpt-container:
docker:
- image: gongpu/kpt:latest
commands:
kpt-fn-run:
steps:
- run: kpt fn run resources --fn-path config/functions.yaml
jobs:
run-functions:
executor: kpt-container
steps:
- setup_remote_docker
- kpt-fn-run
workflows:
main:
jobs:
- kpt/run-functions
`,
},
}
Expand Down

0 comments on commit bf49be9

Please sign in to comment.