mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
* [VAULT-39158] actions(build-hcp-image): various small fixes Various small fixes to correctly trigger custom image builds and wait for them to be available. Signed-off-by: Ryan Cragun <me@ryan.ec> Co-authored-by: Ryan Cragun <me@ryan.ec>
This commit is contained in:
parent
fd52499843
commit
f2872f0cc7
5 changed files with 33 additions and 21 deletions
|
|
@ -37,7 +37,7 @@ func runFindGithubWorkflowArtifactCmd(cmd *cobra.Command, args []string) error {
|
|||
|
||||
res, err := findWorkflowArtifact.Run(context.TODO(), githubCmdState.Github)
|
||||
if err != nil {
|
||||
return fmt.Errorf("listing github workflow failures: %w", err)
|
||||
return fmt.Errorf("finding workflow artifact: %w", err)
|
||||
}
|
||||
|
||||
switch rootCfg.format {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func runListGithubChangedFilesCmd(cmd *cobra.Command, args []string) error {
|
|||
|
||||
res, err := listGithubChangedFiles.Run(context.TODO(), githubCmdState.Github)
|
||||
if err != nil {
|
||||
return fmt.Errorf("listing github workflow failures: %w", err)
|
||||
return fmt.Errorf("listing changed files: %w", err)
|
||||
}
|
||||
|
||||
switch rootCfg.format {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ func runListGithubWorkflowsCmd(cmd *cobra.Command, args []string) error {
|
|||
|
||||
res, err := listGithubWorkflowRuns.Run(context.TODO(), githubCmdState.Github)
|
||||
if err != nil {
|
||||
return fmt.Errorf("listing github workflow failures: %w", err)
|
||||
return fmt.Errorf("listing github workflow runs: %w", err)
|
||||
}
|
||||
|
||||
switch rootCfg.format {
|
||||
|
|
|
|||
|
|
@ -56,31 +56,40 @@ func getWorkflowRuns(
|
|||
id int64,
|
||||
opts *gh.ListWorkflowRunsOptions,
|
||||
) ([]*WorkflowRun, error) {
|
||||
slog.Default().DebugContext(slogctx.Append(ctx,
|
||||
slog.String("owner", owner),
|
||||
slog.String("repo", repo),
|
||||
slog.Int64("id", id),
|
||||
), "getting github actions workflow runs")
|
||||
|
||||
var runs []*WorkflowRun
|
||||
opts.ListOptions = gh.ListOptions{PerPage: PerPageMax}
|
||||
|
||||
for {
|
||||
wfrs, res, err := client.Actions.ListWorkflowRunsByID(ctx, owner, repo, id, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// By default our status will be "success" which elimates in_progress runs.
|
||||
// Instead, we'll try both so that we're sure to include what's actually
|
||||
// running along with historical runs.
|
||||
for _, status := range []string{"success", "in_progress"} {
|
||||
for {
|
||||
opts.Status = status
|
||||
slog.Default().DebugContext(slogctx.Append(ctx,
|
||||
slog.String("owner", owner),
|
||||
slog.String("repo", repo),
|
||||
slog.Int64("id", id),
|
||||
slog.String("query-status", opts.Status),
|
||||
), "getting github actions workflow runs")
|
||||
|
||||
for _, r := range wfrs.WorkflowRuns {
|
||||
runs = append(runs, &WorkflowRun{Run: r})
|
||||
}
|
||||
wfrs, res, err := client.Actions.ListWorkflowRunsByID(ctx, owner, repo, id, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if res.NextPage == 0 {
|
||||
return runs, nil
|
||||
}
|
||||
for _, r := range wfrs.WorkflowRuns {
|
||||
runs = append(runs, &WorkflowRun{Run: r})
|
||||
}
|
||||
|
||||
opts.ListOptions.Page = res.NextPage
|
||||
if res.NextPage == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
opts.ListOptions.Page = res.NextPage
|
||||
}
|
||||
}
|
||||
|
||||
return runs, nil
|
||||
}
|
||||
|
||||
// getWorkflowRunArtifacts gets the artifacts associated with a workflow run
|
||||
|
|
|
|||
|
|
@ -65,8 +65,11 @@ func (r *WaitForImageReq) Run(ctx context.Context, client *Client) (*WaitForImag
|
|||
|
||||
return err
|
||||
},
|
||||
retry.UntilSucceeded(),
|
||||
retry.Context(ctx),
|
||||
retry.WrapContextErrorWithLastError(true),
|
||||
retry.Delay(r.Delay),
|
||||
retry.DelayType(retry.FixedDelay),
|
||||
)
|
||||
|
||||
return res, err
|
||||
|
|
|
|||
Loading…
Reference in a new issue