Skip to content

chore: remove v1 config package and move it to latest package. #7290

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

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ to be submitted.

Some changes to the skaffold code require a change to the skaffold config. These changes require a few extra steps:

* Open the latest Config at [pkg/skaffold/schema/latest/v1/config.go](https://github.com/GoogleContainerTools/skaffold/blob/main/pkg/skaffold/schema/latest/v1/config.go) and inspect the comment at [L28](https://github.com/GoogleContainerTools/skaffold/blob/main/pkg/skaffold/schema/latest/v1/config.go#L28)
* Open the latest Config at [pkg/skaffold/schema/latest/config.go](https://github.com/GoogleContainerTools/skaffold/blob/main/pkg/skaffold/schema/latest/config.go) and inspect the comment at [L28](https://github.com/GoogleContainerTools/skaffold/blob/main/pkg/skaffold/schema/latest/config.go#L28)
* If the line mentions the config version is not released, proceed making your changes.
```
// This config version is not yet released, it is SAFE TO MODIFY the structs in this file.
Expand Down
8 changes: 4 additions & 4 deletions cmd/skaffold/app/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/flags"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
)

Expand Down Expand Up @@ -95,10 +95,10 @@ func doBuild(ctx context.Context, out io.Writer) error {
})
}

func targetArtifacts(opts config.SkaffoldOptions, configs []util.VersionedConfig) []*latestV1.Artifact {
var targetArtifacts []*latestV1.Artifact
func targetArtifacts(opts config.SkaffoldOptions, configs []util.VersionedConfig) []*latest.Artifact {
var targetArtifacts []*latest.Artifact
for _, cfg := range configs {
for _, artifact := range cfg.(*latestV1.SkaffoldConfig).Build.Artifacts {
for _, artifact := range cfg.(*latest.SkaffoldConfig).Build.Artifacts {
if opts.IsTargetImage(artifact) {
targetArtifacts = append(targetArtifacts, artifact)
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/skaffold/app/cmd/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner/runcontext"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
"github.com/GoogleContainerTools/skaffold/testutil"
)
Expand All @@ -38,7 +38,7 @@ type mockRunner struct {
runner.Runner
}

func (r *mockRunner) Build(ctx context.Context, out io.Writer, artifacts []*latestV1.Artifact) ([]graph.Artifact, error) {
func (r *mockRunner) Build(ctx context.Context, out io.Writer, artifacts []*latest.Artifact) ([]graph.Artifact, error) {
out.Write([]byte("Build Completed"))
return []graph.Artifact{{
ImageName: "gcr.io/skaffold/example",
Expand All @@ -52,7 +52,7 @@ func (r *mockRunner) Stop() error {

func TestTagFlag(t *testing.T) {
mockCreateRunner := func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return &mockRunner{}, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
return &mockRunner{}, []util.VersionedConfig{&latest.SkaffoldConfig{}}, nil, nil
}

testutil.Run(t, "override tag with argument", func(t *testutil.T) {
Expand All @@ -71,7 +71,7 @@ func TestTagFlag(t *testing.T) {

func TestQuietFlag(t *testing.T) {
mockCreateRunner := func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return &mockRunner{}, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
return &mockRunner{}, []util.VersionedConfig{&latest.SkaffoldConfig{}}, nil, nil
}

tests := []struct {
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestQuietFlag(t *testing.T) {

func TestFileOutputFlag(t *testing.T) {
mockCreateRunner := func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return &mockRunner{}, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
return &mockRunner{}, []util.VersionedConfig{&latest.SkaffoldConfig{}}, nil, nil
}

tests := []struct {
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestRunBuild(t *testing.T) {
return nil, nil, nil, errors.New("some error")
}
mockCreateRunner := func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return &mockRunner{}, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
return &mockRunner{}, []util.VersionedConfig{&latest.SkaffoldConfig{}}, nil, nil
}

tests := []struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/skaffold/app/cmd/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner/runcontext"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
"github.com/GoogleContainerTools/skaffold/testutil"
)
Expand All @@ -50,7 +50,7 @@ func TestDebugIndependentFromDev(t *testing.T) {
mockRunner := &mockDevRunner{}
testutil.Run(t, "DevDebug", func(t *testutil.T) {
t.Override(&createRunner, func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return mockRunner, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
return mockRunner, []util.VersionedConfig{&latest.SkaffoldConfig{}}, nil, nil
})
t.Override(&opts, config.SkaffoldOptions{})
t.Override(&doDev, func(context.Context, io.Writer) error {
Expand Down
6 changes: 3 additions & 3 deletions cmd/skaffold/app/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/tips"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
)

Expand All @@ -50,9 +50,9 @@ func doDeploy(ctx context.Context, out io.Writer) error {
if opts.SkipRender {
return r.DeployAndLog(ctx, out, []graph.Artifact{})
}
var artifacts []*latestV1.Artifact
var artifacts []*latest.Artifact
for _, cfg := range configs {
artifacts = append(artifacts, cfg.(*latestV1.SkaffoldConfig).Build.Artifacts...)
artifacts = append(artifacts, cfg.(*latest.SkaffoldConfig).Build.Artifacts...)
}
buildArtifacts, err := getBuildArtifactsAndSetTags(artifacts, r.ApplyDefaultRepo)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions cmd/skaffold/app/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output/log"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
)

Expand Down Expand Up @@ -61,12 +61,12 @@ func runDev(ctx context.Context, out io.Writer) error {
case <-ctx.Done():
return nil
default:
// Note: The latestV1.SkaffoldConfig is used for both latestV1 schema and latestV2 schema because
// the latestV1 and latestV2 use the same Build struct. Ideally they should be separated.
// Note: The latest.SkaffoldConfig is used for both latest schema and latestV2 schema because
// the latest and latestV2 use the same Build struct. Ideally they should be separated.
err := withRunner(ctx, out, func(r runner.Runner, configs []util.VersionedConfig) error {
var artifacts []*latestV1.Artifact
var artifacts []*latest.Artifact
for _, cfg := range configs {
artifacts = append(artifacts, cfg.(*latestV1.SkaffoldConfig).Build.Artifacts...)
artifacts = append(artifacts, cfg.(*latest.SkaffoldConfig).Build.Artifacts...)
}
err := r.Dev(ctx, out, artifacts)

Expand Down
10 changes: 5 additions & 5 deletions cmd/skaffold/app/cmd/dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner/runcontext"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
"github.com/GoogleContainerTools/skaffold/testutil"
)
Expand All @@ -38,7 +38,7 @@ type mockDevRunner struct {
calls []string
}

func (r *mockDevRunner) Dev(context.Context, io.Writer, []*latestV1.Artifact) error {
func (r *mockDevRunner) Dev(context.Context, io.Writer, []*latest.Artifact) error {
r.calls = append(r.calls, "Dev")
return r.errDev
}
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestDoDev(t *testing.T) {
errDev: context.Canceled,
}
t.Override(&createRunner, func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return mockRunner, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
return mockRunner, []util.VersionedConfig{&latest.SkaffoldConfig{}}, nil, nil
})
t.Override(&opts, config.SkaffoldOptions{
Cleanup: true,
Expand All @@ -118,7 +118,7 @@ type mockConfigChangeRunner struct {
cycles int
}

func (m *mockConfigChangeRunner) Dev(context.Context, io.Writer, []*latestV1.Artifact) error {
func (m *mockConfigChangeRunner) Dev(context.Context, io.Writer, []*latest.Artifact) error {
m.cycles++
if m.cycles == 1 {
// pass through the first cycle with a config reload
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestDevConfigChange(t *testing.T) {
mockRunner := &mockConfigChangeRunner{}

t.Override(&createRunner, func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return mockRunner, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
return mockRunner, []util.VersionedConfig{&latest.SkaffoldConfig{}}, nil, nil
})
t.Override(&opts, config.SkaffoldOptions{
Cleanup: true,
Expand Down
6 changes: 3 additions & 3 deletions cmd/skaffold/app/cmd/diagnose.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/parser"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner/runcontext"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
schemaUtil "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/version"
Expand Down Expand Up @@ -67,7 +67,7 @@ func doDiagnose(ctx context.Context, out io.Writer) error {
}
// remove the dependency config references since they have already been imported and will be marshalled together.
for i := range configs {
configs[i].(*latestV1.SkaffoldConfig).Dependencies = nil
configs[i].(*latest.SkaffoldConfig).Dependencies = nil
}
buf, err := yaml.MarshalWithSeparator(configs)
if err != nil {
Expand All @@ -84,7 +84,7 @@ func printArtifactDiagnostics(ctx context.Context, out io.Writer, configs []sche
return fmt.Errorf("getting run context: %w", err)
}
for _, c := range configs {
config := c.(*latestV1.SkaffoldConfig)
config := c.(*latest.SkaffoldConfig)
fmt.Fprintln(out, "Skaffold version:", version.Get().GitCommit)
fmt.Fprintln(out, "Configuration version:", config.APIVersion)
fmt.Fprintln(out, "Number of artifacts:", len(config.Build.Artifacts))
Expand Down
10 changes: 5 additions & 5 deletions cmd/skaffold/app/cmd/diagnose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner/runcontext"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
"github.com/GoogleContainerTools/skaffold/testutil"
)
Expand Down Expand Up @@ -64,17 +64,17 @@ metadata:
t.Override(&yamlOnly, test.yamlOnly)
t.Override(&getCfgs, func(context.Context, config.SkaffoldOptions) ([]util.VersionedConfig, error) {
return []util.VersionedConfig{
&latestV1.SkaffoldConfig{
&latest.SkaffoldConfig{
APIVersion: "testVersion",
Kind: "Config",
Metadata: latestV1.Metadata{
Metadata: latest.Metadata{
Name: "config1",
},
},
&latestV1.SkaffoldConfig{
&latest.SkaffoldConfig{
APIVersion: "testVersion",
Kind: "Config",
Metadata: latestV1.Metadata{
Metadata: latest.Metadata{
Name: "config2",
},
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/skaffold/app/cmd/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubernetes/debugging"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubernetes/manifest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
)

Expand Down Expand Up @@ -97,7 +97,7 @@ func getInsecureRegistries(opts config.SkaffoldOptions, configs []util.Versioned

regList = append(regList, opts.InsecureRegistries...)
for _, cfg := range configs {
regList = append(regList, cfg.(*latestV1.SkaffoldConfig).Build.InsecureRegistries...)
regList = append(regList, cfg.(*latest.SkaffoldConfig).Build.InsecureRegistries...)
}
regList = append(regList, cfgRegistries...)
insecureRegistries := make(map[string]bool, len(regList))
Expand Down
4 changes: 2 additions & 2 deletions cmd/skaffold/app/cmd/find_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output/log"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/walk"
)

Expand Down Expand Up @@ -67,7 +67,7 @@ func doFindConfigs(ctx context.Context, out io.Writer) error {
pathOutLen, versionOutLen := 70, 30
for p, v := range pathToVersion {
c := output.Default
if v != latestV1.Version {
if v != latest.Version {
c = output.Green
}
c.Fprintf(out, fmt.Sprintf("%%-%ds\t%%-%ds\n", pathOutLen, versionOutLen), p, v)
Expand Down
10 changes: 5 additions & 5 deletions cmd/skaffold/app/cmd/find_configs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"testing"

latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/v1beta7"
"github.com/GoogleContainerTools/skaffold/testutil"
)
Expand All @@ -33,22 +33,22 @@ func TestFindConfigs(t *testing.T) {
}{
{
files: map[string]string{
"valid.yml": validYaml(latestV1.Version),
"valid.yml": validYaml(latest.Version),
"upgradeable.yaml": validYaml(v1beta7.Version),
"invalid.yaml": invalidYaml(),
},
expected: map[string]string{
"valid.yml": latestV1.Version,
"valid.yml": latest.Version,
"upgradeable.yaml": v1beta7.Version,
},
},
{
files: map[string]string{
"valid.yaml": validYaml(latestV1.Version),
"valid.yaml": validYaml(latest.Version),
"invalid.yaml": invalidYaml(),
},
expected: map[string]string{
"valid.yaml": latestV1.Version,
"valid.yaml": latest.Version,
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/skaffold/app/cmd/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/parser"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/validation"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/yaml"
)
Expand All @@ -47,7 +47,7 @@ func NewCmdFix() *cobra.Command {
WithCommonFlags().
WithFlags([]*Flag{
{Value: &overwrite, Name: "overwrite", DefValue: false, Usage: "Overwrite original config with fixed config"},
{Value: &toVersion, Name: "version", DefValue: latestV1.Version, Usage: "Target schema version to upgrade to"},
{Value: &toVersion, Name: "version", DefValue: latest.Version, Usage: "Target schema version to upgrade to"},
{Value: &fixOutputPath, Name: "output", Shorthand: "o", DefValue: "", Usage: "File to write the changed config (instead of standard output)"},
}).
NoArgs(doFix)
Expand Down Expand Up @@ -96,11 +96,11 @@ func fix(out io.Writer, configFile, outFile string, toVersion string) error {

// TODO(dgageot): We should be able run validations on any schema version
// but that's not the case. They can only run on the latest version for now.
if toVersion == latestV1.Version {
if toVersion == latest.Version {
var cfgs parser.SkaffoldConfigSet
for _, cfg := range versionedCfgs {
cfgs = append(cfgs, &parser.SkaffoldConfigEntry{
SkaffoldConfig: cfg.(*latestV1.SkaffoldConfig),
SkaffoldConfig: cfg.(*latest.SkaffoldConfig),
SourceFile: configFile,
IsRootConfig: true})
}
Expand Down
Loading