@@ -19,41 +19,45 @@ import (
1919
2020const (
2121 // Under no circumstances can this string change. It is for eternity.
22- ProviderName = "cloudscale"
22+ ProviderName = "cloudscale"
23+
24+ // #nosec G101
2325 AccessToken = "CLOUDSCALE_ACCESS_TOKEN"
2426 ApiUrl = "CLOUDSCALE_API_URL"
2527 ApiTimeout = "CLOUDSCALE_API_TIMEOUT"
2628 DefaultTimeout = time .Duration (20 ) * time .Second
2729)
2830
29- // cloud implements cloudprovider.Interface
31+ // cloud implements cloudprovider.Interface.
3032type cloud struct {
3133 instances * instances
3234 loadbalancer * loadbalancer
3335}
3436
35- // Register this provider with Kubernetes
37+ // Register this provider with Kubernetes.
3638func init () {
3739 cloudprovider .RegisterCloudProvider (ProviderName , newCloudscaleProvider )
3840}
3941
40- // maskAccessToken returns the given token with most of the information hidden
42+ // maskAccessToken returns the given token with most of the information hidden.
4143func maskAccessToken (token string ) string {
4244 if len (token ) < 4 {
4345 return ""
4446 }
47+
4548 return fmt .Sprintf ("%.4s%s" , token , strings .Repeat ("*" , len (token )- 4 ))
4649}
4750
48- // apiTimeout returns the configured timeout or the default one
51+ // apiTimeout returns the configured timeout or the default one.
4952func apiTimeout () time.Duration {
5053 if seconds , _ := strconv .Atoi (os .Getenv (ApiTimeout )); seconds > 0 {
5154 return time .Duration (seconds ) * time .Second
5255 }
56+
5357 return DefaultTimeout
5458}
5559
56- // newCloudscaleProvider creates the provider, ready to be registered
60+ // newCloudscaleProvider creates the provider, ready to be registered.
5761func newCloudscaleProvider (config io.Reader ) (cloudprovider.Interface , error ) {
5862 if config != nil {
5963 klog .Warning ("--cloud-config received but ignored" )
@@ -77,7 +81,7 @@ func newCloudscaleProvider(config io.Reader) (cloudprovider.Interface, error) {
7781 }, nil
7882}
7983
80- // newCloudscaleClient spawns a new cloudscale API client
84+ // newCloudscaleClient spawns a new cloudscale API client.
8185func newCloudscaleClient (
8286 token string , timeout time.Duration ) * cloudscale.Client {
8387
@@ -159,7 +163,7 @@ func (c *cloud) ProviderName() string {
159163 return ProviderName
160164}
161165
162- // HasClusterID returns true if a ClusterID is required and set
166+ // HasClusterID returns true if a ClusterID is required and set.
163167func (c * cloud ) HasClusterID () bool {
164168 return false
165169}
0 commit comments