Skip to content

Commit

Permalink
[PCD-447] Trim leading and trailing whitespaces (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaypf9 authored Dec 10, 2024
1 parent d70e375 commit ff4c989
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func ConfigCmdCreateAmazonRun(cfg *objects.Config) error {
if cfg.AwsIamUsername == "" {
fmt.Printf("Amazon IAM User: ")
awsIamUsername, _ := reader.ReadString('\n')
cfg.AwsIamUsername = strings.TrimSuffix(awsIamUsername, "\n")
cfg.AwsIamUsername = strings.TrimSpace(awsIamUsername)
}

if cfg.AwsAccessKey == "" {
Expand All @@ -224,7 +224,7 @@ func ConfigCmdCreateAmazonRun(cfg *objects.Config) error {
if cfg.AwsRegion == "" {
fmt.Printf("Region: ")
region, _ = reader.ReadString('\n')
cfg.AwsRegion = strings.TrimSuffix(region, "\n")
cfg.AwsRegion = strings.TrimSpace(region)
}

if cfg.AwsRegion == "" {
Expand Down Expand Up @@ -278,19 +278,19 @@ func ConfigCmdCreateGoogleRun(cfg *objects.Config) error {
if cfg.GooglePath == "" {
fmt.Printf("Service JSON path: ")
googleProjectName, _ := reader.ReadString('\n')
cfg.GoogleProjectName = strings.TrimSuffix(googleProjectName, "\n")
cfg.GoogleProjectName = strings.TrimSpace(googleProjectName)
}

if cfg.GoogleProjectName == "" {
fmt.Printf("Project Name: ")
googleProjectName, _ := reader.ReadString('\n')
cfg.GoogleProjectName = strings.TrimSuffix(googleProjectName, "\n")
cfg.GoogleProjectName = strings.TrimSpace(googleProjectName)
}

if cfg.GoogleServiceEmail == "" {
fmt.Printf("Service Account Email: ")
googleServiceEmail, _ := reader.ReadString('\n')
cfg.GoogleServiceEmail = strings.TrimSuffix(googleServiceEmail, "\n")
cfg.GoogleServiceEmail = strings.TrimSpace(googleServiceEmail)
}

return nil
Expand All @@ -306,13 +306,13 @@ func ConfigCmdCreateRun(cfg *objects.Config) error {
if cfg.Fqdn == "" {
fmt.Printf("Platform9 Account URL: ")
fqdn, _ := reader.ReadString('\n')
cfg.Fqdn = strings.TrimSuffix(fqdn, "\n")
cfg.Fqdn = strings.TrimSpace(fqdn)
}

if cfg.Username == "" {
fmt.Printf("Username: ")
username, _ := reader.ReadString('\n')
cfg.Username = strings.TrimSuffix(username, "\n")
cfg.Username = strings.TrimSpace(username)
}

if cfg.Password == "" {
Expand All @@ -325,19 +325,19 @@ func ConfigCmdCreateRun(cfg *objects.Config) error {
if cfg.Region == "" {
fmt.Printf("Region [RegionOne]: ")
region, _ = reader.ReadString('\n')
cfg.Region = strings.TrimSuffix(region, "\n")
cfg.Region = strings.TrimSpace(region)
}
var service string
if cfg.Tenant == "" {
fmt.Printf("Tenant [service]: ")
service, _ = reader.ReadString('\n')
cfg.Tenant = strings.TrimSuffix(service, "\n")
cfg.Tenant = strings.TrimSpace(service)
}
var proxyURL string
if cfg.ProxyURL == "" {
fmt.Print("Proxy URL [None]: ")
proxyURL, _ = reader.ReadString('\n')
cfg.ProxyURL = strings.TrimSuffix(proxyURL, "\n")
cfg.ProxyURL = strings.TrimSpace(proxyURL)
}

if cfg.Region == "" {
Expand All @@ -352,7 +352,7 @@ func ConfigCmdCreateRun(cfg *objects.Config) error {
if cfg.MfaToken == "" {
fmt.Print("MFA Token [None]: ")
mfaToken, _ = reader.ReadString('\n')
cfg.MfaToken = strings.TrimSuffix(mfaToken, "\n")
cfg.MfaToken = strings.TrimSpace(mfaToken)
}

return SetProxy(cfg.ProxyURL)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pmk/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func Bootstrap(ctx objects.Config, c client.Client, req qbert.ClusterCreateReque
if err != nil {
return fmt.Errorf("Unable to execute command: %w", err)
}
nodeID := strings.TrimSuffix(string(output), "\n")
nodeID := strings.TrimSpace(string(output))

LoopVariable := 1
for LoopVariable <= util.MaxLoopValue {
Expand Down
2 changes: 1 addition & 1 deletion pkg/pmk/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func PrepNode(ctx objects.Config, allClients client.Client, auth keystone.Keysto
s.Restart()
s.Suffix = " Authorising host"
zap.S().Debug("Authorising host")
hostID := strings.TrimSuffix(output, "\n")
hostID := strings.TrimSpace(output)
time.Sleep(ctx.WaitPeriod * time.Second)

if err := allClients.Resmgr.AuthorizeHost(hostID, auth.Token, util.KubeVersion); err != nil {
Expand Down

0 comments on commit ff4c989

Please sign in to comment.