Skip to content

Commit

Permalink
fix: Fix Parameterizer overwrite warning (#612)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashok Pon Kumar <[email protected]>
  • Loading branch information
ashokponkumar authored Oct 29, 2021
1 parent 2ca27c2 commit 3e9dceb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions transformer/classes/kubernetes/parameterizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package kubernetes

import (
"io/ioutil"
"path/filepath"

"github.com/konveyor/move2kube/environment"
Expand Down Expand Up @@ -69,21 +70,26 @@ func (t *Parameterizer) Transform(newArtifacts []transformertypes.Artifact, oldA
}
for _, a := range newArtifacts {
yamlsPath := a.Paths[artifacts.KubernetesYamlsPathType][0]
destPath := yamlsPath + "-parameterized"
tempPath, err := ioutil.TempDir(t.Env.TempPath, "*")
if err != nil {
logrus.Errorf("Unable to create temp dir : %s", err)
}
baseDirName := filepath.Base(yamlsPath) + "-parameterized"
destPath := filepath.Join(tempPath, baseDirName)
filesWritten, err := parameterizer.Parameterize(yamlsPath, destPath, parameterizertypes.PackagingSpecPathT{}, ps)
if err != nil {
logrus.Errorf("Unable to parameterize : %s", err)
}
for _, f := range filesWritten {
rel, err := filepath.Rel(t.Env.GetEnvironmentOutput(), f)
rel, err := filepath.Rel(destPath, f)
if err != nil {
logrus.Errorf("Unable to make parameterized file path relative : %s", err)
continue
}
pathMappings = append(pathMappings, transformertypes.PathMapping{
Type: transformertypes.DefaultPathMappingType,
SrcPath: f,
DestPath: rel,
DestPath: filepath.Join(filepath.Dir(yamlsPath), baseDirName, rel),
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion transformer/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func processPathMappings(pms []transformertypes.PathMapping, sourcePath, outputP
}
default:
if !copiedDefaultDests[getpair(pm.SrcPath, pm.DestPath)] {
if err := filesystem.Merge(pm.SrcPath, destPath, true); err != nil {
if err := filesystem.Merge(pm.SrcPath, destPath, false); err != nil {
logrus.Errorf("Error while copying sourcepath for %+v", pm)
}
copiedDefaultDests[getpair(pm.SrcPath, pm.DestPath)] = true
Expand Down

0 comments on commit 3e9dceb

Please sign in to comment.