Skip to content

Commit 6b8c2e0

Browse files
humbleck8s-ci-robot
authored andcommitted
Use better variable names and remove unwanted code blocks. (kubernetes#72847)
* Use better variable names and remove unwanted code blocks. Signed-off-by: hchiramm <[email protected]> * Simplify return from InstanceID func() Signed-off-by: Humble Chirammal <[email protected]>
1 parent 4eddb77 commit 6b8c2e0

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

pkg/cloudprovider/providers/photon/photon.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ const (
5353
// overrideIP indicates if the hostname is overridden by IP address, such as when
5454
// running multi-node kubernetes using docker. In this case the user should set
5555
// overrideIP = true in cloud config file. Default value is false.
56-
var overrideIP bool = false
56+
var overrideIP = false
5757

5858
var _ cloudprovider.Interface = (*PCCloud)(nil)
5959
var _ cloudprovider.Instances = (*PCCloud)(nil)
6060
var _ cloudprovider.Zones = (*PCCloud)(nil)
6161

62-
// Photon is an implementation of the cloud provider interface for Photon Controller.
62+
// PCCloud is an implementation of the cloud provider interface for Photon Controller.
6363
type PCCloud struct {
6464
cfg *PCConfig
6565
// InstanceID of the server where this PCCloud object is instantiated.
@@ -213,7 +213,7 @@ func getVMIDbyIP(pc *PCCloud, IPAddress string) (string, error) {
213213
func getPhotonClient(pc *PCCloud) (*photon.Client, error) {
214214
var err error
215215
if len(pc.cfg.Global.CloudTarget) == 0 {
216-
return nil, fmt.Errorf("Photon Controller endpoint was not specified.")
216+
return nil, fmt.Errorf("Photon Controller endpoint was not specified")
217217
}
218218

219219
options := &photon.ClientOptions{
@@ -241,7 +241,7 @@ func getPhotonClient(pc *PCCloud) (*photon.Client, error) {
241241
}
242242
password := scanner.Text()
243243

244-
token_options, err := pc.photonClient.Auth.GetTokensByPassword(username, password)
244+
tokenOptions, err := pc.photonClient.Auth.GetTokensByPassword(username, password)
245245
if err != nil {
246246
klog.Error("Photon Cloud Provider: failed to get tokens by password")
247247
return nil, err
@@ -250,7 +250,7 @@ func getPhotonClient(pc *PCCloud) (*photon.Client, error) {
250250
options = &photon.ClientOptions{
251251
IgnoreCertificate: true,
252252
TokenOptions: &photon.TokenOptions{
253-
AccessToken: token_options.AccessToken,
253+
AccessToken: tokenOptions.AccessToken,
254254
},
255255
}
256256
pc.photonClient = photon.NewClient(pc.cfg.Global.CloudTarget, options, pc.logger)
@@ -474,16 +474,14 @@ func (pc *PCCloud) InstanceID(ctx context.Context, nodeName k8stypes.NodeName) (
474474
name := string(nodeName)
475475
if name == pc.localK8sHostname {
476476
return pc.localInstanceID, nil
477-
} else {
478-
// We assume only master need to get InstanceID of a node other than itself
479-
ID, err := getInstanceID(pc, name)
480-
if err != nil {
481-
klog.Errorf("Photon Cloud Provider: getInstanceID failed for InstanceID. Error[%v]", err)
482-
return ID, err
483-
} else {
484-
return ID, nil
485-
}
486477
}
478+
// We assume only master need to get InstanceID of a node other than itself
479+
id, err := getInstanceID(pc, name)
480+
if err != nil {
481+
klog.Errorf("Photon Cloud Provider: getInstanceID failed for InstanceID. Error[%v]", err)
482+
}
483+
return id, err
484+
487485
}
488486

489487
// InstanceTypeByProviderID returns the cloudprovider instance type of the node with the specified unique providerID
@@ -544,7 +542,7 @@ func (pc *PCCloud) HasClusterID() bool {
544542
return true
545543
}
546544

547-
// Attaches given virtual disk volume to the compute running kubelet.
545+
// AttachDisk attaches given virtual disk volume to the compute running kubelet.
548546
func (pc *PCCloud) AttachDisk(ctx context.Context, pdID string, nodeName k8stypes.NodeName) error {
549547
photonClient, err := getPhotonClient(pc)
550548
if err != nil {
@@ -712,7 +710,7 @@ func (pc *PCCloud) CreateDisk(volumeOptions *VolumeOptions) (pdID string, err er
712710
return waitTask.Entity.ID, nil
713711
}
714712

715-
// Deletes a volume given volume name.
713+
// DeleteDisk deletes a volume given volume name.
716714
func (pc *PCCloud) DeleteDisk(pdID string) error {
717715
photonClient, err := getPhotonClient(pc)
718716
if err != nil {

0 commit comments

Comments
 (0)