Skip to content

Commit

Permalink
Fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Shilpa-Gokul committed Feb 9, 2023
1 parent ab667f5 commit 771bb1e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
32 changes: 18 additions & 14 deletions cmd/capibmadm/cmd/powervs/port/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ package port
import (
"context"
"fmt"
"os"

"github.com/spf13/cobra"

client "github.com/IBM-Cloud/power-go-client/clients/instance"
"github.com/IBM-Cloud/power-go-client/power/models"
"github.com/spf13/cobra"
"k8s.io/klog/v2"
"os"

"sigs.k8s.io/cluster-api/cmd/clusterctl/log"

"sigs.k8s.io/cluster-api-provider-ibmcloud/cmd/capibmadm/clients/iam"
"sigs.k8s.io/cluster-api-provider-ibmcloud/cmd/capibmadm/clients/powervs"
"sigs.k8s.io/cluster-api-provider-ibmcloud/cmd/capibmadm/options"
"sigs.k8s.io/cluster-api-provider-ibmcloud/cmd/capibmadm/printer"
"sigs.k8s.io/cluster-api-provider-ibmcloud/cmd/capibmadm/utils"
logf "sigs.k8s.io/cluster-api/cmd/clusterctl/log"
)

type portCreateOptions struct {
Expand All @@ -38,9 +41,10 @@ type portCreateOptions struct {
description string
}

// CreateCommand create powervs network port.
func CreateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "create PORT_NUMBER",
Use: "create",
Short: "Create PowerVS Port",
Example: `
# Create PowerVS port, provided networkID and IPAddress
Expand All @@ -64,8 +68,8 @@ capibmadm powervs port create --network <networdID/Name> --ip-address <IPaddress
}

func createPort(ctx context.Context, portCreateOption portCreateOptions) error {
log := logf.Log
log.Info("Creating Port ", "Network ID/Name", portCreateOption.networkID, "IP Address", portCreateOption.ipAddress, "Description", portCreateOption.description, "service-instance-id", options.GlobalOptions.ServiceInstanceID, "zone", options.GlobalOptions.PowerVSZone)
logger := log.Log
logger.Info("Creating Port ", "Network ID/Name", portCreateOption.networkID, "IP Address", portCreateOption.ipAddress, "Description", portCreateOption.description, "service-instance-id", options.GlobalOptions.ServiceInstanceID, "zone", options.GlobalOptions.PowerVSZone)
accountID, err := utils.GetAccountID(ctx, iam.GetIAMAuth())
if err != nil {
return err
Expand Down Expand Up @@ -102,13 +106,13 @@ func createPort(ctx context.Context, portCreateOption portCreateOptions) error {
if err != nil {
return fmt.Errorf("failed to create a port, err: %v", err)
}
klog.Infof("Successfully created a port, id: %s", *port.PortID)
logger.Info("Successfully created a port", "portID", *port.PortID)

portInfo := PortList{
Items: []PortSpec{},
portInfo := List{
Items: []Spec{},
}

portInfo.Items = append(portInfo.Items, PortSpec{
portInfo.Items = append(portInfo.Items, Spec{
Description: utils.DereferencePointer(port.Description).(string),
ExternalIP: port.ExternalIP,
IPAddress: utils.DereferencePointer(port.IPAddress).(string),
Expand All @@ -124,9 +128,9 @@ func createPort(ctx context.Context, portCreateOption portCreateOptions) error {

if options.GlobalOptions.Output == printer.PrinterTypeTable {
table := portInfo.ToTable()
printerObj.Print(table)
err = printerObj.Print(table)
} else {
printerObj.Print(portInfo)
err = printerObj.Print(portInfo)
}
return nil
return err
}
12 changes: 6 additions & 6 deletions cmd/capibmadm/cmd/powervs/port/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// PortSpec defines a port
type PortSpec struct {
// Spec defines a port.
type Spec struct {
PortID string `json:"id"`
Description string `json:"description"`
ExternalIP string `json:"externalIP,omitempty"`
Expand All @@ -27,13 +27,13 @@ type PortSpec struct {
Status string `json:"status"`
}

// PortList defines a list of Ports.
type PortList struct {
Items []PortSpec `json:"items"`
// List defines a list of Ports.
type List struct {
Items []Spec `json:"items"`
}

// ToTable converts List to *metav1.Table.
func (portList *PortList) ToTable() *metav1.Table {
func (portList *List) ToTable() *metav1.Table {
table := &metav1.Table{
TypeMeta: metav1.TypeMeta{
APIVersion: metav1.SchemeGroupVersion.String(),
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down

0 comments on commit 771bb1e

Please sign in to comment.