Skip to content

Commit

Permalink
chore: yaml indent level should match yq indent
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed May 28, 2024
1 parent d3e5475 commit c33ad10
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/gosimple/slug"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/kustomize/api/types"
)
Expand Down Expand Up @@ -107,7 +107,7 @@ func CreateTenantResources(connector connectors.Connector, tenant v1.Tenant, ten
// TODO: This should not append the resources, tenant yaml files should be in
// their own directories
kustomization.Resources = append(kustomization.Resources, tenant.ID)
existingKustomization, err := yaml.Marshal(kustomization)
existingKustomization, err := utils.MarshalYAML(kustomization)
if err != nil {
return nil, err
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/utils/yaml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package utils

import (
"bytes"
"gopkg.in/yaml.v3"
)

func MarshalYAML(obj any) ([]byte, error) {
var b bytes.Buffer
yamlEncoder := yaml.NewEncoder(&b)
// Use 2 space indentation to be consistent with yq
yamlEncoder.SetIndent(2)
err := yamlEncoder.Encode(obj)
return b.Bytes(), err
}

0 comments on commit c33ad10

Please sign in to comment.