diff --git a/internal/providers/flux.go b/internal/providers/flux.go index 0c893fc..d8b0e67 100644 --- a/internal/providers/flux.go +++ b/internal/providers/flux.go @@ -14,6 +14,7 @@ import ( "git.badhouseplants.net/allanger/shoebill/internal/utils/githelper" release_v2beta1 "github.com/fluxcd/helm-controller/api/v2beta1" helmrepo_v1beta2 "github.com/fluxcd/source-controller/api/v1beta2" + "github.com/sirupsen/logrus" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" @@ -37,19 +38,11 @@ func (f *Flux) SyncState(diff diff.Diff) error { entity := "repository" srcPath := fmt.Sprintf("%s/src", f.path) filePath := fmt.Sprintf("%s/%s-", srcPath, entity) - - if err := os.RemoveAll(srcPath); err != nil { - return err - } - - if err := os.Mkdir(srcPath, os.ModePerm); err != nil { - return err - } - for _, repo := range diff.DeletedRepositories { if err := os.Remove(filePath + repo.Name + ".yaml"); err != nil { return err } + message := `chore(repository): Removed a repo: %s A repo has been removed from the cluster: @@ -173,7 +166,25 @@ func (f *Flux) SyncState(diff diff.Diff) error { if err := os.Remove(filePath + release.Release + ".yaml"); err != nil { return err } + files, err := filepath.Glob(fmt.Sprintf("%s/values/%s*", srcPath, release.Release)) + if err != nil { + return err + } + for _, f := range files { + if err := os.Remove(f); err != nil { + return err + } + } + files, err = filepath.Glob(fmt.Sprintf("%s/secrets/%s*", srcPath, release.Release)) + if err != nil { + return err + } + for _, f := range files { + if err := os.Remove(f); err != nil { + return err + } + } message := `chore(release): Remove a release: %s A release has been removed from the cluster: diff --git a/internal/utils/diff/diff.go b/internal/utils/diff/diff.go index b381f56..6c0a48f 100644 --- a/internal/utils/diff/diff.go +++ b/internal/utils/diff/diff.go @@ -46,7 +46,10 @@ func DiffReleases(src, dest release.Releases) (*Diff, error) { } } } + logrus.Info(rSrc.Release) if !found { + logrus.Info(rSrc.Release) + // for i, entry := range lockFile { // if entry.Release == rSrc.Release { // lockFile[i] = lockFile[len(lockFile)-1]