Skip to content

Commit

Permalink
Fixing golangci lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Hein <me@chrishein.com>
  • Loading branch information
christopherhein committed Jun 8, 2021
1 parent 76719ee commit 5deaa15
Show file tree
Hide file tree
Showing 35 changed files with 382 additions and 255 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ manager-nested-controlplane: ## Build manager binary
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen

$(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod # Build golangci-lint from tools folder.
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
$(GOLANGCI_LINT): # Download golanci-lint using hack script into tools folder.
hack/ensure-golangci-lint.sh \
-b $(TOOLS_DIR)/$(BIN_DIR) \
v1.40.1

$(RELEASE_NOTES): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && go build -tags=tools -o $(RELEASE_NOTES_BIN) sigs.k8s.io/cluster-api/hack/tools/release
Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha4/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha4 contains API Schema definitions for the infrastructure v1alpha4 API group
//+kubebuilder:object:generate=true
//+groupName=infrastructure.cluster.x-k8s.io
// Package v1alpha4 contains API Schema definitions for the infrastructure v1alpha4 API group.
// +kubebuilder:object:generate=true
// +groupName=infrastructure.cluster.x-k8s.io
package v1alpha4

import (
Expand All @@ -25,10 +25,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha4"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
8 changes: 4 additions & 4 deletions api/v1alpha4/nestedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
)

// NestedClusterSpec defines the desired state of NestedCluster
// NestedClusterSpec defines the desired state of NestedCluster.
type NestedClusterSpec struct {
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
}

// NestedClusterStatus defines the observed state of NestedCluster
// NestedClusterStatus defines the observed state of NestedCluster.
type NestedClusterStatus struct {
// Ready is when the NestedControlPlane has a API server URL.
// +optional
Expand All @@ -41,7 +41,7 @@ type NestedClusterStatus struct {
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
//+kubebuilder:subresource:status

// NestedCluster is the Schema for the nestedclusters API
// NestedCluster is the Schema for the nestedclusters API.
type NestedCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -52,7 +52,7 @@ type NestedCluster struct {

//+kubebuilder:object:root=true

// NestedClusterList contains a list of NestedCluster
// NestedClusterList contains a list of NestedCluster.
type NestedClusterList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1-0.20201002000720-57250aac17f6
controller-gen.kubebuilder.io/version: v0.6.0-beta.0
creationTimestamp: null
name: nestedclusters.infrastructure.cluster.x-k8s.io
spec:
Expand All @@ -31,21 +31,26 @@ spec:
name: v1alpha4
schema:
openAPIV3Schema:
description: NestedCluster is the Schema for the nestedclusters API
description: NestedCluster is the Schema for the nestedclusters API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: NestedClusterSpec defines the desired state of NestedCluster
description: NestedClusterSpec defines the desired state of NestedCluster.
properties:
controlPlaneEndpoint:
description: ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
description: ControlPlaneEndpoint represents the endpoint used to
communicate with the control plane.
properties:
host:
description: The hostname on which the API server is serving.
Expand All @@ -60,10 +65,11 @@ spec:
type: object
type: object
status:
description: NestedClusterStatus defines the observed state of NestedCluster
description: NestedClusterStatus defines the observed state of NestedCluster.
properties:
ready:
description: Ready is when the NestedControlPlane has a API server URL.
description: Ready is when the NestedControlPlane has a API server
URL.
type: boolean
type: object
type: object
Expand Down
4 changes: 3 additions & 1 deletion controllers/nestedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package controllers contains all the Infrastructure group controllers for
// running nested clusters.
package controllers

import (
Expand All @@ -37,7 +39,7 @@ import (
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=nestedclusters/finalizers,verbs=update
//+kubebuilder:rbac:groups=controlplane.cluster.x-k8s.io,resources=nestedcontrolplanes,verbs=get;list;watch

// NestedClusterReconciler reconciles a NestedCluster object
// NestedClusterReconciler reconciles a NestedCluster object.
type NestedClusterReconciler struct {
client.Client
Log logr.Logger
Expand Down
6 changes: 3 additions & 3 deletions controlplane/nested/api/v1alpha4/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha4 contains API Schema definitions for the controlplane v1alpha4 API group
// Package v1alpha4 contains API Schema definitions for the controlplane v1alpha4 API group.
// +kubebuilder:object:generate=true
// +groupName=controlplane.cluster.x-k8s.io
package v1alpha4
Expand All @@ -25,10 +25,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "controlplane.cluster.x-k8s.io", Version: "v1alpha4"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
24 changes: 12 additions & 12 deletions controlplane/nested/api/v1alpha4/nestedapiserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ import (
addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1"
)

// NestedAPIServerSpec defines the desired state of NestedAPIServer
// NestedAPIServerSpec defines the desired state of NestedAPIServer.
type NestedAPIServerSpec struct {
// NestedComponentSpec contains the common and user-specified information that are
// required for creating the component
// required for creating the component.
// +optional
NestedComponentSpec `json:",inline"`
}

// NestedAPIServerStatus defines the observed state of NestedAPIServer
// NestedAPIServerStatus defines the observed state of NestedAPIServer.
type NestedAPIServerStatus struct {
// APIServerService is the reference to the service that expose the APIServer
// APIServerService is the reference to the service that expose the APIServer.
// +optional
APIServerService *corev1.ObjectReference `json:"apiserverService,omitempty"`

// CommonStatus allows addons status monitoring
// CommonStatus allows addons status monitoring.
addonv1alpha1.CommonStatus `json:",inline"`
}

Expand All @@ -46,7 +46,7 @@ type NestedAPIServerStatus struct {
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
//+kubebuilder:subresource:status

// NestedAPIServer is the Schema for the nestedapiservers API
// NestedAPIServer is the Schema for the nestedapiservers API.
type NestedAPIServer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -57,7 +57,7 @@ type NestedAPIServer struct {

//+kubebuilder:object:root=true

// NestedAPIServerList contains a list of NestedAPIServer
// NestedAPIServerList contains a list of NestedAPIServer.
type NestedAPIServerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -72,30 +72,30 @@ var _ addonv1alpha1.CommonObject = &NestedAPIServer{}
var _ addonv1alpha1.Patchable = &NestedAPIServer{}

// ComponentName returns the name of the component for use with
// addonv1alpha1.CommonObject
// addonv1alpha1.CommonObject.
func (c *NestedAPIServer) ComponentName() string {
return string(APIServer)
}

// CommonSpec returns the addons spec of the object allowing common funcs like
// Channel & Version to be usable
// Channel & Version to be usable.
func (c *NestedAPIServer) CommonSpec() addonv1alpha1.CommonSpec {
return c.Spec.CommonSpec
}

// GetCommonStatus will return the common status for checking is a component
// was successfully deployed
// was successfully deployed.
func (c *NestedAPIServer) GetCommonStatus() addonv1alpha1.CommonStatus {
return c.Status.CommonStatus
}

// SetCommonStatus will set the status so that abstract representations can set
// Ready and Phases
// Ready and Phases.
func (c *NestedAPIServer) SetCommonStatus(s addonv1alpha1.CommonStatus) {
c.Status.CommonStatus = s
}

// PatchSpec returns the patches to be applied
// PatchSpec returns the patches to be applied.
func (c *NestedAPIServer) PatchSpec() addonv1alpha1.PatchSpec {
return c.Spec.PatchSpec
}
25 changes: 17 additions & 8 deletions controlplane/nested/api/v1alpha4/nestedcomponent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,47 @@ import (
addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1"
)

// NestedComponentSpec defines the common fields for nested components
// NestedComponentSpec defines the common fields for nested components.
type NestedComponentSpec struct {
// NestedComponentSpec defines the common information for creating the
// component
// component.
// +optional
addonv1alpha1.CommonSpec `json:",inline"`

// PatchSpecs includes the user specified settings
// PatchSpecs includes the user specified settings.
// +optional
addonv1alpha1.PatchSpec `json:",inline"`

// Resources defines the amount of computing resources that will be used
// by this component
// by this component.
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// Replicas defines the number of replicas in the component's workload
// Replicas defines the number of replicas in the component's workload.
// +optional
Replicas int32 `json:"replicas,omitempty"`
}

// ComponentPhase defines the state of the component.
type ComponentPhase string

const (
Ready ComponentPhase = "Ready"
// Ready defines that the component is available and control plane can
// continue provisioning.
Ready ComponentPhase = "Ready"

// Unready defines that the component is unavailable.
Unready ComponentPhase = "Unready"
)

// ComponentKind defines the available kinds.
type ComponentKind string

const (
APIServer ComponentKind = "NestedAPIServer"
Etcd ComponentKind = "NestedEtcd"
// APIServer defines the Kind name for the apiserver.
APIServer ComponentKind = "NestedAPIServer"
// Etcd defines the Kind name for the etcd.
Etcd ComponentKind = "NestedEtcd"
// ControllerManager defines the kind name for the controller-manager.
ControllerManager ComponentKind = "NestedControllerManager"
)
22 changes: 11 additions & 11 deletions controlplane/nested/api/v1alpha4/nestedcontrollermanager_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import (
addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1"
)

// NestedControllerManagerSpec defines the desired state of NestedControllerManager
// NestedControllerManagerSpec defines the desired state of NestedControllerManager.
type NestedControllerManagerSpec struct {
// NestedComponentSpec contains the common and user-specified information
// that are required for creating the component
// that are required for creating the component.
// +optional
NestedComponentSpec `json:",inline"`
}

// NestedControllerManagerStatus defines the observed state of NestedControllerManager
// NestedControllerManagerStatus defines the observed state of NestedControllerManager.
type NestedControllerManagerStatus struct {
// CommonStatus allows addons status monitoring
// CommonStatus allows addons status monitoring.
addonv1alpha1.CommonStatus `json:",inline"`
}

Expand All @@ -41,7 +41,7 @@ type NestedControllerManagerStatus struct {
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
//+kubebuilder:subresource:status

// NestedControllerManager is the Schema for the nestedcontrollermanagers API
// NestedControllerManager is the Schema for the nestedcontrollermanagers API.
type NestedControllerManager struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -52,7 +52,7 @@ type NestedControllerManager struct {

//+kubebuilder:object:root=true

// NestedControllerManagerList contains a list of NestedControllerManager
// NestedControllerManagerList contains a list of NestedControllerManager.
type NestedControllerManagerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -67,30 +67,30 @@ var _ addonv1alpha1.CommonObject = &NestedControllerManager{}
var _ addonv1alpha1.Patchable = &NestedControllerManager{}

// ComponentName returns the name of the component for use with
// addonv1alpha1.CommonObject
// addonv1alpha1.CommonObject.
func (c *NestedControllerManager) ComponentName() string {
return string(ControllerManager)
}

// CommonSpec returns the addons spec of the object allowing common funcs like
// Channel & Version to be usable
// Channel & Version to be usable.
func (c *NestedControllerManager) CommonSpec() addonv1alpha1.CommonSpec {
return c.Spec.CommonSpec
}

// GetCommonStatus will return the common status for checking is a component
// was successfully deployed
// was successfully deployed.
func (c *NestedControllerManager) GetCommonStatus() addonv1alpha1.CommonStatus {
return c.Status.CommonStatus
}

// SetCommonStatus will set the status so that abstract representations can set
// Ready and Phases
// Ready and Phases.
func (c *NestedControllerManager) SetCommonStatus(s addonv1alpha1.CommonStatus) {
c.Status.CommonStatus = s
}

// PatchSpec returns the patches to be applied
// PatchSpec returns the patches to be applied.
func (c *NestedControllerManager) PatchSpec() addonv1alpha1.PatchSpec {
return c.Spec.PatchSpec
}

0 comments on commit 5deaa15

Please sign in to comment.