WIP: Trying to implement diff

This commit is contained in:
Nikolai Rodionov
2023-10-20 13:31:30 +02:00
parent 93ad3389b2
commit ed3d45a7c4
15 changed files with 197 additions and 136 deletions

View File

@ -47,7 +47,7 @@ func (c *Cluster) BootstrapRepo(gh githelper.Githelper, workdir string, dry bool
if err != nil {
return err
}
if err := gh.AddAllAndCommit(workdir, "Bootstrap the shoebill repo"); err != nil {
if _, err := gh.AddAllAndCommit(workdir, "Bootstrap the shoebill repo"); err != nil {
return err
}
if !dry {
@ -67,7 +67,7 @@ func (c *Cluster) BootstrapRepo(gh githelper.Githelper, workdir string, dry bool
if _, err := file.WriteString(c.DotSops); err != nil {
return err
}
if err := gh.AddAllAndCommit(workdir, "Create a sops config file"); err != nil {
if _, err := gh.AddAllAndCommit(workdir, "Create a sops config file"); err != nil {
return err
}
if !dry {

View File

@ -18,10 +18,18 @@ type LockEntry struct {
Namespace string
RepoUrl string
RepoName string
GitCommit string
Values []string
Secrets []string
}
type HashPerRelease struct {
Release string
Namespace string
CommitHash string
}
type HashesPerReleases []*HashPerRelease
type LockRepository struct {
URL string
Name string
@ -77,6 +85,16 @@ func (lockfile LockFile) ReposFromLockfile() (repository.Repositories, error) {
return dedupedRepositories, nil
}
func (lf LockFile) AddHashes(hashes HashesPerReleases) {
for _, lockEntry := range lf {
for _, hash := range hashes {
if lockEntry.Namespace == hash.Namespace && lockEntry.Release == hash.Release {
lockEntry.GitCommit = hash.CommitHash
}
}
}
}
func (lf LockFile) WriteToFile(dir string) error {
lockfilePath := fmt.Sprintf("%s/%s", dir, LOCKFILE_NAME)
lockfileContent, err := yaml.Marshal(lf)

View File

@ -35,6 +35,22 @@ type Release struct {
DestSecrets ValuesHolders `yaml:"-"`
}
func (r *Release) ToHelmReleaseData() *helmhelper.ReleaseData {
// valuesData =
// for _, data := range r.DestValues {
// }
return &helmhelper.ReleaseData{
Name: r.Release,
Chart: r.Chart,
Version: r.Version,
Namespace: r.Namespace,
RepositoryName: r.RepositoryObj.Name,
RepositoryURL: r.RepositoryObj.URL,
RepositoryKind: r.RepositoryObj.Kind,
}
}
type ValuesHolder struct {
SrcPath string
DestPath string
@ -78,7 +94,7 @@ func (r *Release) VersionHandler(dir string, hh helmhelper.Helmhelper) error {
}
switch r.Version {
case VERSION_LATEST:
version, err := hh.FindLatestVersion(dir, r.Chart, *r.RepositoryObj)
version, err := hh.FindLatestVersion(dir, r.ToHelmReleaseData())
if err != nil {
return err
}