Skip to content

Commit

Permalink
Merge pull request #2244 from keboola/petr-hosek-PSGO-1007
Browse files Browse the repository at this point in the history
Replace deprecated functions and remove unused variables
  • Loading branch information
hosekpeter authored Feb 12, 2025
2 parents 3931707 + 9f7b20b commit a0a1c68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 46 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ require (
github.com/jonboulle/clockwork v0.5.0
github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629
github.com/json-iterator/go v1.1.12
github.com/keboola/go-client v1.28.1
github.com/keboola/go-client v1.28.2
github.com/keboola/go-cloud-encrypt v0.0.0-20250116143358-1ca36e2474e2
github.com/keboola/go-utils v1.2.0
github.com/keboola/go-utils v1.3.0
github.com/klauspost/compress v1.17.11
github.com/klauspost/pgzip v1.2.6
github.com/kylelemons/godebug v1.1.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ github.com/justinas/alice v1.2.0 h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo=
github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/keboola/go-client v1.28.1 h1:NHE8URVrw+4Q26a0fSd36BDOVA/bHqGsXQdedjfjR7Q=
github.com/keboola/go-client v1.28.1/go.mod h1:UKsl17jZA1xSa0jQrxw1MAo7GNj+OA5Y/MXjOp/6FkM=
github.com/keboola/go-client v1.28.2 h1:gHJDbrondF9pkXBEzv8S/GQlcBuE1JACeAowL68OgNY=
github.com/keboola/go-client v1.28.2/go.mod h1:RHWix5ZfhJMkXoletJUEsnbVISg3qxpzXP6rN5l/yHY=
github.com/keboola/go-cloud-encrypt v0.0.0-20250116143358-1ca36e2474e2 h1:TIrN79PUr/vIoTvxcJgBGcp/lHHl44oy3noLD9fr4OU=
github.com/keboola/go-cloud-encrypt v0.0.0-20250116143358-1ca36e2474e2/go.mod h1:/xymMid3vszQE78wl4rrqeB5BYCazQ1MwGtsEohwn0A=
github.com/keboola/go-jsonnet v0.20.1-0.20240430105602-71646d8d4fa9 h1:BY9wMWSN1SEIjhBJSrFWpLLS3DiAR+GNANOSTNtfzGA=
Expand All @@ -494,8 +494,8 @@ github.com/keboola/go-mockoidc v0.0.0-20240405064136-5229d2b53db6 h1:HcvX1VQkiav
github.com/keboola/go-mockoidc v0.0.0-20240405064136-5229d2b53db6/go.mod h1:eDjgYHYDJbPLBLsyZ6qRaugP0mX8vePOhZ5id1fdzJw=
github.com/keboola/go-oauth2-proxy/v7 v7.6.1-0.20240418143152-9d00aaa29562 h1:EiwSnkbGt2i6XxvjDMrWx6/bGlQjVs+yq1mDJ5b3U1U=
github.com/keboola/go-oauth2-proxy/v7 v7.6.1-0.20240418143152-9d00aaa29562/go.mod h1:uPrZkzwsuFyIPP04hIt6TG2KvWujglvkOnUUnQJyIdw=
github.com/keboola/go-utils v1.2.0 h1:mz12Eo+/XW+V0qcEGN4mkXQjrFOdxy+muWe0hLj2n/c=
github.com/keboola/go-utils v1.2.0/go.mod h1:4YVC2/V0QwgHqxtch8JAVDNVI1aINF2arJ7sh6TO1GY=
github.com/keboola/go-utils v1.3.0 h1:oiNRfUlLFTWjATty4oQlCBWmiMZN80QCCnRHP61Md5Q=
github.com/keboola/go-utils v1.3.0/go.mod h1:4YVC2/V0QwgHqxtch8JAVDNVI1aINF2arJ7sh6TO1GY=
github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs=
github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down
56 changes: 16 additions & 40 deletions pkg/lib/operation/project/remote/job/run/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func Run(ctx context.Context, o RunOptions, d dependencies) (err error) {

queue := &JobQueue{
async: o.Async,
hasQueueV2: d.ProjectFeatures().Has("queuev2"),
ctx: timeoutCtx,
api: d.KeboolaProjectAPI(),
logger: d.Logger(),
Expand Down Expand Up @@ -76,8 +75,7 @@ func Run(ctx context.Context, o RunOptions, d dependencies) (err error) {
}

type JobQueue struct {
async bool
hasQueueV2 bool
async bool

ctx context.Context
api *keboola.AuthorizedAPI
Expand Down Expand Up @@ -145,7 +143,7 @@ func (q *JobQueue) dispatch(job *Job) {
go func() {
defer q.wg.Done()

if err := job.Start(q.ctx, q.api, q.async, q.hasQueueV2); err != nil {
if err := job.Start(q.ctx, q.api); err != nil {
q.err.Append(errors.Errorf("job \"%s\" failed to start: %s", job.Key(), err))
return
}
Expand Down Expand Up @@ -196,47 +194,25 @@ func (o *Job) Key() string {
return out
}

func (o *Job) Start(ctx context.Context, api *keboola.AuthorizedAPI, async bool, hasQueueV2 bool) error {
if hasQueueV2 {
job, err := api.NewCreateJobRequest(o.ComponentID).
WithConfig(o.ConfigID).
WithBranch(o.BranchID).
WithTag(o.Tag).
Send(ctx)
if err != nil {
return err
}
func (o *Job) Start(ctx context.Context, api *keboola.AuthorizedAPI) error {
job, err := api.NewCreateJobRequest(o.ComponentID).
WithConfig(o.ConfigID).
WithBranch(o.BranchID).
WithTag(o.Tag).
Send(ctx)
if err != nil {
return err
}

o.id = job.ID
o.wait = func() error {
err := api.WaitForQueueJob(ctx, job.ID)
if err != nil {
return err
}
return nil
}
} else {
// nolint: staticcheck
job, err := api.CreateOldQueueJobRequest(
o.ComponentID,
o.ConfigID,
keboola.WithBranchID(o.BranchID),
keboola.WithImageTag(o.Tag),
).Send(ctx)
o.id = job.ID
o.wait = func() error {
err := api.WaitForQueueJob(ctx, job.ID)
if err != nil {
return err
}

o.id = job.ID
o.wait = func() error {
// nolint: staticcheck
err := api.WaitForOldQueueJob(ctx, job.ID)
if err != nil {
return err
}
return nil
}
return nil
}

return nil
}

Expand Down

0 comments on commit a0a1c68

Please sign in to comment.