jkawamoto/roadie

View on GitHub
cloud/azure/batch/models/job_preparation_task.go

Summary

Maintainability
A
2 hrs
Test Coverage
package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
    strfmt "github.com/go-openapi/strfmt"
    "github.com/go-openapi/swag"

    "github.com/go-openapi/errors"
    "github.com/go-openapi/validate"
)

// JobPreparationTask A Job Preparation task to run before any tasks of the job on any given compute node.
// swagger:model JobPreparationTask
type JobPreparationTask struct {

    // The command line of the Job Preparation task.
    //
    // The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux.
    // Required: true
    CommandLine *string `json:"commandLine"`

    // Constraints that apply to the Job Preparation task.
    Constraints *TaskConstraints `json:"constraints,omitempty"`

    // A list of environment variable settings for the Job Preparation task.
    EnvironmentSettings []*EnvironmentSetting `json:"environmentSettings"`

    // A string that uniquely identifies the job preparation task within the job.
    //
    // The ID can contain any combination of alphanumeric characters including hyphens and underscores and cannot contain more than 64 characters. If you do not specify this property, the Batch service assigns a default value of 'jobpreparation'. No other task in the job can have the same id as the Job Preparation task. If you try to submit a task with the same id, the Batch service rejects the request with error code TaskIdSameAsJobPreparationTask; if you are calling the REST API directly, the HTTP status code is 409 (Conflict).
    ID string `json:"id,omitempty"`

    // Whether the Batch service should rerun the Job Preparation task after a compute node reboots.
    //
    // The Job Preparation task is always rerun if a compute node is reimaged, or if the Job Preparation task did not complete (e.g. because the reboot occurred while the task was running). Therefore, you should always write a Job Preparation task to be idempotent and to behave correctly if run multiple times. The default value is true.
    RerunOnNodeRebootAfterSuccess bool `json:"rerunOnNodeRebootAfterSuccess,omitempty"`

    // A list of files that the Batch service will download to the compute node before running the command line.
    //
    // Files listed under this element are located in the task's working directory.
    ResourceFiles []*ResourceFile `json:"resourceFiles"`

    // Whether to run the Job Preparation task in elevated mode. The default value is false.
    RunElevated bool `json:"runElevated,omitempty"`

    // Whether the Batch service should wait for the Job Preparation task to complete successfully before scheduling any other tasks of the job on the compute node.
    //
    // If true and the Job Preparation task fails on a compute node, the Batch service retries the Job Preparation task up to its maximum retry count (as specified in the constraints element). If the task has still not completed successfully after all retries, then the Batch service will not schedule tasks of the job to the compute node. The compute node remains active and eligible to run tasks of other jobs. If false, the Batch service will not wait for the Job Preparation task to complete. In this case, other tasks of the job can start executing on the compute node while the Job Preparation task is still running; and even if the Job Preparation task fails, new tasks will continue to be scheduled on the node. The default value is true.
    WaitForSuccess bool `json:"waitForSuccess,omitempty"`
}

// Validate validates this job preparation task
func (m *JobPreparationTask) Validate(formats strfmt.Registry) error {
    var res []error

    if err := m.validateCommandLine(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateConstraints(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateEnvironmentSettings(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateResourceFiles(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if len(res) > 0 {
        return errors.CompositeValidationError(res...)
    }
    return nil
}

func (m *JobPreparationTask) validateCommandLine(formats strfmt.Registry) error {

    if err := validate.Required("commandLine", "body", m.CommandLine); err != nil {
        return err
    }

    return nil
}

func (m *JobPreparationTask) validateConstraints(formats strfmt.Registry) error {

    if swag.IsZero(m.Constraints) { // not required
        return nil
    }

    if m.Constraints != nil {

        if err := m.Constraints.Validate(formats); err != nil {
            return err
        }
    }

    return nil
}

func (m *JobPreparationTask) validateEnvironmentSettings(formats strfmt.Registry) error {

    if swag.IsZero(m.EnvironmentSettings) { // not required
        return nil
    }

    for i := 0; i < len(m.EnvironmentSettings); i++ {

        if swag.IsZero(m.EnvironmentSettings[i]) { // not required
            continue
        }

        if m.EnvironmentSettings[i] != nil {

            if err := m.EnvironmentSettings[i].Validate(formats); err != nil {
                return err
            }
        }

    }

    return nil
}

func (m *JobPreparationTask) validateResourceFiles(formats strfmt.Registry) error {

    if swag.IsZero(m.ResourceFiles) { // not required
        return nil
    }

    for i := 0; i < len(m.ResourceFiles); i++ {

        if swag.IsZero(m.ResourceFiles[i]) { // not required
            continue
        }

        if m.ResourceFiles[i] != nil {

            if err := m.ResourceFiles[i].Validate(formats); err != nil {
                return err
            }
        }

    }

    return nil
}