Skip to content

Commit

Permalink
Don't lose test configuration when running skaffold fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nkubala committed Nov 7, 2018
1 parent 5cb8824 commit 6e5b0da
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/skaffold/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func getBuilder(cfg *latest.BuildConfig, kubeContext string) (build.Builder, err
}
}

func getTester(cfg *[]*latest.TestCase) (test.Tester, error) {
func getTester(cfg *latest.TestConfig) (test.Tester, error) {
return test.NewTester(cfg)
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type SkaffoldPipeline struct {
Kind string `yaml:"kind"`

Build BuildConfig `yaml:"build,omitempty"`
Test []*TestCase `yaml:"test,omitempty"`
Test TestConfig `yaml:"test,omitempty"`
Deploy DeployConfig `yaml:"deploy,omitempty"`
Profiles []Profile `yaml:"profiles,omitempty"`
}
Expand Down Expand Up @@ -133,6 +133,8 @@ type AzureContainerBuild struct {
TenantID string `yaml:"tenantId,omitempty"`
}

type TestConfig []*TestCase

// TestCase is a struct containing all the specified test
// configuration for an image.
type TestCase struct {
Expand Down Expand Up @@ -237,7 +239,7 @@ type Artifact struct {
type Profile struct {
Name string `yaml:"name,omitempty"`
Build BuildConfig `yaml:"build,omitempty"`
Test []*TestCase `yaml:"test,omitempty"`
Test TestConfig `yaml:"test,omitempty"`
Deploy DeployConfig `yaml:"deploy,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func applyProfile(config *latest.SkaffoldPipeline, profile latest.Profile) {
Kind: config.Kind,
Build: overlayProfileField(config.Build, profile.Build).(latest.BuildConfig),
Deploy: overlayProfileField(config.Deploy, profile.Deploy).(latest.DeployConfig),
Test: overlayProfileField(config.Test, profile.Test).([]*latest.TestCase),
Test: overlayProfileField(config.Test, profile.Test).(latest.TestConfig),
}
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/skaffold/schema/v1alpha4/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ type SkaffoldPipeline struct {
Kind string `yaml:"kind"`

Build BuildConfig `yaml:"build,omitempty"`
Test []TestCase `yaml:"test,omitempty"`
Test TestConfig `yaml:"test,omitempty"`
Deploy DeployConfig `yaml:"deploy,omitempty"`
Profiles []Profile `yaml:"profiles,omitempty"`
}

type TestConfig []TestCase

func (c *SkaffoldPipeline) GetVersion() string {
return c.APIVersion
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/skaffold/schema/v1alpha4/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ func (config *SkaffoldPipeline) Upgrade() (util.VersionedConfig, error) {
return nil, errors.Wrap(err, "converting new build")
}

// convert Test (should be the same)
var newTest next.TestConfig
if err := convert(config.Test, &newTest); err != nil {
return nil, errors.Wrap(err, "converting new test")
}

return &next.SkaffoldPipeline{
APIVersion: next.Version,
Kind: config.Kind,
Deploy: newDeploy,
Build: newBuild,
Test: newTest,
Deploy: newDeploy,
Profiles: newProfiles,
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
// NewTester parses the provided test cases from the Skaffold config,
// and returns a Tester instance with all the necessary test runners
// to run all specified tests.
func NewTester(testCases *[]*latest.TestCase) (Tester, error) {
func NewTester(testCases *latest.TestConfig) (Tester, error) {
// TODO(nkubala): copied this from runner.getDeployer(), this should be moved somewhere else
cwd, err := os.Getwd()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/test/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Tester interface {
// FullTester should always be the ONLY implementation of the Tester interface;
// newly added testing implementations should implement the Runner interface.
type FullTester struct {
testCases *[]*latest.TestCase
testCases *latest.TestConfig
workingDir string
}

Expand Down

0 comments on commit 6e5b0da

Please sign in to comment.