Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/harbor/root/project/robot/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ Examples:
FormatFlag := viper.GetString("output-format")
if FormatFlag != "" {
name := response.Payload.Name
res, _ := api.GetRobot(response.Payload.ID)
res, err := api.GetRobot(response.Payload.ID)
if err != nil {
return fmt.Errorf("failed to get robot details: %v", utils.ParseHarborErrorMsg(err))
}
utils.SavePayloadJSON(name, res.Payload)
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/harbor/root/robot/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ func createRobotAndHandleResponse(opts *create.CreateView, exportToFile bool) er

// Handle output format
if formatFlag := viper.GetString("output-format"); formatFlag != "" {
res, _ := api.GetRobot(response.Payload.ID)
res, err := api.GetRobot(response.Payload.ID)
if err != nil {
return fmt.Errorf("failed to get robot details: %v", utils.ParseHarborErrorMsg(err))
}
utils.SavePayloadJSON(response.Payload.Name, res.Payload)
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/harbor/root/robot/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,10 @@ func updateRobotAndHandleResponse(opts *update.UpdateView) error {

// Handle output format
if formatFlag := viper.GetString("output-format"); formatFlag != "" {
res, _ := api.GetRobot(opts.ID)
res, err := api.GetRobot(opts.ID)
if err != nil {
return fmt.Errorf("failed to get robot details: %v", utils.ParseHarborErrorMsg(err))
}
Comment on lines +590 to +593
utils.SavePayloadJSON(opts.Name, res.Payload)
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/views/webhook/create/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ func WebhookCreateView(createView *CreateView) error {
Title("Endpoint URL").
Value(&createView.EndpointURL).
Validate(func(str string) error {
return utils.ValidateURL(str)
formattedUrl := utils.FormatUrl(str)
if err := utils.ValidateURL(formattedUrl); err != nil {
return err
}
createView.EndpointURL = formattedUrl
return nil
Comment on lines +86 to +91
}),
huh.NewInput().
Title("Auth Header").
Expand Down
4 changes: 3 additions & 1 deletion pkg/views/webhook/edit/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ func WebhookEditView(editView *EditView) {
if strings.TrimSpace(str) == "" {
return errors.New("endpoint URL cannot be empty")
}
if err := utils.ValidateURL(str); err != nil {
formattedUrl := utils.FormatUrl(str)
if err := utils.ValidateURL(formattedUrl); err != nil {
return err
}
editView.EndpointURL = formattedUrl
Comment on lines 109 to +116
return nil
}),

Expand Down