Skip to content

Commit

Permalink
adapt incompaible changes in client-go, sops
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarbian-sap committed Aug 28, 2024
1 parent b6591d1 commit 8bd1e76
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions internal/decrypt/sops.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
sopsage "github.com/getsops/sops/v3/age"
sopscommon "github.com/getsops/sops/v3/cmd/sops/common"
sopsformats "github.com/getsops/sops/v3/cmd/sops/formats"
sopsconfig "github.com/getsops/sops/v3/config"
sopskeys "github.com/getsops/sops/v3/keys"
sopskeyservice "github.com/getsops/sops/v3/keyservice"
sopslogging "github.com/getsops/sops/v3/logging"
Expand Down Expand Up @@ -117,7 +118,7 @@ func (d *SopsDecryptor) SopsDecryptWithFormat(input []byte, inputFormat sopsform
}
}()

store := sopscommon.StoreForFormat(inputFormat)
store := sopscommon.StoreForFormat(inputFormat, sopsconfig.NewStoresConfig())

tree, err := store.LoadEncryptedFile(input)
if err != nil {
Expand All @@ -130,7 +131,7 @@ func (d *SopsDecryptor) SopsDecryptWithFormat(input []byte, inputFormat sopsform
})
}

metadataKey, err := tree.Metadata.GetDataKeyWithKeyServices(d.keyServices)
metadataKey, err := tree.Metadata.GetDataKeyWithKeyServices(d.keyServices, sops.DefaultDecryptionOrder)
if err != nil {
return nil, sopsUserErr("cannot get sops data key", err)
}
Expand All @@ -140,7 +141,7 @@ func (d *SopsDecryptor) SopsDecryptWithFormat(input []byte, inputFormat sopsform
return nil, sopsUserErr("error decrypting sops tree", err)
}

outputStore := sopscommon.StoreForFormat(outputFormat)
outputStore := sopscommon.StoreForFormat(outputFormat, sopsconfig.NewStoresConfig())
out, err := outputStore.EmitPlainFile(tree.Branches)
if err != nil {
return nil, sopsUserErr(fmt.Sprintf("failed to emit encrypted %s file as decrypted %s",
Expand Down
8 changes: 4 additions & 4 deletions internal/flux/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ func newHandler(cache cache.Cache, indexKey string) handler.EventHandler {
}
}

func (h *sourceHandler) Create(ctx context.Context, e event.CreateEvent, q workqueue.RateLimitingInterface) {
func (h *sourceHandler) Create(ctx context.Context, e event.CreateEvent, q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
// new sources will never be immediately ready, so nothing has to be done here
}

func (h *sourceHandler) Update(ctx context.Context, e event.UpdateEvent, q workqueue.RateLimitingInterface) {
func (h *sourceHandler) Update(ctx context.Context, e event.UpdateEvent, q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
newSource := e.ObjectNew.(Source)

if !object.IsReady(newSource) {
Expand Down Expand Up @@ -154,10 +154,10 @@ func (h *sourceHandler) Update(ctx context.Context, e event.UpdateEvent, q workq
}
}

func (h *sourceHandler) Delete(ctx context.Context, e event.DeleteEvent, q workqueue.RateLimitingInterface) {
func (h *sourceHandler) Delete(ctx context.Context, e event.DeleteEvent, q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
// no need to queue components if source is deleted (reconciliation of the component would anyway fail)
}

func (h *sourceHandler) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
func (h *sourceHandler) Generic(context.Context, event.GenericEvent, workqueue.TypedRateLimitingInterface[reconcile.Request]) {
// generic events are not expected to arrive on the watch that uses this handler, so nothing to do here
}
8 changes: 4 additions & 4 deletions pkg/operator/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ func newHandler(cache cache.Cache, indexKey string) handler.EventHandler {
}
}

func (h *componentHandler) Create(ctx context.Context, e event.CreateEvent, q workqueue.RateLimitingInterface) {
func (h *componentHandler) Create(ctx context.Context, e event.CreateEvent, q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
// new components will never be immediately ready, so nothing has to be done here
}

func (h *componentHandler) Update(ctx context.Context, e event.UpdateEvent, q workqueue.RateLimitingInterface) {
func (h *componentHandler) Update(ctx context.Context, e event.UpdateEvent, q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
newComponent := e.ObjectNew.(*operatorv1alpha1.Component)

if !newComponent.IsReady() {
Expand All @@ -89,7 +89,7 @@ func (h *componentHandler) Update(ctx context.Context, e event.UpdateEvent, q wo
}
}

func (h *componentHandler) Delete(ctx context.Context, e event.DeleteEvent, q workqueue.RateLimitingInterface) {
func (h *componentHandler) Delete(ctx context.Context, e event.DeleteEvent, q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
component := e.Object.(*operatorv1alpha1.Component)
for _, dependency := range component.Spec.Dependencies {
q.Add(reconcile.Request{NamespacedName: apitypes.NamespacedName{
Expand All @@ -99,6 +99,6 @@ func (h *componentHandler) Delete(ctx context.Context, e event.DeleteEvent, q wo
}
}

func (h *componentHandler) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
func (h *componentHandler) Generic(context.Context, event.GenericEvent, workqueue.TypedRateLimitingInterface[reconcile.Request]) {
// generic events are not expected to arrive on the watch that uses this handler, so nothing to do here
}

0 comments on commit 8bd1e76

Please sign in to comment.