diff --git a/.golangci.yml b/.golangci.yml index f98fee061e9be..88d58d410ac1f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,12 +1,6 @@ run: timeout: 5m - skip-files: - - "zz_generated.*\\.go$" - skip-dirs: - - ".*/mocks" - - "manager/tilt_modules" - - "internal/aws-sdk-go-v2" - - "pkg/providers/snow/api/v1beta1" + linters: enable: - gofumpt @@ -15,6 +9,7 @@ linters: - nakedret - gocyclo - revive + linters-settings: gci: sections: @@ -34,9 +29,20 @@ linters-settings: gocyclo: # Minimal code complexity to report. min-complexity: 10 + issues: max-same-issues: 0 max-issues-per-linter: 0 + + exclude-files: + - "zz_generated.*\\.go$" + + exclude-dirs: + - ".*/mocks" + - "manager/tilt_modules" + - "internal/aws-sdk-go-v2" + - "pkg/providers/snow/api/v1beta1" + include: - EXC0012 # EXC0012 revive: exported (.+) should have comment( \(or a comment on this block\))? or be unexported - EXC0014 # EXC0014 revive: comment on exported (.+) should be of the form "(.+)..." diff --git a/release/api/v1alpha1/artifact_types.go b/release/api/v1alpha1/artifact_types.go index 625f07998f2e9..19291d330bc7a 100644 --- a/release/api/v1alpha1/artifact_types.go +++ b/release/api/v1alpha1/artifact_types.go @@ -16,6 +16,8 @@ package v1alpha1 import "strings" +// Image represents a container image asset along with metadata such as OS, +// architecture, and registry information. type Image struct { // +kubebuilder:validation:Required // The asset name @@ -42,10 +44,14 @@ type Image struct { ImageDigest string `json:"imageDigest,omitempty"` } +// VersionedImage returns the full URI of the Image, including registry, +// repository, and tag or digest. func (i Image) VersionedImage() string { return i.URI } +// Image returns the repository URI of the Image, excluding the tag or digest +// if one is present. func (i Image) Image() string { lastInd := strings.LastIndex(i.URI, ":") if lastInd == -1 { @@ -54,6 +60,7 @@ func (i Image) Image() string { return i.URI[:lastInd] } +// Tag returns the tag portion of the Image's URI if present, otherwise an empty string. func (i Image) Tag() string { lastInd := strings.LastIndex(i.URI, ":") if lastInd == -1 || lastInd == len(i.URI)-1 { @@ -62,6 +69,8 @@ func (i Image) Tag() string { return i.URI[lastInd+1:] } +// ChartName constructs a typical Helm chart artifact name (with ".tgz") +// from the Image's name by replacing the last colon with a hyphen. func (i Image) ChartName() string { lastInd := strings.LastIndex(i.Image(), "/") if lastInd == -1 { @@ -73,6 +82,7 @@ func (i Image) ChartName() string { return chart } +// Registry returns the registry portion of the Image URI (the substring before the first slash). func (i *Image) Registry() string { result := strings.Split(i.URI, "/") if len(result) < 1 { @@ -81,6 +91,7 @@ func (i *Image) Registry() string { return result[0] } +// Repository returns the repository name (between the registry and the tag/digest). func (i *Image) Repository() string { rol := strings.TrimPrefix(i.URI, i.Registry()+"/") result := strings.Split(rol, "@") @@ -94,6 +105,7 @@ func (i *Image) Repository() string { return result[0] } +// Digest returns the SHA digest portion (after '@') of the Image URI, if present. func (i *Image) Digest() string { rol := strings.TrimPrefix(i.URI, i.Registry()+"/") result := strings.Split(rol, "@") @@ -103,6 +115,7 @@ func (i *Image) Digest() string { return result[1] } +// Version returns the tag portion (after ':') of the Image URI, if present, or empty if the URI uses digests. func (i *Image) Version() string { rol := strings.TrimPrefix(i.URI, i.Registry()+"/") result := strings.Split(rol, "@") @@ -116,6 +129,8 @@ func (i *Image) Version() string { return "" } +// Archive represents an archive asset (e.g. tarball) along with its OS/architecture metadata, +// and checksums for file integrity. type Archive struct { // +kubebuilder:validation:Required // The asset name @@ -138,14 +153,18 @@ type Archive struct { // +kubebuilder:validation:Required // The URI where the asset is located URI string `json:"uri,omitempty"` + // +kubebuilder:validation:Required // The sha512 of the asset, only applies for 'file' store SHA512 string `json:"sha512,omitempty"` + // +kubebuilder:validation:Required // The sha256 of the asset, only applies for 'file' store SHA256 string `json:"sha256,omitempty"` } +// Manifest represents a reference to a manifest, typically containing +// further resource definitions or configurations. type Manifest struct { // +kubebuilder:validation:Required // URI points to the manifest yaml file diff --git a/release/api/v1alpha1/artifacts.go b/release/api/v1alpha1/artifacts.go index 40c8c58fbc1e4..8065596076bcc 100644 --- a/release/api/v1alpha1/artifacts.go +++ b/release/api/v1alpha1/artifacts.go @@ -14,6 +14,7 @@ package v1alpha1 +// Manifests returns a map of manifests for different components in a VersionsBundle. func (vb *VersionsBundle) Manifests() map[string][]*string { return map[string][]*string{ "core-cluster-api": { @@ -83,12 +84,14 @@ func (vb *VersionsBundle) Manifests() map[string][]*string { } } +// Ovas returns a list of OVA archives in a VersionsBundle. func (vb *VersionsBundle) Ovas() []Archive { return []Archive{ vb.EksD.Ova.Bottlerocket, } } +// CloudStackImages returns images needed for the CloudStack provider in a VersionsBundle. func (vb *VersionsBundle) CloudStackImages() []Image { return []Image{ vb.CloudStack.ClusterAPIController, @@ -97,6 +100,7 @@ func (vb *VersionsBundle) CloudStackImages() []Image { } } +// VsphereImages returns images needed for the vSphere provider in a VersionsBundle. func (vb *VersionsBundle) VsphereImages() []Image { return []Image{ vb.VSphere.ClusterAPIController, @@ -106,6 +110,7 @@ func (vb *VersionsBundle) VsphereImages() []Image { } } +// DockerImages returns images needed for the Docker provider in a VersionsBundle. func (vb *VersionsBundle) DockerImages() []Image { return []Image{ vb.Docker.KubeProxy, @@ -113,6 +118,7 @@ func (vb *VersionsBundle) DockerImages() []Image { } } +// SnowImages returns images needed for the Snow provider in a VersionsBundle. func (vb *VersionsBundle) SnowImages() []Image { i := make([]Image, 0, 2) if vb.Snow.KubeVip.URI != "" { @@ -128,6 +134,7 @@ func (vb *VersionsBundle) SnowImages() []Image { return i } +// TinkerbellImages returns images needed for the Tinkerbell provider in a VersionsBundle. func (vb *VersionsBundle) TinkerbellImages() []Image { return []Image{ vb.Tinkerbell.ClusterAPIController, @@ -154,6 +161,7 @@ func (vb *VersionsBundle) TinkerbellImages() []Image { } } +// NutanixImages returns images needed for the Nutanix provider in a VersionsBundle. func (vb *VersionsBundle) NutanixImages() []Image { i := make([]Image, 0, 2) if vb.Nutanix.ClusterAPIController.URI != "" { @@ -167,6 +175,7 @@ func (vb *VersionsBundle) NutanixImages() []Image { return i } +// SharedImages returns images that are shared across different providers in a VersionsBundle. func (vb *VersionsBundle) SharedImages() []Image { return []Image{ vb.Bootstrap.Controller, @@ -204,6 +213,7 @@ func (vb *VersionsBundle) SharedImages() []Image { } } +// Images returns all images from the VersionsBundle by aggregating those from different providers. func (vb *VersionsBundle) Images() []Image { groupedImages := [][]Image{ vb.SharedImages(), @@ -228,6 +238,7 @@ func (vb *VersionsBundle) Images() []Image { return images } +// Charts returns a map of Helm chart images used by different components in a VersionsBundle. func (vb *VersionsBundle) Charts() map[string]*Image { return map[string]*Image{ "cilium": &vb.Cilium.HelmChart, diff --git a/release/api/v1alpha1/artifacts_test.go b/release/api/v1alpha1/artifacts_test.go index 66078706b21d8..5fb7e2afa23b1 100644 --- a/release/api/v1alpha1/artifacts_test.go +++ b/release/api/v1alpha1/artifacts_test.go @@ -14,6 +14,7 @@ package v1alpha1_test +//nolint:revive import ( "testing" diff --git a/release/api/v1alpha1/bundle_types.go b/release/api/v1alpha1/bundle_types.go index af2c5a2bac1aa..90cb96f028de6 100644 --- a/release/api/v1alpha1/bundle_types.go +++ b/release/api/v1alpha1/bundle_types.go @@ -42,6 +42,7 @@ type Bundles struct { Status BundlesStatus `json:"status,omitempty"` } +// DefaultEksAToolsImage returns the default EKS Anywhere Tools image. func (b *Bundles) DefaultEksAToolsImage() Image { return b.Spec.VersionsBundles[0].Eksa.CliTools } @@ -59,6 +60,7 @@ func init() { SchemeBuilder.Register(&Bundles{}, &BundlesList{}) } +// VersionsBundle defines the versions of each component for a specific Kubernetes version in the Bundles CRD. type VersionsBundle struct { KubeVersion string `json:"kubeVersion"` EndOfStandardSupport string `json:"endOfStandardSupport,omitempty"` @@ -87,6 +89,7 @@ type VersionsBundle struct { Aws *AwsBundle `json:"aws,omitempty"` } +// EksDRelease defines the EKS-D specific release information. type EksDRelease struct { // +kubebuilder:validation:Required Name string `json:"name,omitempty"` @@ -102,7 +105,7 @@ type EksDRelease struct { // +kubebuilder:validation:Required // Url pointing to the EKS-D release manifest using which // assets where created - EksDReleaseUrl string `json:"manifestUrl,omitempty"` + EksDReleaseUrl string `json:"manifestUrl,omitempty"` //nolint:revive // +kubebuilder:validation:Required // Git commit the component is built from, before any patches @@ -136,21 +139,24 @@ type EksDRelease struct { Containerd Archive `json:"containerd,omitempty"` } -// UpgraderBundle is a In-place Kubernetes version upgrader bundle. +// UpgraderBundle is a bundle for in-place Kubernetes version upgrader images. type UpgraderBundle struct { Upgrader Image `json:"upgrader"` } +// OSImageBundle defines a set of OS images (e.g., Bottlerocket) for this bundle. type OSImageBundle struct { Bottlerocket Archive `json:"bottlerocket,omitempty"` } +// BottlerocketHostContainersBundle defines the Bottlerocket host containers used by the bundle. type BottlerocketHostContainersBundle struct { Admin Image `json:"admin"` Control Image `json:"control"` KubeadmBootstrap Image `json:"kubeadmBootstrap"` } +// CertManagerBundle defines the Cert Manager version and images for this bundle. type CertManagerBundle struct { Version string `json:"version,omitempty"` Acmesolver Image `json:"acmesolver"` @@ -163,6 +169,7 @@ type CertManagerBundle struct { Manifest Manifest `json:"manifest"` } +// CoreClusterAPI defines the Core Cluster API version and images used in this bundle. type CoreClusterAPI struct { Version string `json:"version"` Controller Image `json:"controller"` @@ -171,6 +178,7 @@ type CoreClusterAPI struct { Metadata Manifest `json:"metadata"` } +// KubeadmBootstrapBundle defines the bootstrap controller images and version for this bundle. type KubeadmBootstrapBundle struct { Version string `json:"version"` Controller Image `json:"controller"` @@ -179,6 +187,7 @@ type KubeadmBootstrapBundle struct { Metadata Manifest `json:"metadata"` } +// KubeadmControlPlaneBundle defines the control plane controller images and version for this bundle. type KubeadmControlPlaneBundle struct { Version string `json:"version"` Controller Image `json:"controller"` @@ -187,6 +196,7 @@ type KubeadmControlPlaneBundle struct { Metadata Manifest `json:"metadata"` } +// AwsBundle defines the AWS-related images and configurations for this bundle. type AwsBundle struct { Version string `json:"version"` Controller Image `json:"controller"` @@ -196,6 +206,7 @@ type AwsBundle struct { Metadata Manifest `json:"metadata"` } +// VSphereBundle defines the vSphere provider images and version for this bundle. type VSphereBundle struct { Version string `json:"version"` ClusterAPIController Image `json:"clusterAPIController"` @@ -211,6 +222,7 @@ type VSphereBundle struct { Syncer *Image `json:"syncer,omitempty"` } +// DockerBundle defines the Docker provider images and version for this bundle. type DockerBundle struct { Version string `json:"version"` Manager Image `json:"manager"` @@ -220,6 +232,7 @@ type DockerBundle struct { Metadata Manifest `json:"metadata"` } +// CloudStackBundle defines the CloudStack provider images and version for this bundle. type CloudStackBundle struct { Version string `json:"version"` ClusterAPIController Image `json:"clusterAPIController"` @@ -229,6 +242,7 @@ type CloudStackBundle struct { Metadata Manifest `json:"metadata"` } +// CiliumBundle defines the Cilium version and images used for CNI in this bundle. type CiliumBundle struct { Version string `json:"version,omitempty"` Cilium Image `json:"cilium"` @@ -237,11 +251,13 @@ type CiliumBundle struct { HelmChart Image `json:"helmChart,omitempty"` } +// KindnetdBundle defines the Kindnetd version and manifest for this bundle. type KindnetdBundle struct { Version string `json:"version,omitempty"` Manifest Manifest `json:"manifest"` } +// FluxBundle defines the Flux components and versions used in this bundle. type FluxBundle struct { Version string `json:"version,omitempty"` SourceController Image `json:"sourceController"` @@ -250,6 +266,7 @@ type FluxBundle struct { NotificationController Image `json:"notificationController"` } +// PackageBundle defines the EKS Anywhere package controller and related images for this bundle. type PackageBundle struct { Version string `json:"version,omitempty"` Controller Image `json:"packageController"` @@ -258,6 +275,7 @@ type PackageBundle struct { HelmChart Image `json:"helmChart,omitempty"` } +// EksaBundle defines EKS Anywhere-specific images and configurations for this bundle. type EksaBundle struct { Version string `json:"version,omitempty"` CliTools Image `json:"cliTools"` @@ -266,6 +284,7 @@ type EksaBundle struct { Components Manifest `json:"components"` } +// EtcdadmBootstrapBundle defines the bootstrap mechanism for external etcd in this bundle. type EtcdadmBootstrapBundle struct { Version string `json:"version"` Controller Image `json:"controller"` @@ -274,6 +293,7 @@ type EtcdadmBootstrapBundle struct { Metadata Manifest `json:"metadata"` } +// EtcdadmControllerBundle defines the external etcd controller images and version for this bundle. type EtcdadmControllerBundle struct { Version string `json:"version"` Controller Image `json:"controller"` @@ -282,6 +302,7 @@ type EtcdadmControllerBundle struct { Metadata Manifest `json:"metadata"` } +// TinkerbellStackBundle defines the Tinkerbell stack components for provisioning bare metal. type TinkerbellStackBundle struct { Actions ActionsBundle `json:"actions"` Boots Image `json:"boots"` @@ -294,7 +315,7 @@ type TinkerbellStackBundle struct { Stack Image `json:"stack"` } -// Tinkerbell Template Actions. +// ActionsBundle defines the Tinkerbell template actions. type ActionsBundle struct { Cexec Image `json:"cexec"` Kexec Image `json:"kexec"` @@ -304,6 +325,7 @@ type ActionsBundle struct { Reboot Image `json:"reboot"` } +// TinkBundle defines the images required for Tinkerbell controller and worker processes. type TinkBundle struct { TinkRelay Image `json:"tinkRelay"` TinkRelayInit Image `json:"tinkRelayInit"` @@ -313,7 +335,7 @@ type TinkBundle struct { Nginx Image `json:"nginx"` } -// Tinkerbell hook OS. +// HookBundle defines the Tinkerbell hook OS images used for provisioning. type HookBundle struct { Bootkit Image `json:"bootkit"` Docker Image `json:"docker"` @@ -322,11 +344,13 @@ type HookBundle struct { Vmlinuz HookArch `json:"vmlinuz"` } +// HookArch defines the Tinkerbell hook architecture-specific artifacts. type HookArch struct { Arm Archive `json:"arm"` Amd Archive `json:"amd"` } +// TinkerbellBundle defines Tinkerbell provider images and configurations for this bundle. type TinkerbellBundle struct { Version string `json:"version"` ClusterAPIController Image `json:"clusterAPIController"` @@ -338,10 +362,12 @@ type TinkerbellBundle struct { TinkerbellStack TinkerbellStackBundle `json:"tinkerbellStack,omitempty"` } +// HaproxyBundle defines the HAProxy image used for this bundle. type HaproxyBundle struct { Image Image `json:"image"` } +// SnowBundle defines the Snow provider images and configurations for this bundle. type SnowBundle struct { Version string `json:"version"` Manager Image `json:"manager"` @@ -351,6 +377,7 @@ type SnowBundle struct { BottlerocketBootstrapSnow Image `json:"bottlerocketBootstrapSnow"` } +// NutanixBundle defines the Nutanix provider images and configurations for this bundle. type NutanixBundle struct { ClusterAPIController Image `json:"clusterAPIController"` CloudProvider Image `json:"cloudProvider,omitempty"` diff --git a/release/api/v1alpha1/bundle_types_test.go b/release/api/v1alpha1/bundle_types_test.go index f1000506dc0d9..4bb0ef3aca6b6 100644 --- a/release/api/v1alpha1/bundle_types_test.go +++ b/release/api/v1alpha1/bundle_types_test.go @@ -14,6 +14,7 @@ package v1alpha1_test +//nolint:revive import ( "testing" diff --git a/release/api/v1alpha1/eksarelease.go b/release/api/v1alpha1/eksarelease.go index e6d25fb2fba0e..b2c1cb04e955f 100644 --- a/release/api/v1alpha1/eksarelease.go +++ b/release/api/v1alpha1/eksarelease.go @@ -8,7 +8,7 @@ import ( // EKSAReleaseKind is the Kind of EKSARelease. const EKSAReleaseKind = "EKSARelease" -// Generates the naming convention of EKSARelease from a version. +// GenerateEKSAReleaseName generates the naming convention of EKSARelease from a version. func GenerateEKSAReleaseName(version string) string { version = strings.ReplaceAll(version, "+", "-plus-") return fmt.Sprintf("eksa-%s", strings.ReplaceAll(version, ".", "-")) diff --git a/release/api/v1alpha1/release_types.go b/release/api/v1alpha1/release_types.go index a905b0c732b1b..7ad12f9be5d2c 100644 --- a/release/api/v1alpha1/release_types.go +++ b/release/api/v1alpha1/release_types.go @@ -82,7 +82,7 @@ type EksARelease struct { // +kubebuilder:validation:Required // Manifest url to parse bundle information from for this EKS-A release - BundleManifestUrl string `json:"bundleManifestUrl"` + BundleManifestUrl string `json:"bundleManifestUrl"` //nolint:revive // +kubebuilder:validation:Required // EKS Anywhere binary bundle @@ -93,6 +93,7 @@ type EksARelease struct { EksACLI PlatformBundle `json:"eksACLI"` } +// BinaryBundle defines the EKS Anywhere Linux and Darwin binaries for each release. type BinaryBundle struct { // +kubebuilder:validation:Required // EKS Anywhere Linux binary @@ -103,6 +104,7 @@ type BinaryBundle struct { DarwinBinary Archive `json:"darwin"` } +// PlatformBundle defines the EKS Anywhere binaries by operating system. type PlatformBundle struct { // +kubebuilder:validation:Required // EKS Anywhere Linux binary @@ -113,6 +115,7 @@ type PlatformBundle struct { DarwinBinary ArchitectureBundle `json:"darwin"` } +// ArchitectureBundle defines the per-architecture binaries for an operating system. type ArchitectureBundle struct { Amd64 Archive `json:"amd64"` Arm64 Archive `json:"arm64"`