Skip to content

Commit

Permalink
refactor: exclude .git, updateImageTags & devImage
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianKramm committed Mar 16, 2022
1 parent a66cb3f commit bed0dae
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ func (cmd *InitCmd) addDevConfig(config *latest.Config, imageName, image string,
}, replacePodPatches...)
}

config.Dev["default"].ReplaceImage = fmt.Sprintf("loftsh/%s:latest", language)
config.Dev["default"].DevImage = fmt.Sprintf("loftsh/%s:latest", language)
config.Dev["default"].Patches = replacePodPatches
}

Expand Down
31 changes: 15 additions & 16 deletions pkg/devspace/config/versions/latest/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,11 @@ type CustomConfigCommand struct {

// DeploymentConfig defines the configuration how the devspace should be deployed
type DeploymentConfig struct {
Name string `yaml:"name" json:"name"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
Helm *HelmConfig `yaml:"helm,omitempty" json:"helm,omitempty"`
Kubectl *KubectlConfig `yaml:"kubectl,omitempty" json:"kubectl,omitempty"`
Name string `yaml:"name" json:"name"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
UpdateImageTags bool `yaml:"updateImageTags,omitempty" json:"updateImageTags,omitempty"`
Helm *HelmConfig `yaml:"helm,omitempty" json:"helm,omitempty"`
Kubectl *KubectlConfig `yaml:"kubectl,omitempty" json:"kubectl,omitempty"`
}

// ComponentConfig holds the component information
Expand Down Expand Up @@ -659,11 +660,10 @@ type RollingUpdateConfig struct {

// HelmConfig defines the specific helm options used during deployment
type HelmConfig struct {
Chart *ChartConfig `yaml:"chart,omitempty" json:"chart,omitempty"`
Values map[string]interface{} `yaml:"values,omitempty" json:"values,omitempty"`
ValuesFiles []string `yaml:"valuesFiles,omitempty" json:"valuesFiles,omitempty"`
ReplaceImageTags bool `yaml:"replaceImageTags,omitempty" json:"replaceImageTags,omitempty"`
DisplayOutput bool `yaml:"displayOutput,omitempty" json:"output,omitempty"`
Chart *ChartConfig `yaml:"chart,omitempty" json:"chart,omitempty"`
Values map[string]interface{} `yaml:"values,omitempty" json:"values,omitempty"`
ValuesFiles []string `yaml:"valuesFiles,omitempty" json:"valuesFiles,omitempty"`
DisplayOutput bool `yaml:"displayOutput,omitempty" json:"output,omitempty"`

TemplateArgs []string `yaml:"templateArgs,omitempty" json:"templateArgs,omitempty"`
UpgradeArgs []string `yaml:"upgradeArgs,omitempty" json:"upgradeArgs,omitempty"`
Expand All @@ -682,12 +682,11 @@ type ChartConfig struct {

// KubectlConfig defines the specific kubectl options used during deployment
type KubectlConfig struct {
Manifests []string `yaml:"manifests,omitempty" json:"manifests,omitempty"`
Kustomize *bool `yaml:"kustomize,omitempty" json:"kustomize,omitempty"`
KustomizeArgs []string `yaml:"kustomizeArgs,omitempty" json:"kustomizeArgs,omitempty"`
ReplaceImageTags bool `yaml:"replaceImageTags,omitempty" json:"replaceImageTags,omitempty"`
CreateArgs []string `yaml:"createArgs,omitempty" json:"createArgs,omitempty"`
ApplyArgs []string `yaml:"applyArgs,omitempty" json:"applyArgs,omitempty"`
Manifests []string `yaml:"manifests,omitempty" json:"manifests,omitempty"`
Kustomize *bool `yaml:"kustomize,omitempty" json:"kustomize,omitempty"`
KustomizeArgs []string `yaml:"kustomizeArgs,omitempty" json:"kustomizeArgs,omitempty"`
CreateArgs []string `yaml:"createArgs,omitempty" json:"createArgs,omitempty"`
ApplyArgs []string `yaml:"applyArgs,omitempty" json:"applyArgs,omitempty"`

KustomizeBinaryPath string `yaml:"kustomizeBinaryPath,omitempty" json:"kustomizeBinaryPath,omitempty"`
KubectlBinaryPath string `yaml:"kubectlBinaryPath,omitempty" json:"kubectlBinaryPath,omitempty"`
Expand Down Expand Up @@ -728,7 +727,7 @@ type DevContainer struct {
Terminal *Terminal `yaml:"terminal,omitempty" json:"terminal,omitempty"`
Logs *Logs `yaml:"logs,omitempty" json:"logs,omitempty"`
Attach *Attach `yaml:"attach,omitempty" json:"attach,omitempty"`
ReplaceImage string `yaml:"replaceImage,omitempty" json:"replaceImage,omitempty"`
DevImage string `yaml:"devImage,omitempty" json:"devImage,omitempty"`
PersistPaths []PersistentPath `yaml:"persistPaths,omitempty" json:"persistPaths,omitempty"`
Sync []*SyncConfig `yaml:"sync,omitempty" json:"sync,omitempty" patchStrategy:"merge" patchMergeKey:"localSubPath"`
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/devspace/config/versions/v1beta11/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func (c *Config) Upgrade(log log.Logger) (config.Config, error) {
log.Warnf("deployments[*].helm.deleteArgs is not supported anymore in v6")
}
if deployment.Helm.ReplaceImageTags == nil || *deployment.Helm.ReplaceImageTags {
nextConfig.Deployments[name].Helm.ReplaceImageTags = true
nextConfig.Deployments[name].UpdateImageTags = true
}
} else if deployment.Kubectl != nil {
nextConfig.Deployments[name].Kubectl = &next.KubectlConfig{
Expand All @@ -448,7 +448,7 @@ func (c *Config) Upgrade(log log.Logger) (config.Config, error) {
log.Warnf("deployments[*].kubectl.deleteArgs is not supported anymore in v6")
}
if deployment.Kubectl.ReplaceImageTags == nil || *deployment.Kubectl.ReplaceImageTags {
nextConfig.Deployments[name].Kubectl.ReplaceImageTags = true
nextConfig.Deployments[name].UpdateImageTags = true
}
}
}
Expand Down Expand Up @@ -530,7 +530,7 @@ func (c *Config) mergeDevConfig(log log.Logger) (map[string]*next.DevPod, error)
}

devContainer := getMatchingDevContainer(devPod, replacePod.ContainerName)
devContainer.ReplaceImage = replacePod.ReplaceImage
devContainer.DevImage = replacePod.ReplaceImage
for _, p := range replacePod.PersistPaths {
nextPersistentPath := next.PersistentPath{
Path: p.Path,
Expand Down
6 changes: 3 additions & 3 deletions pkg/devspace/deploy/deployer/helm/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (d *DeployConfig) getDeploymentValues(ctx *devspacecontext.Context) (bool,
return false, nil, errors.Errorf("Couldn't deploy chart, error reading from chart values %s: %v", chartValuesPath, err)
}

if d.DeploymentConfig.Helm.ReplaceImageTags {
if d.DeploymentConfig.UpdateImageTags {
redeploy, err := legacy.ReplaceImageNames(overwriteValues, ctx.Config, ctx.Dependencies, nil)
if err != nil {
return false, nil, err
Expand All @@ -213,7 +213,7 @@ func (d *DeployConfig) getDeploymentValues(ctx *devspacecontext.Context) (bool,
}

// Replace image names
if d.DeploymentConfig.Helm.ReplaceImageTags {
if d.DeploymentConfig.UpdateImageTags {
redeploy, err := legacy.ReplaceImageNames(overwriteValuesFromPath, ctx.Config, ctx.Dependencies, nil)
if err != nil {
return false, nil, err
Expand All @@ -228,7 +228,7 @@ func (d *DeployConfig) getDeploymentValues(ctx *devspacecontext.Context) (bool,
// Load override values from data and merge them
if d.DeploymentConfig.Helm.Values != nil {
enableLegacy := false
if d.DeploymentConfig.Helm.ReplaceImageTags {
if d.DeploymentConfig.UpdateImageTags {
enableLegacy = true
}
redeploy, _, err := runtimevar.NewRuntimeResolver(ctx.WorkingDir, enableLegacy).FillRuntimeVariablesWithRebuild(ctx.Context, d.DeploymentConfig.Helm.Values, ctx.Config, ctx.Dependencies)
Expand Down
2 changes: 1 addition & 1 deletion pkg/devspace/deploy/deployer/kubectl/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (d *DeployConfig) getReplacedManifest(ctx *devspacecontext.Context, manifes
Namespace: resource.GetNamespace(),
})

if d.DeploymentConfig.Kubectl.ReplaceImageTags {
if d.DeploymentConfig.UpdateImageTags {
redeploy, err := legacy.ReplaceImageNamesStringMap(resource.Object, ctx.Config, ctx.Dependencies, map[string]bool{"image": true})
if err != nil {
return false, "", nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/devspace/devpod/devpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func needPodReplace(devPodConfig *latest.DevPod) bool {
}

func needPodReplaceContainer(devContainer *latest.DevContainer) bool {
if devContainer.ReplaceImage != "" {
if devContainer.DevImage != "" {
return true
}
if len(devContainer.PersistPaths) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/devspace/services/podreplace/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ func hashConfig(replacePod *latest.DevPod) (string, error) {
func replaceImagesInPodSpec(ctx *devspacecontext.Context, podSpec *corev1.PodSpec, devPod *latest.DevPod) error {
var err error
loader.EachDevContainer(devPod, func(devContainer *latest.DevContainer) bool {
if devContainer.ReplaceImage == "" {
if devContainer.DevImage == "" {
return true
}
err = replaceImageInPodSpec(ctx, podSpec, devPod.LabelSelector, devPod.ImageSelector, devContainer.Container, devContainer.ReplaceImage)
err = replaceImageInPodSpec(ctx, podSpec, devPod.LabelSelector, devPod.ImageSelector, devContainer.Container, devContainer.DevImage)
if err != nil {
return false
}
Expand Down
1 change: 1 addition & 0 deletions pkg/devspace/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func NewSync(ctx context.Context, localPath string, options Options) (*Sync, err

// We exclude the sync log to prevent an endless loop in upstream
options.ExcludePaths = append(options.ExcludePaths, ".devspace/")
options.ExcludePaths = append(options.ExcludePaths, ".git/")

// Create sync structure
s := &Sync{
Expand Down

0 comments on commit bed0dae

Please sign in to comment.