Skip to content

Commit

Permalink
Merge pull request #465 from ZackJagger/fix/wait-for-get-current-url
Browse files Browse the repository at this point in the history
fix: wait for preview url to be populated
  • Loading branch information
jenkins-x-bot committed Oct 26, 2023
2 parents b2cd697 + 54e8b80 commit b226f31
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/jenkins-x/jx-helpers/v3/pkg/cobras/templates"
"github.com/jenkins-x/jx-helpers/v3/pkg/scmhelpers"
"github.com/jenkins-x/jx-helpers/v3/pkg/table"
"github.com/jenkins-x/jx-logging/v3/pkg/log"
"github.com/pkg/errors"
"github.com/spf13/cobra"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -140,6 +141,11 @@ func (o *Options) CurrentPreviewURL() error {
}
}

if currentPreview == nil {
log.Logger().Infof("No preview found for PR %v", o.Number)
return nil
}

t := table.CreateTable(os.Stdout)
t.AddRow("PULL REQUEST", "NAMESPACE", "APPLICATION")
t.AddRow(currentPreview.Spec.PullRequest.URL,
Expand Down Expand Up @@ -188,7 +194,7 @@ func (o *Options) listPreviews() (*v1alpha1.PreviewList, error) {
}

func (o *Options) waitForCommit() (*v1alpha1.Preview, error) {
fmt.Printf("Waiting for preview with commit: %s\n", o.LatestCommit)
log.Logger().Infof("Waiting for preview with commit: %s\n", o.LatestCommit)

for {
previewList, err := o.listPreviews()
Expand All @@ -200,7 +206,8 @@ func (o *Options) waitForCommit() (*v1alpha1.Preview, error) {
if err != nil {
return nil, err
}
if preview != nil && preview.Spec.PullRequest.LatestCommit == o.LatestCommit {
if preview != nil && preview.Spec.PullRequest.LatestCommit == o.LatestCommit &&
preview.Spec.Resources.URL != "" {
return preview, nil
}

Expand Down

0 comments on commit b226f31

Please sign in to comment.