Skip to content

Commit

Permalink
chore: refactor the extension rendering a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronschweig committed Jan 15, 2025
1 parent d2fb426 commit 9a857be
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions pkg/subroutines/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
v1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -100,21 +101,14 @@ func RenderExtensionSpec(ctx context.Context, keyValues map[string]any, account
return err
}

var intermediate bytes.Buffer
err = json.NewEncoder(&intermediate).Encode(account)
if err != nil {
return err
}

var renderAccount map[string]any
err = json.NewDecoder(&intermediate).Decode(&renderAccount)
renderedAccount, err := runtime.DefaultUnstructuredConverter.ToUnstructured(account)
if err != nil {
return err
}

var rendered bytes.Buffer
err = t.Execute(&rendered, map[string]any{
"Account": renderAccount,
"Account": renderedAccount,
})
if err != nil {
return err
Expand Down

0 comments on commit 9a857be

Please sign in to comment.