Skip to content

Commit 9ea2b6e

Browse files
committed
refactor: move CI workflow to pkg/ci/github
The CI workflow generation lived in cmd/ci/, tightly coupled to the command layer via viper flag reads and direct file I/O. This made it impossible to reuse or test the generator independently. Move workflow generation, printing, and writing into pkg/ci/github/ as a self-contained package. Introduce CI and PathWriter interfaces in pkg/functions/client.go so the client can orchestrate workflow generation without depending on the cmd layer. The cmd/config_ci.go command now resolves flags and delegates to client.GenerateCIWorkflow(). Also fix typos: --patform → --platform, functionl → function, proivdes → provides, precldes → precedes, sevices → services, suppot → support, Desribe → Describe, pipilines → pipelines, intance → instance. Issue #3256 Signed-off-by: Stanislav Jakuschevskij <sjakusch@redhat.com>
1 parent 40d337d commit 9ea2b6e

19 files changed

Lines changed: 4917 additions & 5399 deletions

cmd/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ func (c buildConfig) buildOptions() (oo []fn.BuildOption, err error) {
501501
if c.Platform != "" {
502502
parts := strings.Split(c.Platform, "/")
503503
if len(parts) != 2 {
504-
return oo, fmt.Errorf("the value for --patform must be in the form [OS]/[Architecture]. eg \"linux/amd64\"")
504+
return oo, fmt.Errorf("the value for --platform must be in the form [OS]/[Architecture]. eg \"linux/amd64\"")
505505
}
506506
oo = append(oo, fn.BuildWithPlatforms([]fn.Platform{{OS: parts[0], Architecture: parts[1]}}))
507507
}

cmd/ci/config.go

Lines changed: 0 additions & 292 deletions
This file was deleted.

cmd/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77

88
"github.com/ory/viper"
9+
"knative.dev/func/pkg/ci/github"
910
"knative.dev/func/pkg/keda"
1011

1112
"knative.dev/func/cmd/prompt"
@@ -78,6 +79,7 @@ func NewClient(cfg ClientConfig, options ...fn.Option) (*fn.Client, func()) {
7879
docker.WithCredentialsProvider(c),
7980
docker.WithTransport(t),
8081
docker.WithVerbose(cfg.Verbose))),
82+
fn.WithCI(github.NewWorkflowGenerator(cfg.Verbose)),
8183
}
8284
)
8385

cmd/config.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ import (
88
"github.com/ory/viper"
99
"github.com/spf13/cobra"
1010

11-
"knative.dev/func/cmd/ci"
1211
"knative.dev/func/cmd/common"
1312
"knative.dev/func/pkg/config"
1413
fn "knative.dev/func/pkg/functions"
1514
)
1615

1716
func NewConfigCmd(
1817
loaderSaver common.FunctionLoaderSaver,
19-
writer ci.WorkflowWriter,
18+
pathWriter fn.PathWriter,
2019
currentBranch common.CurrentBranchFunc,
2120
workingDir common.WorkDirFunc,
2221
newClient ClientFactory,
@@ -47,8 +46,14 @@ or from the directory specified with --path.
4746
cmd.AddCommand(NewConfigEnvsCmd(loaderSaver))
4847
cmd.AddCommand(NewConfigVolumesCmd())
4948

50-
if os.Getenv(ci.ConfigCIFeatureFlag) == "true" {
51-
cmd.AddCommand(NewConfigCICmd(loaderSaver, writer, currentBranch, workingDir))
49+
if os.Getenv(ConfigCIFeatureFlag) == "true" {
50+
cmd.AddCommand(NewConfigCICmd(
51+
loaderSaver,
52+
pathWriter,
53+
currentBranch,
54+
workingDir,
55+
newClient,
56+
))
5257
}
5358

5459
return cmd

0 commit comments

Comments
 (0)