Skip to content

Commit

Permalink
code refactor + change regex for github url validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jajita committed Oct 4, 2024
1 parent 835c7e3 commit 9a1d40e
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 8 deletions.
2 changes: 0 additions & 2 deletions internal/commands/update_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func (u UpdateRelease) Execute(args []string) error {
StemcellOS: kilnfileLock.Stemcell.OS,
GitHubRepository: releaseSpec.GitHubRepository,
}, false)

if err != nil {
if component.IsErrNotFound(err) {
return fmt.Errorf("error finding the release: %w", err)
Expand All @@ -99,7 +98,6 @@ func (u UpdateRelease) Execute(args []string) error {
StemcellVersion: kilnfileLock.Stemcell.Version,
GitHubRepository: releaseSpec.GitHubRepository,
})

if err != nil {
if component.IsErrNotFound(err) {
return fmt.Errorf("error finding the release: %w", err)
Expand Down
1 change: 0 additions & 1 deletion internal/commands/update_stemcell.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (update UpdateStemcell) Execute(args []string) error {

kilnStemcellVersion := kilnfile.Stemcell.Version
releaseVersionConstraint, err = semver.NewConstraint(kilnStemcellVersion)

if err != nil {
return fmt.Errorf("invalid stemcell constraint in kilnfile: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/gh/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func RepositoryHostOwnerAndNameFromPath(urlStr string) (string, string, string,
return fmt.Errorf("failed to parse owner and repo name from URI %q: %w", urlStr, err)
}
if strings.HasPrefix(urlStr, "git@") {
exp := regexp.MustCompile(`git@(?P<host>.*):(?P<owner>[^/]+)/(?P<name>.+)\.git`)
exp := regexp.MustCompile(`git@(?P<host>.+):(?P<owner>[^/]+)/(?P<name>.+)\.git`)
m := exp.FindStringSubmatch(urlStr)
if m == nil {
return "", "", "", fmt.Errorf("path missing expected parts")
Expand Down
3 changes: 2 additions & 1 deletion pkg/cargo/kilnfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"errors"
"fmt"
"strings"

"github.com/google/go-github/v50/github"
"golang.org/x/oauth2"
"strings"

"gopkg.in/yaml.v3"

Expand Down
1 change: 0 additions & 1 deletion pkg/planitest/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func MergeAdditionalProductProperties(configFile io.Reader, additionalProperties

var inputConfig ProductConfiguration
err = yaml.Unmarshal(yamlInput, &inputConfig)

if err != nil {
return nil, fmt.Errorf("could not parse config file: %s", err)
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/planitest/internal/om_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func (o OMRunner) ResetAndConfigure(productName string, productVersion string, c
"--product-name", productName,
"--product-version", productVersion,
)

if err != nil {
return fmt.Errorf("Unable to stage product %q, version %q: %s: %s",
productName, productVersion, err, errOutput)
Expand All @@ -114,7 +113,6 @@ func (o OMRunner) ResetAndConfigure(productName string, productVersion string, c
"configure-product",
"--config", configFile.Name(),
)

if err != nil {
return fmt.Errorf("Unable to configure product %q: %s: %s", productName, err, errOutput)
}
Expand Down

0 comments on commit 9a1d40e

Please sign in to comment.