Skip to content

Commit 02946ce

Browse files
authored
refactor(output): replace log.Info and log.Infof statements with Printf and log.Debugf statements (goharbor#884)
1 parent 2a5ae18 commit 02946ce

39 files changed

Lines changed: 107 additions & 106 deletions

cmd/harbor/root/context/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ If you specify --name, that credential (rather than the "current" one) will be u
8181
}
8282

8383
if found {
84-
logrus.Infof("Removed credential '%s' and cleared CurrentCredentialName", currentName)
84+
logrus.Debugf("Removed credential '%s' and cleared CurrentCredentialName", currentName)
8585
} else {
86-
logrus.Infof("No credential named '%s' found; cleared CurrentCredentialName anyway", currentName)
86+
logrus.Debugf("No credential named '%s' found; cleared CurrentCredentialName anyway", currentName)
8787
}
8888

8989
return nil

cmd/harbor/root/context/update.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ If you specify --name, that credential (rather than the "current" one) will be u
6969

7070
// 5. Confirm to the user (logrus.Info is fine here; no error)
7171
canonicalPath := strings.Join(actualSegments, ".")
72-
logrus.Infof("Successfully updated %s to '%s'", canonicalPath, newValue)
73-
72+
fmt.Printf("Successfully updated %s to '%s'\n", canonicalPath, newValue)
7473
return nil
7574
},
7675
}

cmd/harbor/root/project/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func ListProjectCommand() *cobra.Command {
9393

9494
log.WithField("count", len(allProjects)).Debug("Number of projects fetched")
9595
if len(allProjects) == 0 {
96-
log.Info("No projects found")
96+
fmt.Println("No projects found")
9797
return nil
9898
}
9999
formatFlag := viper.GetString("output-format")

cmd/harbor/root/project/robot/create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Examples:
102102
if loadErr != nil {
103103
return fmt.Errorf("failed to load robot config from file: %v", loadErr)
104104
}
105-
logrus.Info("Successfully loaded robot configuration")
105+
logrus.Debug("Successfully loaded robot configuration")
106106
opts = *loadedOpts
107107
if opts.ProjectName == "" {
108108
opts.ProjectName = opts.Permissions[0].Namespace
@@ -196,7 +196,7 @@ Examples:
196196
return fmt.Errorf("failed to create robot: %v", utils.ParseHarborErrorMsg(err))
197197
}
198198

199-
logrus.Infof("Successfully created robot account '%s' (ID: %d)",
199+
fmt.Printf("Successfully created robot account '%s' (ID: %d)\n",
200200
response.Payload.Name, response.Payload.ID)
201201

202202
FormatFlag := viper.GetString("output-format")
@@ -209,7 +209,7 @@ Examples:
209209
name, secret := response.Payload.Name, response.Payload.Secret
210210

211211
if exportToFile {
212-
logrus.Info("Exporting robot credentials to file")
212+
fmt.Printf("Exporting robot credentials to file\n")
213213
exportSecretToFile(name, secret, response.Payload.CreationTime.String(), response.Payload.ExpiresAt)
214214
return nil
215215
} else {

cmd/harbor/root/project/robot/refresh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Examples:
106106
return fmt.Errorf("failed to refresh robot secret: %v\n", err)
107107
}
108108

109-
log.Info("Secret updated successfully.")
109+
fmt.Println("Secret updated successfully.")
110110

111111
if response.Payload.Secret != "" {
112112
secret = response.Payload.Secret

cmd/harbor/root/quota/update.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/goharbor/harbor-cli/pkg/prompt"
2323
"github.com/goharbor/harbor-cli/pkg/utils"
2424
"github.com/goharbor/harbor-cli/pkg/views/quota/update"
25-
log "github.com/sirupsen/logrus"
2625
"github.com/spf13/cobra"
2726
)
2827

@@ -80,7 +79,7 @@ func UpdateQuotaCommand() *cobra.Command {
8079
return fmt.Errorf("failed to update quota: %v", err)
8180
}
8281

83-
log.Infof("quota updated successfully!")
82+
fmt.Println("Quota updated successfully!")
8483

8584
return nil
8685
},

cmd/harbor/root/registry/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func ListRegistryCommand() *cobra.Command {
4949
return fmt.Errorf("failed to get projects list: %v", err)
5050
}
5151
if len(registry.Payload) == 0 {
52-
log.Info("No registries found")
52+
fmt.Println("No registries found")
5353
return nil
5454
}
5555
formatFlag := viper.GetString("output-format")

cmd/harbor/root/replication/executions/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func ListCommand() *cobra.Command {
6868

6969
log.WithField("count", len(executions.Payload)).Debug("Number of executions fetched")
7070
if len(executions.Payload) == 0 {
71-
log.Info("No executions found")
71+
fmt.Println("No executions found")
7272
return nil
7373
}
7474

cmd/harbor/root/replication/policies/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func ListCommand() *cobra.Command {
5252

5353
log.WithField("count", len(allPolicies.Payload)).Debug("Number of policies fetched")
5454
if len(allPolicies.Payload) == 0 {
55-
log.Info("No policies found")
55+
fmt.Println("No policies found")
5656
return nil
5757
}
5858

cmd/harbor/root/replication/policies/update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func UpdateCommand() *cobra.Command {
9696
}
9797
}
9898

99-
log.Infof("Updating replication policy: %s (ID: %d)", existingPolicy.Payload.Name, policyID)
99+
log.Debugf("Updating replication policy: %s (ID: %d)", existingPolicy.Payload.Name, policyID)
100100
create.CreateRPolicyView(createView, true)
101101

102102
var updatedPolicy *models.ReplicationPolicy
@@ -114,7 +114,7 @@ func UpdateCommand() *cobra.Command {
114114
return fmt.Errorf("failed to update replication policy: %w", err)
115115
}
116116

117-
log.Infof("Successfully updated replication policy: %s (ID: %d)", updatedPolicy.Name, policyID)
117+
fmt.Printf("Successfully updated replication policy: %s (ID: %d)\n", updatedPolicy.Name, policyID)
118118
return nil
119119
},
120120
}

0 commit comments

Comments
 (0)