Format go resource (#71370)

* Format Go resource

* Format tabs

* use format library

* Undo template change

* Apply suggestion
This commit is contained in:
Selene 2023-07-11 16:41:18 +02:00 committed by GitHub
parent 850a7a7d39
commit 8b419f624f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 32 deletions

View File

@ -3,6 +3,7 @@ package codegen
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"go/format"
"strings" "strings"
"cuelang.org/go/cue" "cuelang.org/go/cue"
@ -57,7 +58,13 @@ func (ag *ResourceGoTypesJenny) Generate(kind kindsys.Kind) (*codejen.File, erro
if err != nil { if err != nil {
return nil, err return nil, err
} }
return codejen.NewFile(fmt.Sprintf("pkg/kinds/%s/%s_gen.go", mname, mname), buf.Bytes(), ag), nil
content, err := format.Source(buf.Bytes())
if err != nil {
return nil, err
}
return codejen.NewFile(fmt.Sprintf("pkg/kinds/%s/%s_gen.go", mname, mname), content, ag), nil
} }
type SubresourceGoTypesJenny struct { type SubresourceGoTypesJenny struct {

View File

@ -21,7 +21,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of {{ .KindName }}. // Resource is the wire representation of {{ .KindName }}.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of AccessPolicy. // Resource is the wire representation of AccessPolicy.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of Dashboard. // Resource is the wire representation of Dashboard.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of Folder. // Resource is the wire representation of Folder.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of LibraryPanel. // Resource is the wire representation of LibraryPanel.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of Playlist. // Resource is the wire representation of Playlist.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of Preferences. // Resource is the wire representation of Preferences.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of PublicDashboard. // Resource is the wire representation of PublicDashboard.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of Role. // Resource is the wire representation of Role.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of RoleBinding. // Resource is the wire representation of RoleBinding.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {

View File

@ -30,7 +30,6 @@ func NewK8sResource(name string, s *Spec) K8sResource {
} }
} }
// Resource is the wire representation of Team. // Resource is the wire representation of Team.
// It currently will soon be merged into the k8s flavor (TODO be better) // It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct { type Resource struct {