Skip to content

Commit fd00cfc

Browse files
authored
Update cog to v0.0.30 (#753)
The grafana/cog update from `v0.0.29` to `v0.0.30` contains breaking changes to the go type generation command (removing `AllowMarshalEmptyDisjunctions` from the go gen config), and updates the NewX methods in generated code. This causes the [dependabot PR](#752) to fail, so a manual update must be done to remove `allowMarshalEmptyDisjunctions` from the CUE and go code, and re-generate the golden test files.
1 parent 6499cef commit fd00cfc

File tree

14 files changed

+57
-26
lines changed

14 files changed

+57
-26
lines changed

codegen/cuekind/def.cue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ Kind: S={
198198
// enabled indicates whether back-end Go code should be generated for this kind's schema
199199
enabled: bool | *true
200200
config: {
201-
// allowMarshalEmptyDisjunctions determines whether to allow marshaling empty disjunctions.
202-
// If true, empty disjunctions will be marshaled as `null` instead of returning an error.
203-
allowMarshalEmptyDisjunctions: bool | *true
204201
}
205202
}
206203
}

codegen/jennies/gotypes.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ func (g *GoTypes) generateFiles(version *codegen.KindVersion, name string, machi
9292
codegenPipeline := cog.TypesFromSchema().
9393
CUEValue(packageName, version.Schema, cog.ForceEnvelope(name)).
9494
Golang(cog.GoConfig{
95-
AnyAsInterface: g.AnyAsInterface,
96-
AllowMarshalEmptyDisjunctions: version.Codegen.Go.Config.AllowMarshalEmptyDisjunctions,
95+
AnyAsInterface: g.AnyAsInterface,
9796
})
9897

9998
if g.AddKubernetesCodegen {
@@ -130,7 +129,6 @@ func (g *GoTypes) generateFilesAtDepth(v cue.Value, kv *codegen.KindVersion, cur
130129
NamePrefix: namePrefix,
131130
AddKubernetesOpenAPIGenComment: g.AddKubernetesCodegen && !(len(fieldName) == 1 && fieldName[0] == "metadata"),
132131
AnyAsInterface: g.AnyAsInterface,
133-
AllowMarshalEmptyDisjunctions: kv.Codegen.Go.Config.AllowMarshalEmptyDisjunctions,
134132
}, len(v.Path().Selectors())-(g.Depth-g.NamingDepth))
135133
if err != nil {
136134
return nil, err
@@ -165,7 +163,6 @@ type CUEGoConfig struct {
165163

166164
AddKubernetesOpenAPIGenComment bool
167165
AnyAsInterface bool
168-
AllowMarshalEmptyDisjunctions bool
169166

170167
// NamePrefix prefixes all generated types with the provided NamePrefix
171168
NamePrefix string
@@ -192,8 +189,7 @@ func GoTypesFromCUE(v cue.Value, cfg CUEGoConfig, maxNamingDepth int) ([]byte, e
192189
CUEValue(cfg.PackageName, v, cog.ForceEnvelope(cfg.Name), cog.NameFunc(nameFunc)).
193190
SchemaTransformations(cog.PrefixObjectsNames(cfg.NamePrefix)).
194191
Golang(cog.GoConfig{
195-
AnyAsInterface: cfg.AnyAsInterface,
196-
AllowMarshalEmptyDisjunctions: cfg.AllowMarshalEmptyDisjunctions,
192+
AnyAsInterface: cfg.AnyAsInterface,
197193
})
198194

199195
if cfg.AddKubernetesOpenAPIGenComment {

codegen/kind.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ type KindCodegenTSConfig struct {
7777
// KindCodegenGoConfig is the Go configuration options for codegen,
7878
// modeled after the cog Go codegen options.
7979
type KindCodegenGoConfig struct {
80-
AllowMarshalEmptyDisjunctions bool `json:"allowMarshalEmptyDisjunctions"`
8180
}
8281

8382
type AdditionalPrinterColumn struct {

codegen/testing/golden_generated/go/groupbygroup/customapp/v0_0/customkind_metadata_gen.go.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ type CustomKindMetadata struct {
2424

2525
// NewCustomKindMetadata creates a new CustomKindMetadata object.
2626
func NewCustomKindMetadata() *CustomKindMetadata {
27-
return &CustomKindMetadata{}
27+
return &CustomKindMetadata{
28+
Finalizers: []string{},
29+
Labels: map[string]string{},
30+
}
2831
}

codegen/testing/golden_generated/go/groupbygroup/customapp/v1_0/customkind_metadata_gen.go.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@ type CustomKindMetadata struct {
3434

3535
// NewCustomKindMetadata creates a new CustomKindMetadata object.
3636
func NewCustomKindMetadata() *CustomKindMetadata {
37-
return &CustomKindMetadata{}
37+
return &CustomKindMetadata{
38+
Finalizers: []string{},
39+
Labels: map[string]string{},
40+
}
3841
}

codegen/testing/golden_generated/go/groupbygroup/customapp/v1_0/customkind_spec_gen.go.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ type CustomKindInnerObject1 struct {
1616

1717
// NewCustomKindInnerObject1 creates a new CustomKindInnerObject1 object.
1818
func NewCustomKindInnerObject1() *CustomKindInnerObject1 {
19-
return &CustomKindInnerObject1{}
19+
return &CustomKindInnerObject1{
20+
InnerField2: []string{},
21+
InnerField3: []CustomKindInnerObject2{},
22+
InnerField4: []map[string]interface{}{},
23+
}
2024
}
2125

2226
// +k8s:openapi-gen=true
@@ -27,7 +31,9 @@ type CustomKindInnerObject2 struct {
2731

2832
// NewCustomKindInnerObject2 creates a new CustomKindInnerObject2 object.
2933
func NewCustomKindInnerObject2() *CustomKindInnerObject2 {
30-
return &CustomKindInnerObject2{}
34+
return &CustomKindInnerObject2{
35+
Details: map[string]interface{}{},
36+
}
3137
}
3238

3339
// +k8s:openapi-gen=true
@@ -52,7 +58,9 @@ type CustomKindType2 struct {
5258

5359
// NewCustomKindType2 creates a new CustomKindType2 object.
5460
func NewCustomKindType2() *CustomKindType2 {
55-
return &CustomKindType2{}
61+
return &CustomKindType2{
62+
Details: map[string]interface{}{},
63+
}
5664
}
5765

5866
// +k8s:openapi-gen=true
@@ -73,6 +81,7 @@ type CustomKindSpec struct {
7381
func NewCustomKindSpec() *CustomKindSpec {
7482
return &CustomKindSpec{
7583
Inner: *NewCustomKindInnerObject1(),
84+
Map: map[string]CustomKindType2{},
7685
BoolField: false,
7786
}
7887
}

codegen/testing/golden_generated/go/groupbygroup/testapp/v1/testkind2_metadata_gen.go.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ type TestKind2Metadata struct {
2424

2525
// NewTestKind2Metadata creates a new TestKind2Metadata object.
2626
func NewTestKind2Metadata() *TestKind2Metadata {
27-
return &TestKind2Metadata{}
27+
return &TestKind2Metadata{
28+
Finalizers: []string{},
29+
Labels: map[string]string{},
30+
}
2831
}

codegen/testing/golden_generated/go/groupbygroup/testapp/v1/testkind_metadata_gen.go.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ type TestKindMetadata struct {
2424

2525
// NewTestKindMetadata creates a new TestKindMetadata object.
2626
func NewTestKindMetadata() *TestKindMetadata {
27-
return &TestKindMetadata{}
27+
return &TestKindMetadata{
28+
Finalizers: []string{},
29+
Labels: map[string]string{},
30+
}
2831
}

codegen/testing/golden_generated/go/groupbygroup/testapp/v2/testkind_metadata_gen.go.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ type TestKindMetadata struct {
2424

2525
// NewTestKindMetadata creates a new TestKindMetadata object.
2626
func NewTestKindMetadata() *TestKindMetadata {
27-
return &TestKindMetadata{}
27+
return &TestKindMetadata{
28+
Finalizers: []string{},
29+
Labels: map[string]string{},
30+
}
2831
}

codegen/testing/golden_generated/go/groupbykind/customkind/v0_0/customkind_metadata_gen.go.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ type Metadata struct {
2424

2525
// NewMetadata creates a new Metadata object.
2626
func NewMetadata() *Metadata {
27-
return &Metadata{}
27+
return &Metadata{
28+
Finalizers: []string{},
29+
Labels: map[string]string{},
30+
}
2831
}

0 commit comments

Comments
 (0)