Skip to content

Commit

Permalink
Merge pull request #2927 from corneliusweig/w/update-linter
Browse files Browse the repository at this point in the history
Bump golangci-lint to v0.19.0
  • Loading branch information
balopat authored Sep 25, 2019
2 parents 8d4135b + 1980e31 commit 207ccf9
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 69 deletions.
20 changes: 10 additions & 10 deletions pkg/skaffold/schema/v1alpha2/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
// 3. Updates
// - KanikoBuildContext instead of GCSBucket
// - HelmRelease.valuesFilePath -> valuesFiles in yaml
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
// convert Deploy (should be the same)
var newDeploy next.DeployConfig
pkgutil.CloneThroughJSON(config.Deploy, &newDeploy)
pkgutil.CloneThroughJSON(c.Deploy, &newDeploy)

// if the helm deploy config was set, then convert ValueFilePath to ValuesFiles
if oldHelmDeploy := config.Deploy.DeployType.HelmDeploy; oldHelmDeploy != nil {
if oldHelmDeploy := c.Deploy.DeployType.HelmDeploy; oldHelmDeploy != nil {
for i, oldHelmRelease := range oldHelmDeploy.Releases {
if oldHelmRelease.ValuesFilePath != "" {
newDeploy.DeployType.HelmDeploy.Releases[i].ValuesFiles = []string{oldHelmRelease.ValuesFilePath}
Expand All @@ -45,12 +45,12 @@ func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {

// convert Profiles (should be the same)
var newProfiles []next.Profile
if config.Profiles != nil {
pkgutil.CloneThroughJSON(config.Profiles, &newProfiles)
if c.Profiles != nil {
pkgutil.CloneThroughJSON(c.Profiles, &newProfiles)
}

// if the helm deploy config was set for a profile, then convert ValueFilePath to ValuesFiles
for p, oldProfile := range config.Profiles {
for p, oldProfile := range c.Profiles {
if oldProfileHelmDeploy := oldProfile.Deploy.DeployType.HelmDeploy; oldProfileHelmDeploy != nil {
for i, oldProfileHelmRelease := range oldProfileHelmDeploy.Releases {
if oldProfileHelmRelease.ValuesFilePath != "" {
Expand All @@ -61,12 +61,12 @@ func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
}

// convert Build (different only for kaniko)
oldKanikoBuilder := config.Build.KanikoBuild
config.Build.KanikoBuild = nil
oldKanikoBuilder := c.Build.KanikoBuild
c.Build.KanikoBuild = nil

// copy over old build config to new build config
var newBuild next.BuildConfig
pkgutil.CloneThroughJSON(config.Build, &newBuild)
pkgutil.CloneThroughJSON(c.Build, &newBuild)

// if the kaniko build was set, then convert it
if oldKanikoBuilder != nil {
Expand All @@ -83,7 +83,7 @@ func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {

return &next.SkaffoldConfig{
APIVersion: next.Version,
Kind: config.Kind,
Kind: c.Kind,
Deploy: newDeploy,
Build: newBuild,
Profiles: newProfiles,
Expand Down
14 changes: 7 additions & 7 deletions pkg/skaffold/schema/v1alpha3/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,30 @@ import (
// - Artifact.imageName -> image, workspace -> context in yaml
// - DockerArtifact.dockerfilePath -> dockerfile in yaml
// - BazelArtifact.BuildTarget is optional in yaml
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
// convert Deploy (should be the same)
var newDeploy next.DeployConfig
pkgutil.CloneThroughJSON(config.Deploy, &newDeploy)
pkgutil.CloneThroughJSON(c.Deploy, &newDeploy)

// convert Profiles (should be the same)
var newProfiles []next.Profile
if config.Profiles != nil {
pkgutil.CloneThroughJSON(config.Profiles, &newProfiles)
if c.Profiles != nil {
pkgutil.CloneThroughJSON(c.Profiles, &newProfiles)

for i, oldProfile := range config.Profiles {
for i, oldProfile := range c.Profiles {
convertBuild(oldProfile.Build, newProfiles[i].Build)
}
}

// convert Build (should be the same)
var newBuild next.BuildConfig
oldBuild := config.Build
oldBuild := c.Build
pkgutil.CloneThroughJSON(oldBuild, &newBuild)
convertBuild(oldBuild, newBuild)

return &next.SkaffoldConfig{
APIVersion: next.Version,
Kind: config.Kind,
Kind: c.Kind,
Deploy: newDeploy,
Build: newBuild,
Profiles: newProfiles,
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1alpha4/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (
// 2. No removal
// 3. Updates
// - minor - []TestCase type aliased to TestConfig
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
8 changes: 4 additions & 4 deletions pkg/skaffold/schema/v1alpha5/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ import (
// 2. Removals:
// - AzureContainerBuilder
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
if config.Build.AzureContainerBuild != nil {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
if c.Build.AzureContainerBuild != nil {
return nil, errors.Errorf("can't upgrade to %s, build.acr is not supported anymore, please remove it manually", next.Version)
}

for _, profile := range config.Profiles {
for _, profile := range c.Profiles {
if profile.Build.AzureContainerBuild != nil {
return nil, errors.Errorf("can't upgrade to %s, profiles.build.acr is not supported anymore, please remove it from the %s profile manually", next.Version, profile.Name)
}
}

var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1beta1/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
// Kaniko AdditionalFlags
// 2. No removals
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1beta10/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
// - GitTagger variants `TreeSha` and `AbbrevTreeSha`
// 2. No removals
// 3. No Updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1beta11/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
// 1. No Additions
// 2. No removals
// 3. No Updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1beta12/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
// 1. No Additions
// 2. No removals
// 3. No Updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/skaffold/schema/v1beta13/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
// jibGradle builder
// jibMaven profile removed
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
if err := util.UpgradePipelines(config, &newConfig, upgradeOnePipeline); err != nil {
pkgutil.CloneThroughJSON(c, &newConfig)
if err := util.UpgradePipelines(c, &newConfig, upgradeOnePipeline); err != nil {
return nil, err
}
newConfig.APIVersion = next.Version
Expand Down
6 changes: 3 additions & 3 deletions pkg/skaffold/schema/v1beta14/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
// buildArgs for Kustomize deployer
// 2. Removals:
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
if err := util.UpgradePipelines(config, &newConfig, upgradeOnePipeline); err != nil {
pkgutil.CloneThroughJSON(c, &newConfig)
if err := util.UpgradePipelines(c, &newConfig, upgradeOnePipeline); err != nil {
return nil, err
}
newConfig.APIVersion = next.Version
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1beta2/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
// kaniko docker config
// 2. No removals
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1beta3/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
// profile activation
// 2. No removals
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1beta4/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import (
// jibGradle flags
// 2. No removals
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1beta5/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
// helm deployFlags
// 2. No removals
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
18 changes: 9 additions & 9 deletions pkg/skaffold/schema/v1beta6/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,34 @@ import (
// 2. No removals
// 3. Updates:
// kaniko becomes cluster
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
// convert Deploy (should be the same)
var newDeploy next.DeployConfig
pkgutil.CloneThroughJSON(config.Deploy, &newDeploy)
pkgutil.CloneThroughJSON(c.Deploy, &newDeploy)

// convert Profiles (should be the same)
var newProfiles []next.Profile
if config.Profiles != nil {
pkgutil.CloneThroughJSON(config.Profiles, &newProfiles)
if c.Profiles != nil {
pkgutil.CloneThroughJSON(c.Profiles, &newProfiles)
}

// Update profile if kaniko build exists
for i, p := range config.Profiles {
for i, p := range c.Profiles {
upgradeKanikoBuild(p.Build, &newProfiles[i].Build)
}

// convert Kaniko if needed
var newBuild next.BuildConfig
pkgutil.CloneThroughJSON(config.Build, &newBuild)
upgradeKanikoBuild(config.Build, &newBuild)
pkgutil.CloneThroughJSON(c.Build, &newBuild)
upgradeKanikoBuild(c.Build, &newBuild)

// convert Test (should be the same)
var newTest []*next.TestCase
pkgutil.CloneThroughJSON(config.Test, &newTest)
pkgutil.CloneThroughJSON(c.Test, &newTest)

return &next.SkaffoldConfig{
APIVersion: next.Version,
Kind: config.Kind,
Kind: c.Kind,
Build: newBuild,
Test: newTest,
Deploy: newDeploy,
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/v1beta7/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
// kaniko/resource requirements
// 2. No removals
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

return &newConfig, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/skaffold/schema/v1beta8/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import (
// gitTagger/variant
// 2. Removed all schemas associated with builder plugins
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

if err := util.UpgradePipelines(config, &newConfig, upgradeOnePipeline); err != nil {
if err := util.UpgradePipelines(c, &newConfig, upgradeOnePipeline); err != nil {
return nil, err
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/skaffold/schema/v1beta9/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ var (
// 2. No removals
// 3. Updates:
// - sync map becomes a list of sync rules
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
func (c *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig

pkgutil.CloneThroughJSON(config, &newConfig)
pkgutil.CloneThroughJSON(c, &newConfig)
newConfig.APIVersion = next.Version

if err := util.UpgradePipelines(config, &newConfig, upgradeOnePipeline); err != nil {
if err := util.UpgradePipelines(c, &newConfig, upgradeOnePipeline); err != nil {
return nil, err
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/skaffold/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,19 @@ func matchSyncRules(syncRules []*latest.SyncRule, relPath, containerWd string) (
return dsts, nil
}

func (k *podSyncer) Sync(ctx context.Context, s *Item) error {
if len(s.Copy) > 0 {
logrus.Infoln("Copying files:", s.Copy, "to", s.Image)
func (s *podSyncer) Sync(ctx context.Context, item *Item) error {
if len(item.Copy) > 0 {
logrus.Infoln("Copying files:", item.Copy, "to", item.Image)

if err := Perform(ctx, s.Image, s.Copy, k.copyFileFn, k.namespaces); err != nil {
if err := Perform(ctx, item.Image, item.Copy, s.copyFileFn, s.namespaces); err != nil {
return errors.Wrap(err, "copying files")
}
}

if len(s.Delete) > 0 {
logrus.Infoln("Deleting files:", s.Delete, "from", s.Image)
if len(item.Delete) > 0 {
logrus.Infoln("Deleting files:", item.Delete, "from", item.Image)

if err := Perform(ctx, s.Image, s.Delete, k.deleteFileFn, k.namespaces); err != nil {
if err := Perform(ctx, item.Image, item.Delete, s.deleteFileFn, s.namespaces); err != nil {
return errors.Wrap(err, "deleting files")
}
}
Expand Down

0 comments on commit 207ccf9

Please sign in to comment.