WIP: Trying to diff

This commit is contained in:
Nikolai Rodionov
2023-10-13 18:02:11 +02:00
parent eb7abefc89
commit 93ad3389b2
7 changed files with 109 additions and 20 deletions

View File

@ -24,7 +24,7 @@ func ReadTheConfig(path string) (*config.Config, error) {
return conf, nil
}
func Reconcile(definedWorkdirPath, sshKeyPath string, conf *config.Config, dry bool) error {
func Sync(definedWorkdirPath, sshKeyPath string, conf *config.Config, dry, diffArg bool) error {
// Start by creating a directory where everything should be happening
configPath := filepath.Dir(conf.ConfigPath)
workdirPath, err := workdir.CreateWorkdir(definedWorkdirPath)
@ -88,6 +88,14 @@ func Reconcile(definedWorkdirPath, sshKeyPath string, conf *config.Config, dry b
return err
}
if diffArg {
_, err := hh.PullChart(workdirPath, *release.RepositoryObj, release.Chart, release.Version)
if err != nil {
return err
}
hh.RenderChart(workdirPath, *release.RepositoryObj, release.Chart, release.Version)
}
if err := release.ValuesHandler(configPath); err != nil {
return err
}
@ -105,6 +113,12 @@ func Reconcile(definedWorkdirPath, sshKeyPath string, conf *config.Config, dry b
return err
}
if diffArg {
for _, releaseCurrent := range releasesCurrent {
hh.PullChart(workdirPath, *releaseCurrent.RepositoryObj, releaseCurrent.Chart, releaseCurrent.Version)
}
}
// Compare releases from the lockfile to ones from the current cluster config
diffReleases, err := diff.DiffReleases(releasesCurrent, cluster.ReleasesObj)
if err != nil {