Skip to content

Commit

Permalink
chore: remove git-urls deps (#6726)
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
  • Loading branch information
yesnault authored Dec 11, 2023
1 parent 78d7b75 commit cc8d00b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 23 deletions.
10 changes: 3 additions & 7 deletions cli/cdsctl/workflow_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

repo "github.com/fsamin/go-repo"
"github.com/rockbears/log"
giturls "github.com/whilp/git-urls"

"github.com/ovh/cds/cli"
"github.com/ovh/cds/sdk"
Expand Down Expand Up @@ -101,7 +100,6 @@ func interactiveChooseProject(gitRepo repo.Repo, defaultValue string) (string, e
func interactiveChooseVCSServer(proj *sdk.Project, gitRepo repo.Repo) (string, error) {
switch len(proj.VCSServers) {
case 0:
//TODO ask to link the project
return "", cli.NewError("your CDS project must be linked to a repositories manager to perform this operation")
case 1:
return proj.VCSServers[0].Name, nil
Expand All @@ -110,12 +108,10 @@ func interactiveChooseVCSServer(proj *sdk.Project, gitRepo repo.Repo) (string, e
if err != nil {
return "", cli.WrapError(err, "Unable to get remote URL")
}

originURL, err := giturls.Parse(fetchURL)
if err != nil {
return "", cli.WrapError(err, "Unable to parse remote URL")
if !strings.HasPrefix(fetchURL, "https://") && !strings.HasPrefix(fetchURL, "ssh://") {
return "", cli.NewError("Unable to parse remote URL %v", fetchURL)
}
originHost := strings.TrimSpace(strings.SplitN(originURL.Host, ":", 2)[0])
originHost := strings.TrimSpace(strings.SplitN(fetchURL, ":", 2)[0])

vcsConf, err := client.VCSConfiguration()
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions engine/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func (a *API) Serve(ctx context.Context) error {
return sdk.WrapError(err, "unable to initialize the JWT Layer")
}

// Intialize service mesh httpclient
// Initialize service mesh httpclient
if a.Config.InternalServiceMesh.RequestSecondsTimeout == 0 {
a.Config.InternalServiceMesh.RequestSecondsTimeout = 60
}
Expand Down Expand Up @@ -583,7 +583,7 @@ func (a *API) Serve(ctx context.Context) error {
}

log.Info(ctx, "Initializing database connection...")
//Intialize database
// Initialize database
a.DBConnectionFactory, err = database.Init(ctx, a.Config.Database)
if err != nil {
return fmt.Errorf("cannot connect to database: %v", err)
Expand Down Expand Up @@ -647,9 +647,9 @@ func (a *API) Serve(ctx context.Context) error {
return migrate.MigrateRunJobSignature(ctx, a.DBConnectionFactory.GetDBMap(gorpmapping.Mapper)())
}})

isFreshInstall, errF := version.IsFreshInstall(a.mustDB())
if errF != nil {
return sdk.WrapError(errF, "Unable to check if it's a fresh installation of CDS")
isFreshInstall, err := version.IsFreshInstall(a.mustDB())
if err != nil {
return sdk.WrapError(err, "Unable to check if it's a fresh installation of CDS")
}

if isFreshInstall {
Expand All @@ -658,9 +658,9 @@ func (a *API) Serve(ctx context.Context) error {
}
} else {
if sdk.VersionCurrent().Version != "" && !strings.HasPrefix(sdk.VersionCurrent().Version, "snapshot") {
major, minor, _, errV := version.MaxVersion(a.mustDB())
if errV != nil {
return sdk.WrapError(errV, "Cannot fetch max version of CDS already started")
major, minor, _, err := version.MaxVersion(a.mustDB())
if err != nil {
return sdk.WrapError(err, "Cannot fetch max version of CDS already started")
}
if major != 0 || minor != 0 {
minSemverCompatible, _ := semver.Parse(migrate.MinCompatibleRelease)
Expand Down Expand Up @@ -696,7 +696,7 @@ func (a *API) Serve(ctx context.Context) error {
log.Error(ctx, "unable to init api metrics: %v", err)
}

// Intialize notification package
// Initialize notification package
notification.Init(a.Config.URL.UI)

log.Info(ctx, "Initializing Authentication drivers...")
Expand Down
4 changes: 2 additions & 2 deletions engine/api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (api *API) disableWorkerHandler() service.Handler {
if err := DisableWorker(ctx, api.mustDB(), id, api.Config.Log.StepMaxSize); err != nil {
cause := sdk.Cause(err)
if cause == worker.ErrNoWorker || cause == sql.ErrNoRows {
return sdk.WrapError(sdk.ErrWrongRequest, "disableWorkerHandler> worker %s does not exists", id)
return sdk.WrapError(sdk.ErrWrongRequest, "disableWorkerHandler> worker %s does not exist", id)
}
return sdk.WrapError(err, "cannot update worker status")
}
Expand Down Expand Up @@ -290,7 +290,7 @@ func DisableWorker(ctx context.Context, db *gorp.DbMap, id string, maxLogSize in
if err := worker.SetStatus(ctx, tx, id, sdk.StatusDisabled); err != nil {
cause := sdk.Cause(err)
if cause == worker.ErrNoWorker || cause == sql.ErrNoRows {
return sdk.WrapError(sdk.ErrWrongRequest, "DisableWorker> worker %s does not exists", id)
return sdk.WrapError(sdk.ErrWrongRequest, "DisableWorker> worker %s does not exist", id)
}
return sdk.WrapError(err, "cannot update worker status")
}
Expand Down
2 changes: 1 addition & 1 deletion engine/cdn/cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (s *Service) Start(ctx context.Context) error {
}

log.Info(ctx, "Initializing database connection...")
// Intialize database
// Initialize database
s.DBConnectionFactory, err = database.Init(ctx, s.Cfg.Database)
if err != nil {
return sdk.WrapError(err, "cannot connect to database")
Expand Down
2 changes: 1 addition & 1 deletion engine/database/gorp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (g gorpLogger) Printf(format string, v ...interface{}) {
log.Debug(context.Background(), format, v...)
}

// DBMap returns a propor intialized gorp.DBMap pointer
// DBMap returns a proper Initialized gorp.DBMap pointer
func DBMap(m *gorpmapper.Mapper, db *sql.DB) *gorp.DbMap {
dbmap := &gorp.DbMap{Db: db, Dialect: gorp.PostgresDialect{}, TypeConverter: new(TypeConverter)}

Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ require (
github.com/urfave/cli v1.20.0
github.com/vmware/go-nfs-client v0.0.0-20190605212624-d43b92724c1b
github.com/vmware/govmomi v0.23.0
github.com/whilp/git-urls v1.0.0
github.com/xanzy/go-gitlab v0.15.0
github.com/xeipuuv/gojsonschema v1.2.0
github.com/yesnault/go-toml v0.0.0-20191205182532-f5ef6cee7945
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,6 @@ github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/X
github.com/vmware/govmomi v0.23.0 h1:DC97v1FdSr3cPfq3eBKD5C1O4JtYxo+NTcbGTKe2k48=
github.com/vmware/govmomi v0.23.0/go.mod h1:Y+Wq4lst78L85Ge/F8+ORXIWiKYqaro1vhAulACy9Lc=
github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk=
github.com/whilp/git-urls v1.0.0 h1:95f6UMWN5FKW71ECsXRUd3FVYiXdrE7aX4NZKcPmIjU=
github.com/whilp/git-urls v1.0.0/go.mod h1:J16SAmobsqc3Qcy98brfl5f5+e0clUvg1krgwk/qCfE=
github.com/xanzy/go-gitlab v0.15.0 h1:rWtwKTgEnXyNUGrOArN7yyc3THRkpYcKXIXia9abywQ=
github.com/xanzy/go-gitlab v0.15.0/go.mod h1:8zdQa/ri1dfn8eS3Ir1SyfvOKlw7WBJ8DVThkpGiXrs=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
Expand Down

0 comments on commit cc8d00b

Please sign in to comment.