Skip to content

Commit 62d38c0

Browse files
fix: lints and improve error message
Signed-off-by: Nishchay Rajput <nishchayr@iitbhilai.ac.in>
1 parent 88b7928 commit 62d38c0

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

cmd/harbor/root/jobservice/schedules/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
"github.com/goharbor/harbor-cli/pkg/api"
2020
"github.com/goharbor/harbor-cli/pkg/utils"
21+
jobserviceutils "github.com/goharbor/harbor-cli/pkg/utils/jobservice"
2122
"github.com/goharbor/harbor-cli/pkg/views/jobservice/schedules"
2223
"github.com/spf13/cobra"
2324
"github.com/spf13/viper"
@@ -43,7 +44,7 @@ func ListCommand() *cobra.Command {
4344

4445
response, err := api.ListSchedules(page, pageSize)
4546
if err != nil {
46-
return formatScheduleError("failed to retrieve schedules", err, "ActionList")
47+
return jobserviceutils.FormatScheduleError("failed to retrieve schedules", err, "ActionList")
4748
}
4849

4950
if response == nil || response.Payload == nil || len(response.Payload) == 0 {

cmd/harbor/root/jobservice/schedules/pause_all.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"fmt"
1818

1919
"github.com/goharbor/harbor-cli/pkg/api"
20+
jobserviceutils "github.com/goharbor/harbor-cli/pkg/utils/jobservice"
2021
"github.com/spf13/cobra"
2122
)
2223

@@ -31,7 +32,7 @@ func PauseAllCommand() *cobra.Command {
3132
fmt.Println("Pausing all schedules...")
3233
err := api.ActionJobQueue("SCHEDULER", "pause")
3334
if err != nil {
34-
return formatScheduleError("failed to pause all schedules", err, "ActionStop")
35+
return jobserviceutils.FormatScheduleError("failed to pause all schedules", err, "ActionStop")
3536
}
3637
fmt.Println("✓ All schedules paused successfully.")
3738
return nil

cmd/harbor/root/jobservice/schedules/resume_all.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"fmt"
1818

1919
"github.com/goharbor/harbor-cli/pkg/api"
20+
jobserviceutils "github.com/goharbor/harbor-cli/pkg/utils/jobservice"
2021
"github.com/spf13/cobra"
2122
)
2223

@@ -31,7 +32,7 @@ func ResumeAllCommand() *cobra.Command {
3132
fmt.Println("Resuming all schedules...")
3233
err := api.ActionJobQueue("SCHEDULER", "resume")
3334
if err != nil {
34-
return formatScheduleError("failed to resume all schedules", err, "ActionStop")
35+
return jobserviceutils.FormatScheduleError("failed to resume all schedules", err, "ActionStop")
3536
}
3637
fmt.Println("✓ All schedules resumed successfully.")
3738
return nil

cmd/harbor/root/jobservice/schedules/status.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
"github.com/goharbor/harbor-cli/pkg/api"
2020
"github.com/goharbor/harbor-cli/pkg/utils"
21+
jobserviceutils "github.com/goharbor/harbor-cli/pkg/utils/jobservice"
2122
"github.com/goharbor/harbor-cli/pkg/views/jobservice/schedules"
2223
"github.com/spf13/cobra"
2324
"github.com/spf13/viper"
@@ -33,7 +34,7 @@ func StatusCommand() *cobra.Command {
3334
RunE: func(cmd *cobra.Command, args []string) error {
3435
response, err := api.GetSchedulePaused()
3536
if err != nil {
36-
return formatScheduleError("failed to retrieve scheduler status", err, "authenticated")
37+
return jobserviceutils.FormatScheduleError("failed to retrieve scheduler status", err, "authenticated")
3738
}
3839

3940
if response == nil || response.Payload == nil {

cmd/harbor/root/jobservice/schedules/utils.go renamed to pkg/utils/jobservice/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
package schedules
14+
package jobservice
1515

1616
import (
1717
"fmt"
1818

1919
"github.com/goharbor/harbor-cli/pkg/utils"
2020
)
2121

22-
func formatScheduleError(operation string, err error, requiredPermission string) error {
22+
func FormatScheduleError(operation string, err error, requiredPermission string) error {
2323
errorCode := utils.ParseHarborErrorCode(err)
2424

2525
switch errorCode {

0 commit comments

Comments
 (0)