Skip to content

Commit ffc9a86

Browse files
feat: [AH-1598]: fix bugbash issues
1 parent 6bfc438 commit ffc9a86

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cmd/ar/command/push_go.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func NewPushGoCmd(c *client.ClientWithResponses) *cobra.Command {
136136
// Check response
137137
if resp.StatusCode() != http.StatusOK && resp.StatusCode() != http.StatusCreated {
138138
progress.Error("Upload failed")
139-
return fmt.Errorf("failed to push package: %s", resp.Status())
139+
return fmt.Errorf("failed to push package: %s \n response: %s", resp.Status(), resp.Body)
140140
}
141141

142142
progress.Success(fmt.Sprintf("Successfully uploaded package %s", packageName))

module/ar/packages/gopkg/impl.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import (
1717
"github.com/harness/harness-cli/util/common/vcs"
1818
)
1919

20+
const (
21+
ModulePathRegex = `^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+(?:/[a-z0-9][a-z0-9._-]*)*$`
22+
)
23+
2024
// DefaultGenerator provides the default implementation of package generation interfaces.
2125
// It combines the default implementations of ModuleValidator, FileGenerator, and
2226
// VCSMetadataProvider to provide a complete package generation solution.
@@ -66,6 +70,10 @@ func (v *defaultModuleValidator) ValidateModulePath(modulePath, version string)
6670
return errors.NewValidationError("version", err.Error())
6771
}
6872

73+
if !regexp.MustCompile(ModulePathRegex).MatchString(modulePath) {
74+
return errors.NewValidationError("module_path", "module path must match regex "+ModulePathRegex)
75+
}
76+
6977
if major <= 1 {
7078
if strings.HasSuffix(modulePath, "/v2") || strings.HasSuffix(modulePath, fmt.Sprintf("/v%d", major+1)) {
7179
return errors.NewValidationError("module_path", "module path must not have /vN suffix for v1 or below")

0 commit comments

Comments
 (0)