feat(delivery): switch AWX delivery to callbacks
This commit is contained in:
@@ -32,16 +32,19 @@ type AWXLaunchRequest struct {
|
||||
}
|
||||
|
||||
type AWXJob struct {
|
||||
ID uint64 `json:"id"`
|
||||
Status string `json:"status"`
|
||||
Failed bool `json:"failed"`
|
||||
ID uint64 `json:"id"`
|
||||
Status string `json:"status"`
|
||||
Failed bool `json:"failed"`
|
||||
IgnoredFields map[string]any `json:"ignored_fields"`
|
||||
}
|
||||
|
||||
type AWXJobTemplate struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Inventory uint64 `json:"inventory"`
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Inventory uint64 `json:"inventory"`
|
||||
AskVariablesOnLaunch bool `json:"ask_variables_on_launch"`
|
||||
AskLimitOnLaunch bool `json:"ask_limit_on_launch"`
|
||||
}
|
||||
|
||||
type AWXInventoryHost struct {
|
||||
@@ -92,12 +95,23 @@ func (c *AWXClient) Launch(ctx context.Context, templateID uint64, input AWXLaun
|
||||
if err := c.request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/job_templates/%d/launch/", templateID), body, &job); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(job.IgnoredFields) > 0 {
|
||||
return nil, fmt.Errorf("AWX ignored launch fields %v; enable Prompt on launch for Variables and Limit on the job template", ignoredFieldNames(job.IgnoredFields))
|
||||
}
|
||||
if job.ID == 0 {
|
||||
return nil, fmt.Errorf("AWX launch response did not include a job id")
|
||||
}
|
||||
return &job, nil
|
||||
}
|
||||
|
||||
func ignoredFieldNames(fields map[string]any) []string {
|
||||
names := make([]string, 0, len(fields))
|
||||
for name := range fields {
|
||||
names = append(names, name)
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
func (c *AWXClient) GetJob(ctx context.Context, jobID string) (*AWXJob, error) {
|
||||
if _, err := strconv.ParseUint(jobID, 10, 64); err != nil {
|
||||
return nil, fmt.Errorf("invalid AWX job id %q", jobID)
|
||||
|
||||
Reference in New Issue
Block a user