Skip to content

Commit

Permalink
fix: NPE qovery client
Browse files Browse the repository at this point in the history
Ticket: ENG-1619
  • Loading branch information
benjaminch committed Oct 26, 2023
1 parent 60c0057 commit ff88f6d
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 390 deletions.
11 changes: 9 additions & 2 deletions cmd/cronjob_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,15 @@ var cronjobDeployCmd = &cobra.Command{
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011
}

docker := cronjob.Source.JobResponseAllOfSourceOneOf1.Docker
image := cronjob.Source.JobResponseAllOfSourceOneOf.Image
var docker *qovery.JobResponseAllOfSourceOneOf1Docker = nil
if cronjob.Source.JobResponseAllOfSourceOneOf1 != nil {
docker = cronjob.Source.JobResponseAllOfSourceOneOf1.Docker
}

var image *qovery.ContainerSource = nil
if cronjob.Source.JobResponseAllOfSourceOneOf != nil {
image = cronjob.Source.JobResponseAllOfSourceOneOf.Image
}

var req qovery.JobDeployRequest

Expand Down
12 changes: 10 additions & 2 deletions cmd/cronjob_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"github.com/qovery/qovery-client-go"
"io"
"os"

Expand Down Expand Up @@ -64,8 +65,15 @@ var cronjobUpdateCmd = &cobra.Command{
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011
}

docker := cronjob.Source.JobResponseAllOfSourceOneOf1.Docker
image := cronjob.Source.JobResponseAllOfSourceOneOf.Image
var docker *qovery.JobResponseAllOfSourceOneOf1Docker = nil
if cronjob.Source.JobResponseAllOfSourceOneOf1 != nil {
docker = cronjob.Source.JobResponseAllOfSourceOneOf1.Docker
}

var image *qovery.ContainerSource = nil
if cronjob.Source.JobResponseAllOfSourceOneOf != nil {
image = cronjob.Source.JobResponseAllOfSourceOneOf.Image
}

if docker != nil && (cronjobTag != "" || cronjobImageName != "") {
utils.PrintlnError(fmt.Errorf("you can't use --tag or --image-name with a cronjob targetting a Dockerfile. Use --branch instead"))
Expand Down
1 change: 1 addition & 0 deletions cmd/database_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"time"

Check failure on line 7 in cmd/database_deploy.go

View workflow job for this annotation

GitHub Actions / build

imported and not used: "time"

"github.com/pterm/pterm"
"github.com/qovery/qovery-cli/utils"
Expand Down
11 changes: 9 additions & 2 deletions cmd/lifecycle_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,15 @@ var lifecycleDeployCmd = &cobra.Command{
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011
}

docker := lifecycle.Source.JobResponseAllOfSourceOneOf1.Docker
image := lifecycle.Source.JobResponseAllOfSourceOneOf.Image
var docker *qovery.JobResponseAllOfSourceOneOf1Docker = nil
if lifecycle.Source.JobResponseAllOfSourceOneOf1 != nil {
docker = lifecycle.Source.JobResponseAllOfSourceOneOf1.Docker
}

var image *qovery.ContainerSource = nil
if lifecycle.Source.JobResponseAllOfSourceOneOf != nil {
image = lifecycle.Source.JobResponseAllOfSourceOneOf.Image
}

var req qovery.JobDeployRequest

Expand Down
12 changes: 10 additions & 2 deletions cmd/lifecycle_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"github.com/qovery/qovery-client-go"
"io"
"os"

Expand Down Expand Up @@ -64,8 +65,15 @@ var lifecycleUpdateCmd = &cobra.Command{
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011
}

docker := lifecycle.Source.JobResponseAllOfSourceOneOf1.Docker
image := lifecycle.Source.JobResponseAllOfSourceOneOf.Image
var docker *qovery.JobResponseAllOfSourceOneOf1Docker = nil
if lifecycle.Source.JobResponseAllOfSourceOneOf1 != nil {
docker = lifecycle.Source.JobResponseAllOfSourceOneOf1.Docker
}

var image *qovery.ContainerSource = nil
if lifecycle.Source.JobResponseAllOfSourceOneOf != nil {
image = lifecycle.Source.JobResponseAllOfSourceOneOf.Image
}

if docker != nil && (lifecycleTag != "" || lifecycleImageName != "") {
utils.PrintlnError(fmt.Errorf("you can't use --tag or --image-name with a lifecycle targetting a Dockerfile. Use --branch instead"))
Expand Down
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ require (
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gookit/color v1.5.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand Down Expand Up @@ -68,11 +67,8 @@ require (
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/oauth2 v0.9.0 // indirect
golang.org/x/term v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
)
375 changes: 1 addition & 374 deletions go.sum

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions utils/qovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -1358,8 +1358,15 @@ func DeployJobs(client *qovery.APIClient, envId string, jobNames string, commitI
return fmt.Errorf("job %s not found", trimmedJobName)
}

docker := job.Source.JobResponseAllOfSourceOneOf1.Docker
image := job.Source.JobResponseAllOfSourceOneOf.Image
var docker *qovery.JobResponseAllOfSourceOneOf1Docker = nil
if job.Source.JobResponseAllOfSourceOneOf1 != nil {
docker = job.Source.JobResponseAllOfSourceOneOf1.Docker
}

var image *qovery.ContainerSource = nil
if job.Source.JobResponseAllOfSourceOneOf != nil {
image = job.Source.JobResponseAllOfSourceOneOf.Image
}

var mCommitId *string
var mTag *string
Expand Down Expand Up @@ -2032,8 +2039,15 @@ func StopServices(client *qovery.APIClient, envId string, serviceIds []string, s
}

func ToJobRequest(job qovery.JobResponse) qovery.JobRequest {
docker := job.Source.JobResponseAllOfSourceOneOf1.Docker
image := job.Source.JobResponseAllOfSourceOneOf.Image
var docker *qovery.JobResponseAllOfSourceOneOf1Docker = nil
if job.Source.JobResponseAllOfSourceOneOf1 != nil {
docker = job.Source.JobResponseAllOfSourceOneOf1.Docker
}

var image *qovery.ContainerSource = nil
if job.Source.JobResponseAllOfSourceOneOf != nil {
image = job.Source.JobResponseAllOfSourceOneOf.Image
}

var sourceImage qovery.JobRequestAllOfSourceImage

Expand Down

0 comments on commit ff88f6d

Please sign in to comment.