Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: futuretea <[email protected]>
  • Loading branch information
futuretea committed Sep 19, 2023
1 parent 84f2534 commit 852276f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions internal/graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ func ResolveDependents(m meta.RESTMapper, objects []unstructuredv1.Unstructured,

// resolveDeps resolves all dependencies or dependents of the provided objects
// and returns a relationship tree.
//
//nolint:funlen,gocognit,gocyclo
func resolveDeps(m meta.RESTMapper, objects []unstructuredv1.Unstructured, uids []types.UID, depsIsDependencies bool) (NodeMap, error) {
if len(uids) == 0 {
Expand Down
14 changes: 10 additions & 4 deletions internal/graph/kubernetes.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package graph

import (
"k8s.io/klog/v2"
"strings"

lhv1beta2 "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
Expand All @@ -24,6 +23,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apiserver/pkg/authentication/serviceaccount"
"k8s.io/apiserver/pkg/authentication/user"
"k8s.io/klog/v2"
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
kubevirtv1 "kubevirt.io/api/core/v1"
)
Expand Down Expand Up @@ -209,6 +209,7 @@ func getClusterRoleRelationships(n *Node) (*RelationshipMap, error) {
// getClusterRoleBindingRelationships returns a map of relationships that this
// ClusterRoleBinding has with other objects, based on what was referenced in
// its manifest.
//
//nolint:gocognit
func getClusterRoleBindingRelationships(n *Node) (*RelationshipMap, error) {
var crb rbacv1.ClusterRoleBinding
Expand Down Expand Up @@ -313,6 +314,7 @@ func getCSIStorageCapacityRelationships(n *Node) (*RelationshipMap, error) {

// getEventRelationships returns a map of relationships that this Event has with
// other objects, based on what was referenced in its manifest.
//
//nolint:unparam
func getEventRelationships(n *Node) (*RelationshipMap, error) {
result := newRelationshipMap()
Expand All @@ -335,6 +337,7 @@ func getEventRelationships(n *Node) (*RelationshipMap, error) {

// getIngressRelationships returns a map of relationships that this Ingress has
// with other objects, based on what was referenced in its manifest.
//
//nolint:funlen,gocognit
func getIngressRelationships(n *Node) (*RelationshipMap, error) {
var ref ObjectReference
Expand Down Expand Up @@ -603,9 +606,9 @@ func getPersistentVolumeClaimRelationships(n *Node) (*RelationshipMap, error) {
}
}

if imageId := pvc.Annotations["harvesterhci.io/imageId"]; imageId != "" {
klog.V(4).Infof("Found imageId %s in PVC %s/%s", imageId, pvc.Namespace, pvc.Name)
nn := strings.SplitN(imageId, "/", 2)
if imageID := pvc.Annotations["harvesterhci.io/imageId"]; imageID != "" {
klog.V(4).Infof("Found imageId %s in PVC %s/%s", imageID, pvc.Namespace, pvc.Name)
nn := strings.SplitN(imageID, "/", 2)
ref = ObjectReference{Kind: "VirtualMachineImage", Name: nn[1], Namespace: nn[0]}
result.AddDependentByKey(ref.Key(), RelationshipPersistentVolumeClaimVMImage)
}
Expand Down Expand Up @@ -757,6 +760,7 @@ func getVMIRelationships(n *Node) (*RelationshipMap, error) {

// getPodRelationships returns a map of relationships that this Pod has with
// other objects, based on what was referenced in its manifest.
//
//nolint:funlen,gocognit
func getPodRelationships(n *Node) (*RelationshipMap, error) {
var pod corev1.Pod
Expand Down Expand Up @@ -970,6 +974,7 @@ func getRoleRelationships(n *Node) (*RelationshipMap, error) {
// getRoleBindingRelationships returns a map of relationships that this
// RoleBinding has with other objects, based on what was referenced in its
// manifest.
//
//nolint:funlen,gocognit
func getRoleBindingRelationships(n *Node) (*RelationshipMap, error) {
var rb rbacv1.RoleBinding
Expand Down Expand Up @@ -1164,6 +1169,7 @@ func getValidatingWebhookConfigurationRelationships(n *Node) (*RelationshipMap,
// getVolumeAttachmentRelationships returns a map of relationships that this
// VolumeAttachment has with other objects, based on what was referenced in its
// manifest.
//
//nolint:funlen,nestif
func getVolumeAttachmentRelationships(n *Node) (*RelationshipMap, error) {
var va storagev1.VolumeAttachment
Expand Down
10 changes: 10 additions & 0 deletions internal/printers/printers_humanreadable.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func getAPIServiceReadyStatus(u *unstructuredv1.Unstructured) (string, string, e
// getDaemonSetReadyStatus returns the ready & status value of a DaemonSet
// which is based off the table cell values computed by printDaemonSet from
// https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/printers/internalversion/printers.go.
//
//nolint:unparam
func getDaemonSetReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {
var ds appsv1.DaemonSet
Expand All @@ -203,6 +204,7 @@ func getDaemonSetReadyStatus(u *unstructuredv1.Unstructured) (string, string, er
// getDeploymentReadyStatus returns the ready & status value of a Deployment
// which is based off the table cell values computed by printDeployment from
// https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/printers/internalversion/printers.go.
//
//nolint:unparam
func getDeploymentReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {
var deploy appsv1.Deployment
Expand All @@ -218,6 +220,7 @@ func getDeploymentReadyStatus(u *unstructuredv1.Unstructured) (string, string, e
}

// getEventCoreReadyStatus returns the ready & status value of a Event.
//
//nolint:unparam
func getEventCoreReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {
var status string
Expand All @@ -236,6 +239,7 @@ func getEventCoreReadyStatus(u *unstructuredv1.Unstructured) (string, string, er
}

// getEventReadyStatus returns the ready & status value of a Event.events.k8s.io.
//
//nolint:unparam
func getEventReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {
var status string
Expand All @@ -256,6 +260,7 @@ func getEventReadyStatus(u *unstructuredv1.Unstructured) (string, string, error)
// getPodReadyStatus returns the ready & status value of a Pod which is based
// off the table cell values computed by printPod from
// https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/printers/internalversion/printers.go.
//
//nolint:funlen,gocognit,gocyclo
func getPodReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {
var pod corev1.Pod
Expand Down Expand Up @@ -336,6 +341,7 @@ func getPodReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {

// getPodDisruptionBudgetReadyStatus returns the ready & status value of a
// PodDisruptionBudget.
//
//nolint:unparam
func getPodDisruptionBudgetReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {
var pdb policyv1.PodDisruptionBudget
Expand All @@ -358,6 +364,7 @@ func getPodDisruptionBudgetReadyStatus(u *unstructuredv1.Unstructured) (string,
// getReplicaSetReadyStatus returns the ready & status value of a ReplicaSet
// which is based off the table cell values computed by printReplicaSet from
// https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/printers/internalversion/printers.go.
//
//nolint:unparam
func getReplicaSetReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {
var rs appsv1.ReplicaSet
Expand All @@ -376,6 +383,7 @@ func getReplicaSetReadyStatus(u *unstructuredv1.Unstructured) (string, string, e
// ReplicationController which is based off the table cell values computed by
// printReplicationController from
// https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/printers/internalversion/printers.go.
//
//nolint:unparam
func getReplicationControllerReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {
var rc corev1.ReplicationController
Expand All @@ -393,6 +401,7 @@ func getReplicationControllerReadyStatus(u *unstructuredv1.Unstructured) (string
// getStatefulSetReadyStatus returns the ready & status value of a StatefulSet
// which is based off the table cell values computed by printStatefulSet from
// https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/printers/internalversion/printers.go.
//
//nolint:unparam
func getStatefulSetReadyStatus(u *unstructuredv1.Unstructured) (string, string, error) {
var sts appsv1.StatefulSet
Expand Down Expand Up @@ -436,6 +445,7 @@ func getVolumeAttachmentReadyStatus(u *unstructuredv1.Unstructured) (string, str
}

// nodeToTableRow converts the provided node into a table row.
//
//nolint:funlen,gocognit,goconst
func nodeToTableRow(node *graph.Node, rset graph.RelationshipSet, namePrefix string, showGroupFn func(kind string) bool) metav1.TableRow {
var name, ready, status, age string
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package helm
import (
"context"
"fmt"
"k8s.io/kubectl/pkg/util/completion"
"os"
"strings"

"k8s.io/kubectl/pkg/util/completion"

"github.com/spf13/cobra"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/release"
Expand Down Expand Up @@ -187,6 +188,7 @@ func (o *CmdOptions) Validate() error {
}

// Run implements all the necessary functionality for the helm command.
//
//nolint:funlen,gocognit,gocyclo
func (o *CmdOptions) Run() error {
ctx := context.Background()
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/lineage/lineage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package lineage
import (
"context"
"fmt"
"k8s.io/kubectl/pkg/util/completion"
"strings"

"k8s.io/kubectl/pkg/util/completion"

"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/types"
"k8s.io/cli-runtime/pkg/genericclioptions"
Expand Down Expand Up @@ -189,6 +190,7 @@ func (o *CmdOptions) Validate() error {
}

// Run implements all the necessary functionality for the lineage command.
//
//nolint:funlen
func (o *CmdOptions) Run() error {
ctx := context.Background()
Expand Down

0 comments on commit 852276f

Please sign in to comment.