wip: Some changes
This commit is contained in:
@ -121,13 +121,11 @@ func (diff *Diff) Resolve(repositories repository.Repositories, path string) (lo
|
||||
// Delete the
|
||||
} else {
|
||||
reposWished[i] = repoWished
|
||||
logrus.Infof("%v -- %v", repoExisting, repoWished)
|
||||
i++
|
||||
}
|
||||
}
|
||||
reposWished = reposWished[:i]
|
||||
if !found {
|
||||
logrus.Infof("HERE I AM: %s", repoExisting)
|
||||
diff.DeletedRepositories = append(diff.DeletedRepositories, repoExisting)
|
||||
}
|
||||
}
|
||||
|
@ -134,23 +134,42 @@ func Generate(path string, gh githelper.Githelper) error {
|
||||
},
|
||||
ConfigMapGenerator: kustomize.CmGeneratorFromFiles(),
|
||||
}
|
||||
|
||||
if len(kustomize.Secrets) > 0 {
|
||||
kustomization.Generators = []string{"sec-generator.yaml"}
|
||||
if err := kustomize.SecGeneratorCreate(path); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
} else {
|
||||
if err := os.RemoveAll(fmt.Sprintf("%s/sec-generator.yaml", path)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
manifest, err := yaml.Marshal(kustomization)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
file, err := os.Create(path + "/kustomization.yaml")
|
||||
if err != nil {
|
||||
dstFilePath := path + "/kustomization.yaml"
|
||||
var dstFile *os.File
|
||||
if _, err = os.Stat(dstFilePath); err == nil {
|
||||
dstFile, err = os.Open(dstFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer dstFile.Close()
|
||||
} else if errors.Is(err, os.ErrNotExist) {
|
||||
dstFile, err = os.Create(dstFilePath)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer dstFile.Close()
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
if _, err := file.Write(manifest); err != nil {
|
||||
return err
|
||||
|
||||
if err := os.WriteFile(dstFilePath, manifest, os.ModeExclusive); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := gh.AddAllAndCommit(path, "Update the root kustomization"); err != nil {
|
||||
|
Reference in New Issue
Block a user