Skip to content

Commit

Permalink
Fix submission namespace output when including dashes
Browse files Browse the repository at this point in the history
When a new provider or module has been submitted which included a `-` within the namespace of the Git repository, only the last portion of the user or organization was picked.

See opentofu#125 as an example where `metal-stack-cloud/terraform-provider-metal` resulted in a errornous repository url of `https://github.com/cloud/terraform-provider-metal`.
  • Loading branch information
vknabel committed Dec 21, 2023
1 parent 0aaf15b commit c44adbd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cmd/add-module/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func main() {

err = func() error {
// Lower case input
re := regexp.MustCompile("(?P<Namespace>[a-zA-Z0-9]+)/terraform-(?P<Target>[a-zA-Z0-9]*)-(?P<Name>[a-zA-Z0-9-]*)")
re := regexp.MustCompile("(?P<Namespace>[a-zA-Z0-9-]+)/terraform-(?P<Target>[a-zA-Z0-9]*)-(?P<Name>[a-zA-Z0-9-]*)")
match := re.FindStringSubmatch(*repository)
if match == nil {
return fmt.Errorf("Invalid repository name: %s", *repository)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/add-provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func main() {

err = func() error {
// Lower case input
re := regexp.MustCompile("(?P<Namespace>[a-zA-Z0-9]+)/terraform-provider-(?P<Name>[a-zA-Z0-9-]*)")
re := regexp.MustCompile("(?P<Namespace>[a-zA-Z0-9-]+)/terraform-provider-(?P<Name>[a-zA-Z0-9-]*)")
match := re.FindStringSubmatch(strings.ToLower(*repository))
if match == nil {
return fmt.Errorf("Invalid repository name: %s", *repository)
Expand Down

0 comments on commit c44adbd

Please sign in to comment.