Skip to content

Commit a6aaa06

Browse files
authored
gofmt 1.20 updates (style-only changes) (#407)
Signed-off-by: Jay Pipes <[email protected]> By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent adad76c commit a6aaa06

File tree

14 files changed

+405
-361
lines changed

14 files changed

+405
-361
lines changed

pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type PrefixConfig struct {
7777
// GetAdditionalColumns extracts AdditionalColumns defined for a given Resource
7878
func (c *Config) GetAdditionalColumns(resourceName string) []*AdditionalColumnConfig {
7979
if c == nil {
80-
return nil
80+
return nil
8181
}
8282

8383
resourceConfig, ok := c.Resources[resourceName]

pkg/config/field.go

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,23 @@ import "strings"
4949
// CreateFunction API call, which has a `Code` member of its Input shape that
5050
// looks like this:
5151
//
52-
// "Code": {
53-
// "ImageUri": "string",
54-
// "S3Bucket": "string",
55-
// "S3Key": "string",
56-
// "S3ObjectVersion": "string",
57-
// "ZipFile": blob
58-
// },
52+
// "Code": {
53+
// "ImageUri": "string",
54+
// "S3Bucket": "string",
55+
// "S3Key": "string",
56+
// "S3ObjectVersion": "string",
57+
// "ZipFile": blob
58+
// },
5959
//
6060
// The GetFunction API call's Output shape has a same-named field called
6161
// `Code` in it, but this field looks like this:
6262
//
63-
// "Code": {
64-
// "ImageUri": "string",
65-
// "Location": "string",
66-
// "RepositoryType": "string",
67-
// "ResolvedImageUri": "string"
68-
// },
63+
// "Code": {
64+
// "ImageUri": "string",
65+
// "Location": "string",
66+
// "RepositoryType": "string",
67+
// "ResolvedImageUri": "string"
68+
// },
6969
//
7070
// This presents a conundrum to the ACK code generator, which, as noted above,
7171
// assumes the data types of same-named fields in the Create Operation's Input
@@ -80,23 +80,24 @@ import "strings"
8080
// ReadOne Operation's Output shape:
8181
//
8282
// resources:
83-
// Function:
84-
// fields:
85-
// CodeLocation:
86-
// is_read_only: true
87-
// from:
88-
// operation: GetFunction
89-
// path: Code.Location
90-
// CodeRepositoryType:
91-
// is_read_only: true
92-
// from:
93-
// operation: GetFunction
94-
// path: Code.RepositoryType
95-
// CodeRegisteredImageURI:
96-
// is_read_only: true
97-
// from:
98-
// operation: GetFunction
99-
// path: Code.RegisteredImageUri
83+
//
84+
// Function:
85+
// fields:
86+
// CodeLocation:
87+
// is_read_only: true
88+
// from:
89+
// operation: GetFunction
90+
// path: Code.Location
91+
// CodeRepositoryType:
92+
// is_read_only: true
93+
// from:
94+
// operation: GetFunction
95+
// path: Code.RepositoryType
96+
// CodeRegisteredImageURI:
97+
// is_read_only: true
98+
// from:
99+
// operation: GetFunction
100+
// path: Code.RegisteredImageUri
100101
type SourceFieldConfig struct {
101102
// Operation refers to the ID of the API Operation where we will
102103
// determine the field's Go type.
@@ -135,17 +136,20 @@ type SourceFieldConfig struct {
135136
// the SetResource generator:
136137
//
137138
// ```go
138-
// if resp.DBInstance.DBSecurityGroups != nil {
139-
// f17 := []*string{}
140-
// for _, f17iter := range resp.DBInstance.DBSecurityGroups {
141-
// var f17elem string
142-
// f17elem = *f17iter.DBSecurityGroupName
143-
// f17 = append(f17, &f17elem)
144-
// }
145-
// ko.Spec.DBSecurityGroupNames = f17
146-
// } else {
147-
// ko.Spec.DBSecurityGroupNames = nil
148-
// }
139+
//
140+
// if resp.DBInstance.DBSecurityGroups != nil {
141+
// f17 := []*string{}
142+
// for _, f17iter := range resp.DBInstance.DBSecurityGroups {
143+
// var f17elem string
144+
// f17elem = *f17iter.DBSecurityGroupName
145+
// f17 = append(f17, &f17elem)
146+
// }
147+
// ko.Spec.DBSecurityGroupNames = f17
148+
// } else {
149+
//
150+
// ko.Spec.DBSecurityGroupNames = nil
151+
// }
152+
//
149153
// ```
150154
//
151155
// [0] https://github.com/aws/aws-sdk-go/blob/0a01aef9caf16d869c7340e729080205760dc2a2/models/apis/rds/2014-10-31/api-2.json#L2985
@@ -274,12 +278,14 @@ type LateInitializeConfig struct {
274278
// Example:
275279
// ```
276280
// Integration:
277-
// fields:
278-
// ApiId:
279-
// references:
280-
// resource: API
281-
// path: Status.APIID
282-
//```
281+
//
282+
// fields:
283+
// ApiId:
284+
// references:
285+
// resource: API
286+
// path: Status.APIID
287+
//
288+
// ```
283289
// The above configuration will result in generation of a new field 'APIRef'
284290
// of type 'AWSResourceReference' for ApiGatewayv2-Integration crd.
285291
// When 'APIRef' field is present in custom resource manifest, reconciler will

pkg/fieldpath/path.go

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -128,53 +128,53 @@ func (p *Path) Size() int {
128128
//
129129
// Assume a ShapeRef that looks like this:
130130
//
131-
// authShapeRef := &awssdkmodel.ShapeRef{
132-
// ShapeName: "Author",
133-
// Shape: &awssdkmodel.Shape{
134-
// Type: "structure",
135-
// MemberRefs: map[string]*awssdkmodel.ShapeRef{
136-
// "Name": &awssdkmodel.ShapeRef{
137-
// ShapeName: "Name",
138-
// Shape: &awssdkmodel.Shape{
139-
// Type: "string",
140-
// },
141-
// },
142-
// "Address": &awssdkmodel.ShapeRef{
143-
// ShapeName: "Address",
144-
// Shape: &awssdkmodel.Shape{
145-
// Type: "structure",
146-
// MemberRefs: map[string]*awssdkmodel.ShapeRef{
147-
// "State": &awssdkmodel.ShapeRef{
148-
// ShapeName: "StateCode",
149-
// Shape: &awssdkmodel.Shape{
150-
// Type: "string",
151-
// },
152-
// },
153-
// "Country": &awssdkmodel.ShapeRef{
154-
// ShapeName: "CountryCode",
155-
// Shape: &awssdkmodel.Shape{
156-
// Type: "string",
157-
// },
158-
// },
159-
// },
160-
// },
161-
// },
162-
// },
163-
// },
164-
// }
131+
// authShapeRef := &awssdkmodel.ShapeRef{
132+
// ShapeName: "Author",
133+
// Shape: &awssdkmodel.Shape{
134+
// Type: "structure",
135+
// MemberRefs: map[string]*awssdkmodel.ShapeRef{
136+
// "Name": &awssdkmodel.ShapeRef{
137+
// ShapeName: "Name",
138+
// Shape: &awssdkmodel.Shape{
139+
// Type: "string",
140+
// },
141+
// },
142+
// "Address": &awssdkmodel.ShapeRef{
143+
// ShapeName: "Address",
144+
// Shape: &awssdkmodel.Shape{
145+
// Type: "structure",
146+
// MemberRefs: map[string]*awssdkmodel.ShapeRef{
147+
// "State": &awssdkmodel.ShapeRef{
148+
// ShapeName: "StateCode",
149+
// Shape: &awssdkmodel.Shape{
150+
// Type: "string",
151+
// },
152+
// },
153+
// "Country": &awssdkmodel.ShapeRef{
154+
// ShapeName: "CountryCode",
155+
// Shape: &awssdkmodel.Shape{
156+
// Type: "string",
157+
// },
158+
// },
159+
// },
160+
// },
161+
// },
162+
// },
163+
// },
164+
// }
165165
//
166166
// If I have the following Path:
167167
//
168168
// p := fieldpath.FromString("Author.Address.Country")
169169
//
170170
// calling p.ShapeRef(authShapeRef) would return the following:
171171
//
172-
// &awssdkmodel.ShapeRef{
173-
// ShapeName: "CountryCode",
174-
// Shape: &awssdkmodel.Shape{
175-
// Type: "string",
176-
// },
177-
// },
172+
// &awssdkmodel.ShapeRef{
173+
// ShapeName: "CountryCode",
174+
// Shape: &awssdkmodel.Shape{
175+
// Type: "string",
176+
// },
177+
// },
178178
func (p *Path) ShapeRef(
179179
subject *awssdkmodel.ShapeRef,
180180
) *awssdkmodel.ShapeRef {
@@ -254,11 +254,12 @@ func memberShapeRef(
254254
// HasPrefix returns true if the supplied string, delimited on ".", matches
255255
// p.parts up to the length of the supplied string.
256256
// e.g. if the Path p represents "A.B":
257-
// subject "A" -> true
258-
// subject "A.B" -> true
259-
// subject "A.B.C" -> false
260-
// subject "B" -> false
261-
// subject "A.C" -> false
257+
//
258+
// subject "A" -> true
259+
// subject "A.B" -> true
260+
// subject "A.B.C" -> false
261+
// subject "B" -> false
262+
// subject "A.C" -> false
262263
func (p *Path) HasPrefix(subject string) bool {
263264
subjectSplit := strings.Split(subject, ".")
264265

pkg/generate/code/check.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ func checkRequiredFieldsMissingFromShape(
163163
// locates an identifier field in the shape that can be populated with an
164164
// identifier value from the CR.
165165
//
166-
//
167166
// As an example, DescribeVpcs EC2 API call doesn't have a ReadOne operation or
168167
// required fields. However, the input shape has a VpcIds field which can be
169168
// populated using a VpcId, a field in the VPC CR's Status. Therefore, require

pkg/generate/code/compare.go

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,41 @@ import (
4242
//
4343
// For *scalar* Go types, the output Go code looks like this:
4444
//
45-
// if ackcompare.HasNilDifference(a.ko.Spec.GrantFullControl, b.ko.Spec.GrantFullControl) {
46-
// delta.Add("Spec.GrantFullControl", a.ko.Spec.GrantFullControl, b.ko.Spec.GrantFullControl)
47-
// } else if a.ko.Spec.GrantFullControl != nil && b.ko.Spec.GrantFullControl != nil {
48-
// if *a.ko.Spec.GrantFullControl != *b.ko.Spec.GrantFullControl {
49-
// delta.Add("Spec.GrantFullControl", a.ko.Spec.GrantFullControl, b.ko.Spec.GrantFullControl)
50-
// }
51-
// }
45+
// if ackcompare.HasNilDifference(a.ko.Spec.GrantFullControl, b.ko.Spec.GrantFullControl) {
46+
// delta.Add("Spec.GrantFullControl", a.ko.Spec.GrantFullControl, b.ko.Spec.GrantFullControl)
47+
// } else if a.ko.Spec.GrantFullControl != nil && b.ko.Spec.GrantFullControl != nil {
48+
//
49+
// if *a.ko.Spec.GrantFullControl != *b.ko.Spec.GrantFullControl {
50+
// delta.Add("Spec.GrantFullControl", a.ko.Spec.GrantFullControl, b.ko.Spec.GrantFullControl)
51+
// }
52+
// }
5253
//
5354
// For *struct* Go types, the output Go code looks like this (note that it is a
5455
// simple recursive-descent output of all the struct's fields...):
5556
//
56-
// if ackcompare.HasNilDifference(a.ko.Spec.CreateBucketConfiguration, b.ko.Spec.CreateBucketConfiguration) {
57-
// delta.Add("Spec.CreateBucketConfiguration", a.ko.Spec.CreateBucketConfiguration, b.ko.Spec.CreateBucketConfiguration)
58-
// } else if a.ko.Spec.CreateBucketConfiguration != nil && b.ko.Spec.CreateBucketConfiguration != nil {
59-
// if ackcompare.HasNilDifference(a.ko.Spec.CreateBucketConfiguration.LocationConstraint, b.ko.Spec.CreateBucketConfiguration.LocationConstraint) {
60-
// delta.Add("Spec.CreateBucketConfiguration.LocationConstraint", a.ko.Spec.CreateBucketConfiguration.LocationConstraint, b.ko.Spec.CreateBucketConfiguration.LocationConstraint)
61-
// } else if a.ko.Spec.CreateBucketConfiguration.LocationConstraint != nil && b.ko.Spec.CreateBucketConfiguration.LocationConstraint != nil {
62-
// if *a.ko.Spec.CreateBucketConfiguration.LocationConstraint != *b.ko.Spec.CreateBucketConfiguration.LocationConstraint {
63-
// delta.Add("Spec.CreateBucketConfiguration.LocationConstraint", a.ko.Spec.CreateBucketConfiguration.LocationConstraint, b.ko.Spec.CreateBucketConfiguration.LocationConstraint)
64-
// }
65-
// }
66-
// }
57+
// if ackcompare.HasNilDifference(a.ko.Spec.CreateBucketConfiguration, b.ko.Spec.CreateBucketConfiguration) {
58+
// delta.Add("Spec.CreateBucketConfiguration", a.ko.Spec.CreateBucketConfiguration, b.ko.Spec.CreateBucketConfiguration)
59+
// } else if a.ko.Spec.CreateBucketConfiguration != nil && b.ko.Spec.CreateBucketConfiguration != nil {
60+
//
61+
// if ackcompare.HasNilDifference(a.ko.Spec.CreateBucketConfiguration.LocationConstraint, b.ko.Spec.CreateBucketConfiguration.LocationConstraint) {
62+
// delta.Add("Spec.CreateBucketConfiguration.LocationConstraint", a.ko.Spec.CreateBucketConfiguration.LocationConstraint, b.ko.Spec.CreateBucketConfiguration.LocationConstraint)
63+
// } else if a.ko.Spec.CreateBucketConfiguration.LocationConstraint != nil && b.ko.Spec.CreateBucketConfiguration.LocationConstraint != nil {
64+
// if *a.ko.Spec.CreateBucketConfiguration.LocationConstraint != *b.ko.Spec.CreateBucketConfiguration.LocationConstraint {
65+
// delta.Add("Spec.CreateBucketConfiguration.LocationConstraint", a.ko.Spec.CreateBucketConfiguration.LocationConstraint, b.ko.Spec.CreateBucketConfiguration.LocationConstraint)
66+
// }
67+
// }
68+
// }
6769
//
6870
// For *slice of strings* Go types, the output Go code looks like this:
6971
//
70-
// if ackcompare.HasNilDifference(a.ko.Spec.AllowedPublishers, b.ko.Spec.AllowedPublishers) {
71-
// delta.Add("Spec.AllowedPublishers", a.ko.Spec.AllowedPublishers, b.ko.Spec.AllowedPublishers)
72-
// } else if a.ko.Spec.AllowedPublishers != nil && b.ko.Spec.AllowedPublishers != nil {
73-
// if !ackcompare.SliceStringPEqual(a.ko.Spec.AllowedPublishers.SigningProfileVersionARNs, b.ko.Spec.AllowedPublishers.SigningProfileVersionARNs) {
74-
// delta.Add("Spec.AllowedPublishers.SigningProfileVersionARNs", a.ko.Spec.AllowedPublishers.SigningProfileVersionARNs, b.ko.Spec.AllowedPublishers.SigningProfileVersionARNs)
75-
// }
76-
// }
72+
// if ackcompare.HasNilDifference(a.ko.Spec.AllowedPublishers, b.ko.Spec.AllowedPublishers) {
73+
// delta.Add("Spec.AllowedPublishers", a.ko.Spec.AllowedPublishers, b.ko.Spec.AllowedPublishers)
74+
// } else if a.ko.Spec.AllowedPublishers != nil && b.ko.Spec.AllowedPublishers != nil {
75+
//
76+
// if !ackcompare.SliceStringPEqual(a.ko.Spec.AllowedPublishers.SigningProfileVersionARNs, b.ko.Spec.AllowedPublishers.SigningProfileVersionARNs) {
77+
// delta.Add("Spec.AllowedPublishers.SigningProfileVersionARNs", a.ko.Spec.AllowedPublishers.SigningProfileVersionARNs, b.ko.Spec.AllowedPublishers.SigningProfileVersionARNs)
78+
// }
79+
// }
7780
func CompareResource(
7881
cfg *ackgenconfig.Config,
7982
r *model.CRD,
@@ -238,9 +241,9 @@ func CompareResource(
238241
//
239242
// Output code will look something like this:
240243
//
241-
// if ackcompare.HasNilDifferenceStringP(a.ko.Spec.Name, b.ko.Spec.Name == nil) {
242-
// delta.Add("Spec.Name", a.ko.Spec.Name, b.ko.Spec.Name)
243-
// }
244+
// if ackcompare.HasNilDifferenceStringP(a.ko.Spec.Name, b.ko.Spec.Name == nil) {
245+
// delta.Add("Spec.Name", a.ko.Spec.Name, b.ko.Spec.Name)
246+
// }
244247
func compareNil(
245248
// struct informing code generator how to compare the field values
246249
compareConfig *ackgenconfig.CompareFieldConfig,
@@ -302,9 +305,9 @@ func compareNil(
302305
//
303306
// Output code will look something like this:
304307
//
305-
// if *a.ko.Spec.Name != *b.ko.Spec.Name) {
306-
// delta.Add("Spec.Name", a.ko.Spec.Name, b.ko.Spec.Name)
307-
// }
308+
// if *a.ko.Spec.Name != *b.ko.Spec.Name) {
309+
// delta.Add("Spec.Name", a.ko.Spec.Name, b.ko.Spec.Name)
310+
// }
308311
func compareScalar(
309312
// struct informing code generator how to compare the field values
310313
compareConfig *ackgenconfig.CompareFieldConfig,
@@ -372,9 +375,9 @@ func compareScalar(
372375
//
373376
// Output code will look something like this:
374377
//
375-
// if !ackcompare.MapStringStringPEqual(a.ko.Spec.Tags, b.ko.Spec.Tags) {
376-
// delta.Add("Spec.Tags", a.ko.Spec.Tags, b.ko.Spec.Tags)
377-
// }
378+
// if !ackcompare.MapStringStringPEqual(a.ko.Spec.Tags, b.ko.Spec.Tags) {
379+
// delta.Add("Spec.Tags", a.ko.Spec.Tags, b.ko.Spec.Tags)
380+
// }
378381
func compareMap(
379382
cfg *ackgenconfig.Config,
380383
r *model.CRD,
@@ -449,9 +452,9 @@ func compareMap(
449452
//
450453
// Output code will look something like this:
451454
//
452-
// if !ackcompare.SliceStringPEqual(a.ko.Spec.SecurityGroupIDs, b.ko.Spec.SecurityGroupIDs) {
453-
// delta.Add("Spec.SecurityGroupIDs", a.ko.Spec.SecurityGroupIDs, b.ko.Spec.SecurityGroupIDs)
454-
// }
455+
// if !ackcompare.SliceStringPEqual(a.ko.Spec.SecurityGroupIDs, b.ko.Spec.SecurityGroupIDs) {
456+
// delta.Add("Spec.SecurityGroupIDs", a.ko.Spec.SecurityGroupIDs, b.ko.Spec.SecurityGroupIDs)
457+
// }
455458
func compareSlice(
456459
cfg *ackgenconfig.Config,
457460
r *model.CRD,

pkg/generate/code/initialize_field.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ import (
3333
// Example: generated code for "Logging.LoggingEnabled.TargetBucket" field
3434
// inside "s3" "bucket" crd looks like:
3535
//
36-
// ```
37-
// r.ko.Spec.Logging = &svcapitypes.BucketLoggingStatus{}
38-
// r.ko.Spec.Logging.LoggingEnabled = &svcapitypes.LoggingEnabled{}
39-
// ```
36+
// ```
37+
// r.ko.Spec.Logging = &svcapitypes.BucketLoggingStatus{}
38+
// r.ko.Spec.Logging.LoggingEnabled = &svcapitypes.LoggingEnabled{}
39+
// ```
4040
func InitializeNestedStructField(
4141
r *model.CRD,
4242
sourceVarName string,

0 commit comments

Comments
 (0)