A lot of changes

This commit is contained in:
Nikolai Rodionov
2024-07-25 18:44:58 +02:00
parent 625450ca25
commit 6e08510b3d
25 changed files with 225 additions and 443 deletions

View File

@ -6,7 +6,6 @@ import (
"git.badhouseplants.net/allanger/shoebill/pkg/cluster"
"git.badhouseplants.net/allanger/shoebill/pkg/release"
"git.badhouseplants.net/allanger/shoebill/pkg/repository"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)
@ -21,7 +20,6 @@ type Config struct {
// NewConfigFromFile populates the config struct from a configuration yaml file
func NewConfigFromFile(path string) (*Config, error) {
var config Config
logrus.Infof("readig the config file: %s", path)
configFile, err := os.ReadFile(path)
if err != nil {
return nil, err

View File

@ -19,8 +19,8 @@ type LockEntry struct {
RepoUrl string
RepoName string
GitCommit string
Values []string
Secrets []string
Values map[string]string
Secrets map[string]string
}
type HashPerRelease struct {

View File

@ -1,6 +1,8 @@
package release
import (
"crypto/sha1"
"encoding/base64"
"fmt"
"os"
"path/filepath"
@ -36,9 +38,9 @@ type Release struct {
}
func (r *Release) ToHelmReleaseData() *helmhelper.ReleaseData {
// valuesData =
// valuesData =
// for _, data := range r.DestValues {
// }
return &helmhelper.ReleaseData{
Name: r.Release,
@ -179,6 +181,20 @@ func ReleasesFromLockfile(lockfile lockfile.LockFile, repos repository.Repositor
}
func (r *Release) LockEntry() *lockfile.LockEntry {
valuesHashes := map[string]string{}
for _, valueHolder := range r.DestValues {
hasher := sha1.New()
hasher.Write(valueHolder.Data)
sha := base64.URLEncoding.EncodeToString(hasher.Sum(nil))
valuesHashes[valueHolder.DestPath] = sha
}
secretHashes := map[string]string{}
for _, valueHolder := range r.DestSecrets {
hasher := sha1.New()
hasher.Write(valueHolder.Data)
sha := base64.URLEncoding.EncodeToString(hasher.Sum(nil))
secretHashes[valueHolder.DestPath] = sha
}
return &lockfile.LockEntry{
Chart: r.Chart,
Release: r.Release,
@ -186,8 +202,8 @@ func (r *Release) LockEntry() *lockfile.LockEntry {
Namespace: r.Namespace,
RepoUrl: r.RepositoryObj.URL,
RepoName: r.RepositoryObj.Name,
Values: r.DestValues.ToStrings(),
Secrets: r.DestSecrets.ToStrings(),
Values: valuesHashes,
Secrets: secretHashes,
}
}