Skip to content

Commit 8bea646

Browse files
committed
Fix lint errors and update golangci configuration
1 parent 1fcef45 commit 8bea646

File tree

8 files changed

+81
-13
lines changed

8 files changed

+81
-13
lines changed

.golangci.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
run:
22
timeout: 5m
3-
skip-files:
4-
- "zz_generated.*\\.go$"
5-
skip-dirs:
6-
- ".*/mocks"
7-
- "manager/tilt_modules"
8-
- "internal/aws-sdk-go-v2"
9-
- "pkg/providers/snow/api/v1beta1"
3+
104
linters:
115
enable:
126
- gofumpt
@@ -15,6 +9,7 @@ linters:
159
- nakedret
1610
- gocyclo
1711
- revive
12+
1813
linters-settings:
1914
gci:
2015
sections:
@@ -34,9 +29,20 @@ linters-settings:
3429
gocyclo:
3530
# Minimal code complexity to report.
3631
min-complexity: 10
32+
3733
issues:
3834
max-same-issues: 0
3935
max-issues-per-linter: 0
36+
37+
exclude-files:
38+
- "zz_generated.*\\.go$"
39+
40+
exclude-dirs:
41+
- ".*/mocks"
42+
- "manager/tilt_modules"
43+
- "internal/aws-sdk-go-v2"
44+
- "pkg/providers/snow/api/v1beta1"
45+
4046
include:
4147
- EXC0012 # EXC0012 revive: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
4248
- EXC0014 # EXC0014 revive: comment on exported (.+) should be of the form "(.+)..."

release/api/v1alpha1/artifact_types.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ package v1alpha1
1616

1717
import "strings"
1818

19+
// Image represents a container image asset along with metadata such as OS,
20+
// architecture, and registry information.
1921
type Image struct {
2022
// +kubebuilder:validation:Required
2123
// The asset name
@@ -42,10 +44,14 @@ type Image struct {
4244
ImageDigest string `json:"imageDigest,omitempty"`
4345
}
4446

47+
// VersionedImage returns the full URI of the Image, including registry,
48+
// repository, and tag or digest.
4549
func (i Image) VersionedImage() string {
4650
return i.URI
4751
}
4852

53+
// Image returns the repository URI of the Image, excluding the tag or digest
54+
// if one is present.
4955
func (i Image) Image() string {
5056
lastInd := strings.LastIndex(i.URI, ":")
5157
if lastInd == -1 {
@@ -54,6 +60,7 @@ func (i Image) Image() string {
5460
return i.URI[:lastInd]
5561
}
5662

63+
// Tag returns the tag portion of the Image's URI if present, otherwise an empty string.
5764
func (i Image) Tag() string {
5865
lastInd := strings.LastIndex(i.URI, ":")
5966
if lastInd == -1 || lastInd == len(i.URI)-1 {
@@ -62,6 +69,8 @@ func (i Image) Tag() string {
6269
return i.URI[lastInd+1:]
6370
}
6471

72+
// ChartName constructs a typical Helm chart artifact name (with ".tgz")
73+
// from the Image's name by replacing the last colon with a hyphen.
6574
func (i Image) ChartName() string {
6675
lastInd := strings.LastIndex(i.Image(), "/")
6776
if lastInd == -1 {
@@ -73,6 +82,7 @@ func (i Image) ChartName() string {
7382
return chart
7483
}
7584

85+
// Registry returns the registry portion of the Image URI (the substring before the first slash).
7686
func (i *Image) Registry() string {
7787
result := strings.Split(i.URI, "/")
7888
if len(result) < 1 {
@@ -81,6 +91,7 @@ func (i *Image) Registry() string {
8191
return result[0]
8292
}
8393

94+
// Repository returns the repository name (between the registry and the tag/digest).
8495
func (i *Image) Repository() string {
8596
rol := strings.TrimPrefix(i.URI, i.Registry()+"/")
8697
result := strings.Split(rol, "@")
@@ -94,6 +105,7 @@ func (i *Image) Repository() string {
94105
return result[0]
95106
}
96107

108+
// Digest returns the SHA digest portion (after '@') of the Image URI, if present.
97109
func (i *Image) Digest() string {
98110
rol := strings.TrimPrefix(i.URI, i.Registry()+"/")
99111
result := strings.Split(rol, "@")
@@ -103,6 +115,7 @@ func (i *Image) Digest() string {
103115
return result[1]
104116
}
105117

118+
// Version returns the tag portion (after ':') of the Image URI, if present, or empty if the URI uses digests.
106119
func (i *Image) Version() string {
107120
rol := strings.TrimPrefix(i.URI, i.Registry()+"/")
108121
result := strings.Split(rol, "@")
@@ -116,6 +129,8 @@ func (i *Image) Version() string {
116129
return ""
117130
}
118131

132+
// Archive represents an archive asset (e.g. tarball) along with its OS/architecture metadata,
133+
// and checksums for file integrity.
119134
type Archive struct {
120135
// +kubebuilder:validation:Required
121136
// The asset name
@@ -138,14 +153,18 @@ type Archive struct {
138153
// +kubebuilder:validation:Required
139154
// The URI where the asset is located
140155
URI string `json:"uri,omitempty"`
156+
141157
// +kubebuilder:validation:Required
142158
// The sha512 of the asset, only applies for 'file' store
143159
SHA512 string `json:"sha512,omitempty"`
160+
144161
// +kubebuilder:validation:Required
145162
// The sha256 of the asset, only applies for 'file' store
146163
SHA256 string `json:"sha256,omitempty"`
147164
}
148165

166+
// Manifest represents a reference to a manifest, typically containing
167+
// further resource definitions or configurations.
149168
type Manifest struct {
150169
// +kubebuilder:validation:Required
151170
// URI points to the manifest yaml file

release/api/v1alpha1/artifacts.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package v1alpha1
1616

17+
// Manifests returns a map of manifests for different components in a VersionsBundle.
1718
func (vb *VersionsBundle) Manifests() map[string][]*string {
1819
return map[string][]*string{
1920
"core-cluster-api": {
@@ -83,12 +84,14 @@ func (vb *VersionsBundle) Manifests() map[string][]*string {
8384
}
8485
}
8586

87+
// Ovas returns a list of OVA archives in a VersionsBundle.
8688
func (vb *VersionsBundle) Ovas() []Archive {
8789
return []Archive{
8890
vb.EksD.Ova.Bottlerocket,
8991
}
9092
}
9193

94+
// CloudStackImages returns images needed for the CloudStack provider in a VersionsBundle.
9295
func (vb *VersionsBundle) CloudStackImages() []Image {
9396
return []Image{
9497
vb.CloudStack.ClusterAPIController,
@@ -97,6 +100,7 @@ func (vb *VersionsBundle) CloudStackImages() []Image {
97100
}
98101
}
99102

103+
// VsphereImages returns images needed for the vSphere provider in a VersionsBundle.
100104
func (vb *VersionsBundle) VsphereImages() []Image {
101105
return []Image{
102106
vb.VSphere.ClusterAPIController,
@@ -106,13 +110,15 @@ func (vb *VersionsBundle) VsphereImages() []Image {
106110
}
107111
}
108112

113+
// DockerImages returns images needed for the Docker provider in a VersionsBundle.
109114
func (vb *VersionsBundle) DockerImages() []Image {
110115
return []Image{
111116
vb.Docker.KubeProxy,
112117
vb.Docker.Manager,
113118
}
114119
}
115120

121+
// SnowImages returns images needed for the Snow provider in a VersionsBundle.
116122
func (vb *VersionsBundle) SnowImages() []Image {
117123
i := make([]Image, 0, 2)
118124
if vb.Snow.KubeVip.URI != "" {
@@ -128,6 +134,7 @@ func (vb *VersionsBundle) SnowImages() []Image {
128134
return i
129135
}
130136

137+
// TinkerbellImages returns images needed for the Tinkerbell provider in a VersionsBundle.
131138
func (vb *VersionsBundle) TinkerbellImages() []Image {
132139
return []Image{
133140
vb.Tinkerbell.ClusterAPIController,
@@ -154,6 +161,7 @@ func (vb *VersionsBundle) TinkerbellImages() []Image {
154161
}
155162
}
156163

164+
// NutanixImages returns images needed for the Nutanix provider in a VersionsBundle.
157165
func (vb *VersionsBundle) NutanixImages() []Image {
158166
i := make([]Image, 0, 2)
159167
if vb.Nutanix.ClusterAPIController.URI != "" {
@@ -167,6 +175,7 @@ func (vb *VersionsBundle) NutanixImages() []Image {
167175
return i
168176
}
169177

178+
// SharedImages returns images that are shared across different providers in a VersionsBundle.
170179
func (vb *VersionsBundle) SharedImages() []Image {
171180
return []Image{
172181
vb.Bootstrap.Controller,
@@ -204,6 +213,7 @@ func (vb *VersionsBundle) SharedImages() []Image {
204213
}
205214
}
206215

216+
// Images returns all images from the VersionsBundle by aggregating those from different providers.
207217
func (vb *VersionsBundle) Images() []Image {
208218
groupedImages := [][]Image{
209219
vb.SharedImages(),
@@ -228,6 +238,7 @@ func (vb *VersionsBundle) Images() []Image {
228238
return images
229239
}
230240

241+
// Charts returns a map of Helm chart images used by different components in a VersionsBundle.
231242
func (vb *VersionsBundle) Charts() map[string]*Image {
232243
return map[string]*Image{
233244
"cilium": &vb.Cilium.HelmChart,

release/api/v1alpha1/artifacts_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package v1alpha1_test
1616

17+
//nolint:revive
1718
import (
1819
"testing"
1920

0 commit comments

Comments
 (0)