task

package
v0.2.54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: MIT Imports: 22 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// DefaultResponseResultField is the default output property result field
	DefaultResponseResultField = "commandResponse"

	// SecureResponseResultField is the output property result field that is not shown in the UI
	SecureResponseResultField = "secureResponse"
)
View Source
const CallbackURL = "CALLBACK_URL"

CallbackURL represents the environment variable for the callback URL.

View Source
const InputCategory = "input"

InputCategory represents the category of input properties.

View Source
const InputContextSecret = "INPUT_CONTEXT_SECRET"

InputContextSecret represents the environment variable for the input context secret.

View Source
const InputContextSecretDataFetchUrlKey = "fetchUrl"

InputContextSecretDataFetchUrlKey represents the key for Fetching task content URL in the input context secret. This

View Source
const InputContextSecretDataInput = "input"

InputContextSecretDataInput represents the key for input data in the input context secret.

View Source
const InputContextSecretDataSessionKey = "session-key"

InputContextSecretDataSessionKey represents the key for session key in the input context secret.

View Source
const InputContextSecretDataUrlKey = "url"

InputContextSecretDataUrlKey represents the key for URL in the input context secret.

View Source
const InputContextSecretExecutionIdKey = "execution-id"

InputContextSecretExecutionIdKey represents the key for execution ID in the input context secret.

View Source
const InputLocation = "INPUT_LOCATION"

InputLocation represents the environment variable for input location.

View Source
const OutputCategory = "output"

OutputCategory represents the category of output properties.

View Source
const OutputLocation = "OUTPUT_LOCATION"

OutputLocation represents the environment variable for output location.

View Source
const ReleaseURL = "RELEASE_URL"

ReleaseURL represents the environment variable for the release URL.

View Source
const ResultSecretName = "RESULT_SECRET_NAME"

ResultSecretName represents the name of the result secret.

View Source
const RunnerNamespace = "RUNNER_NAMESPACE"

RunnerNamespace represents the environment variable for the runner namespace.

View Source
const SessionKey = "SESSION_KEY"

SessionKey represents the environment variable for the session key.

View Source
const SizeOf1Mb = 1024 * 1024

Variables

This section is empty.

Functions

func Comment

func Comment(comment string)

Comment logs a comment message.

func Decrypt

func Decrypt(content []byte) ([]byte, error)

Decrypt decrypts the content using the session key.

func Deserialize

func Deserialize(context *InputContext) error

Deserialize deserializes the input context from the specified source into the provided InputContext object.

func DeserializeTask

func DeserializeTask(properties []PropertyDefinition, taskInstance any) error

DeserializeTask deserializes the input properties into the provided task instance.

func Encrypt

func Encrypt(content []byte) ([]byte, error)

Encrypt encrypts the content using the session key.

func HandleAbort added in v0.2.37

func HandleAbort(result map[string]interface{})

func HandleError

func HandleError(err error, result map[string]interface{}, records []interface{})

HandleError handles task execution error by processing the result, error message and reporting records.

func HandleSuccess

func HandleSuccess(result map[string]interface{}, records interface{})

HandleSuccess handles successful task execution by processing the result and reporting records.

func Serialize

func Serialize(result map[string]interface{})

Serialize serializes the provided result into the output properties.

func SerializeError

func SerializeError(err error, result map[string]interface{})

SerializeError serializes the provided error and result into the output properties.

func Status

func Status(status string)

Status logs a status message.

func UnmarshalProperties

func UnmarshalProperties(properties []PropertyDefinition, prototype interface{}) error

UnmarshalProperties unmarshalls the input properties into the provided prototype object.

Types

type AbortError added in v0.2.37

type AbortError struct{}

func (*AbortError) Error added in v0.2.37

func (e *AbortError) Error() string

type AbortGenerator added in v0.2.37

type AbortGenerator struct {
	// contains filtered or unexported fields
}

The AbortGenerator - used to represent aborted execution result

func (AbortGenerator) FieldName added in v0.2.37

func (gen AbortGenerator) FieldName() string

func (AbortGenerator) GenerateValue added in v0.2.37

func (gen AbortGenerator) GenerateValue() (interface{}, error)

type AutomatedTaskAsUserContext

type AutomatedTaskAsUserContext struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

AutomatedTaskAsUserContext represents the context of an automated task as a user with credentials.

type BoolGenerator

type BoolGenerator struct {
	// contains filtered or unexported fields
}

BoolGenerator represents a simple boolean value with a custom field name.

func (BoolGenerator) FieldName

func (gen BoolGenerator) FieldName() string

FieldName returns the custom field name for the boolean value.

func (BoolGenerator) GenerateValue

func (gen BoolGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the boolean value.

type BuildRecord added in v0.2.36

type BuildRecord struct {
	ReportingRecord
	Project   string    `json:"project,omitempty"`
	Build     string    `json:"build,omitempty"`
	Outcome   string    `json:"outcome,omitempty"`
	StartDate time.Time `json:"startDate,omitempty"`
	EndDate   time.Time `json:"endDate,omitempty"`
	Duration  string    `json:"duration,omitempty"`
	BuildUrl  string    `json:"build_url,omitempty"`
}

BuildRecord represents the record for build.

type CodeComplianceRecord added in v0.2.36

type CodeComplianceRecord struct {
	ReportingRecord
	Project        string    `json:"project,omitempty"`
	ProjectUrl     string    `json:"project_url,omitempty"`
	AnalysisDate   time.Time `json:"analysisDate,omitempty"`
	Outcome        string    `json:"outcome,omitempty"`
	ComplianceData string    `json:"complianceData,omitempty"`
}

CodeComplianceRecord represents the record for code compliance.

type ComposedProperty

type ComposedProperty TaskContext

ComposedProperty represents a composed property of a task.

type DateGenerator

type DateGenerator struct {
	// contains filtered or unexported fields
}

DateGenerator represents a simple date and time value with a custom field name.

func (DateGenerator) FieldName

func (gen DateGenerator) FieldName() string

FieldName returns the custom field name for the date and time value.

func (DateGenerator) GenerateValue

func (gen DateGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the date and time value.

type DeploymentRecord added in v0.2.36

type DeploymentRecord struct {
	ReportingRecord
	DeploymentTask    string           `json:"deploymentTask,omitempty"`
	DeploymentTaskUrl string           `json:"deploymentTask_url,omitempty"`
	ApplicationName   string           `json:"applicationName,omitempty"`
	Version           string           `json:"version,omitempty"`
	EnvironmentName   string           `json:"environmentName,omitempty"`
	Status            DeploymentStatus `json:"status,omitempty"`
}

DeploymentRecord represents the record for deployment.

func CreateDeploymentRecord added in v0.2.36

func CreateDeploymentRecord(client *http.HttpClient, taskInfo *DeploymentRecordTaskInfo, status DeploymentStatus) *DeploymentRecord

CreateDeploymentRecord creates a new reporting record for deployment.

type DeploymentRecordTaskInfo added in v0.2.36

type DeploymentRecordTaskInfo struct {
	TaskId                string
	DeploymentPackage     string
	DeploymentEnvironment string
	DeploymentVersion     string
	DeploymentApplication string
	DeployedApplication   string
	Username              string
	ReleaseTaskId         string
}

DeploymentRecordTaskInfo represents properties of deployment needed for audit record.

type DeploymentStatus added in v0.2.36

type DeploymentStatus string

DeploymentStatus represents the status of the deployment.

const (
	Planned    DeploymentStatus = "planned"
	InProgress DeploymentStatus = "in_progress"
	Completed  DeploymentStatus = "completed"
	Skipped    DeploymentStatus = "skipped"
	Failed     DeploymentStatus = "failed"
	Aborted    DeploymentStatus = "aborted"
)

type ErrorGenerator

type ErrorGenerator struct {
	// contains filtered or unexported fields
}

ErrorGenerator represents an error in the standardized response.

func (ErrorGenerator) FieldName

func (gen ErrorGenerator) FieldName() string

FieldName returns the field name for the error.

func (ErrorGenerator) GenerateValue

func (gen ErrorGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the error value.

type Generator

type Generator interface {
	GenerateValue() (interface{}, error)
	FieldName() string
}

Generator is an interface for result value generators.

type InputContext

type InputContext struct {
	Release ReleaseContext `json:"release"`
	Task    TaskContext    `json:"task"`
}

InputContext represents the input context of a task.

type IntGenerator

type IntGenerator struct {
	// contains filtered or unexported fields
}

IntGenerator represents a simple integer value with a custom field name.

func (IntGenerator) FieldName

func (gen IntGenerator) FieldName() string

FieldName returns the custom field name for the integer value.

func (IntGenerator) GenerateValue

func (gen IntGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the integer value.

type ItsmReportingRecord added in v0.2.36

type ItsmReportingRecord struct {
	ReportingRecord
	Record    string `json:"record,omitempty"`
	RecordUrl string `json:"record_url,omitempty"`
	Title     string `json:"title,omitempty"`
	Status    string `json:"status,omitempty"`
	Priority  string `json:"priority,omitempty"`
	CreatedBy string `json:"createdBy,omitempty"`
}

ItsmReportingRecord represents the record for ITSM.

type JsonGenerator

type JsonGenerator struct {
	// contains filtered or unexported fields
}

JsonGenerator represents a JSON value with a custom field name.

func (JsonGenerator) FieldName

func (gen JsonGenerator) FieldName() string

FieldName returns the custom field name for the JSON value.

func (JsonGenerator) GenerateValue

func (gen JsonGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the JSON value.

type JsonRawGenerator

type JsonRawGenerator struct {
	// contains filtered or unexported fields
}

JsonRawGenerator represents a raw JSON value with a custom field name.

func (JsonRawGenerator) FieldName

func (gen JsonRawGenerator) FieldName() string

FieldName returns the custom field name for the raw JSON value.

func (JsonRawGenerator) GenerateValue

func (gen JsonRawGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the raw JSON value.

type JsonValueBoolGenerator

type JsonValueBoolGenerator struct {
	JsonValueGenerator
}

JsonValueBoolGenerator represents a boolean result on a JSON path given over a JQ command.

func (JsonValueBoolGenerator) GenerateValue

func (gen JsonValueBoolGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the boolean value.

type JsonValueDateGenerator

type JsonValueDateGenerator struct {
	JsonValueGenerator
	// contains filtered or unexported fields
}

JsonValueDateGenerator represents a date result on a JSON path given over a JQ command.

func (JsonValueDateGenerator) GenerateValue

func (gen JsonValueDateGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the date value.

type JsonValueGenerator

type JsonValueGenerator struct {
	// contains filtered or unexported fields
}

JsonValueGenerator is the base struct for all JSON value generators.

func (JsonValueGenerator) FieldName

func (gen JsonValueGenerator) FieldName() string

FieldName returns the field name for the JSON value generator.

type JsonValueNodeGenerator

type JsonValueNodeGenerator struct {
	JsonValueGenerator
}

JsonValueNodeGenerator represents a JSON result on a JSON path given over a JQ command.

func (JsonValueNodeGenerator) GenerateValue

func (gen JsonValueNodeGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the JSON value.

type JsonValueStringGenerator

type JsonValueStringGenerator struct {
	JsonValueGenerator
}

JsonValueStringGenerator represents a string result on a JSON path given over a JQ command.

func (JsonValueStringGenerator) GenerateValue

func (gen JsonValueStringGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the string value.

type LookupResultElement

type LookupResultElement struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

LookupResultElement represents an element of a lookup result.

type LookupResultElementsGenerator

type LookupResultElementsGenerator struct {
	// contains filtered or unexported fields
}

LookupResultElementsGenerator represents lookup result elements with a custom field name.

func (LookupResultElementsGenerator) FieldName

func (gen LookupResultElementsGenerator) FieldName() string

FieldName returns the custom field name for the lookup result elements value.

func (LookupResultElementsGenerator) GenerateValue

func (gen LookupResultElementsGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the lookup result elements value.

type PlanRecord added in v0.2.36

type PlanRecord struct {
	ReportingRecord
	Ticket      string    `json:"ticket,omitempty"`
	TicketUrl   string    `json:"ticket_url,omitempty"`
	Title       string    `json:"title,omitempty"`
	TicketType  string    `json:"ticketType,omitempty"`
	Status      string    `json:"status,omitempty"`
	UpdatedDate time.Time `json:"updatedDate,omitempty"`
	UpdatedBy   string    `json:"updatedBy,omitempty"`
}

PlanRecord represents the record for plan.

type PropertyDefinition

type PropertyDefinition struct {
	Name       string          `json:"name"`
	Value      json.RawMessage `json:"value"`
	Kind       string          `json:"kind"`
	Category   string          `json:"category"`
	IsPassword bool            `json:"password"`
}

PropertyDefinition represents the definition of a task property.

type ReleaseContext

type ReleaseContext struct {
	Id                  string                     `json:"id"`
	AutomatedTaskAsUser AutomatedTaskAsUserContext `json:"automatedTaskAsUser"`
	Url                 string                     `json:"url"`
}

ReleaseContext represents the context of a release.

type ReportingRecord added in v0.2.36

type ReportingRecord struct {
	Id                 string    `json:"id"`
	Type               string    `json:"type"`
	TargetId           string    `json:"targetId,omitempty"`
	ServerUrl          string    `json:"serverUrl,omitempty"`
	ServerUser         string    `json:"serverUser,omitempty"`
	CreationDate       time.Time `json:"creationDate,omitempty"`
	RetryAttemptNumber int32     `json:"retryAttemptNumber,omitempty"`
	CreatedViaApi      bool      `json:"createdViaApi,omitempty"`
}

ReportingRecord represents the record produced by task.

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result represents the result of a task execution.

func NewResult

func NewResult() *Result

NewResult creates a new Result instance.

func (*Result) Aborted added in v0.2.37

func (r *Result) Aborted(result *Result) *Result

func (*Result) Bool

func (r *Result) Bool(resultField string, result bool) *Result

Bool adds a boolean value with a custom field name to the result.

func (*Result) CustomValue

func (r *Result) CustomValue(generator Generator) *Result

CustomValue provides a custom implementation of the Generator interface, adding a custom parsed or generated value to the result.

func (*Result) Date

func (r *Result) Date(resultField string, dateTime time.Time) *Result

Date adds a date and time value with a custom field name to the result.

func (*Result) DateString

func (r *Result) DateString(resultField string, sampleFormat string, dateTime string) *Result

DateString adds a date and time value with a custom format and field name to the result.

func (*Result) Error

func (r *Result) Error(err error) *Result

Error adds an error to the result.

func (*Result) Get

func (r *Result) Get() (map[string]interface{}, error)

Get returns map with all values that were added to result

func (*Result) GetRecords added in v0.2.36

func (r *Result) GetRecords() []interface{}

GetRecords returns list of all reporting records

func (*Result) Int

func (r *Result) Int(resultField string, result int) *Result

Int adds an integer value with a custom field name to the result.

func (*Result) Json

func (r *Result) Json(resultField string, jsonPayload json.RawMessage) *Result

Json adds a JSON value with a custom field name to the result.

func (*Result) JsonBool

func (r *Result) JsonBool(resultField string, jqOp string, jsonPayload json.RawMessage) *Result

JsonBool adds a boolean result on a JSON path given over a JQ command to the result.

func (*Result) JsonDate

func (r *Result) JsonDate(resultField string, jqOp string, sampleFormat string, jsonPayload json.RawMessage) *Result

JsonDate adds a date result on a JSON path given over a JQ command to the result.

func (*Result) JsonNode

func (r *Result) JsonNode(resultField string, jqOp string, jsonPayload json.RawMessage) *Result

JsonNode adds a JSON result on a JSON path given over a JQ command to the result.

func (*Result) JsonRaw

func (r *Result) JsonRaw(resultField string, jsonPayload json.RawMessage) *Result

JsonRaw adds a raw JSON value with a custom field name to the result.

func (*Result) JsonString

func (r *Result) JsonString(resultField string, jqOp string, jsonPayload json.RawMessage) *Result

JsonString adds a string result on a JSON path given over a JQ command to the result.

func (*Result) LookupResultElements

func (r *Result) LookupResultElements(resultField string, lookupResults []LookupResultElement) *Result

LookupResultElements adds lookup result elements with a custom field name to the result.

func (*Result) ReportingRecord added in v0.2.36

func (r *Result) ReportingRecord(record interface{}) *Result

ReportingRecord adds reporting record to the result.

func (*Result) Slice

func (r *Result) Slice(resultField string, result []interface{}) *Result

Slice adds a []interface{} value with a custom field name to the result.

func (*Result) String

func (r *Result) String(resultField string, result string) *Result

String adds a string value with a custom field name to the result.

func (*Result) StringSlice

func (r *Result) StringSlice(resultField string, result []string) *Result

StringSlice adds a []string value with a custom field name to the result.

type SkipResultHandler

type SkipResultHandler struct{}

SkipResultHandler represents a result handler that should be skipped.

func (*SkipResultHandler) Error

func (m *SkipResultHandler) Error() string

Error returns the error message for the SkipResultHandler.

type SliceGenerator

type SliceGenerator struct {
	// contains filtered or unexported fields
}

SliceGenerator represents a []interface{} value with a custom field name.

func (SliceGenerator) FieldName

func (gen SliceGenerator) FieldName() string

FieldName returns the custom field name for the []interface{} value.

func (SliceGenerator) GenerateValue

func (gen SliceGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the []interface{} value.

type StringGenerator

type StringGenerator struct {
	// contains filtered or unexported fields
}

StringGenerator represents a simple string value with a custom field name.

func (StringGenerator) FieldName

func (gen StringGenerator) FieldName() string

FieldName returns the custom field name for the string value.

func (StringGenerator) GenerateValue

func (gen StringGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the string value.

type StringSliceGenerator

type StringSliceGenerator struct {
	// contains filtered or unexported fields
}

StringSliceGenerator represents a []string value with a custom field name.

func (StringSliceGenerator) FieldName

func (gen StringSliceGenerator) FieldName() string

FieldName returns the custom field name for the []string value.

func (StringSliceGenerator) GenerateValue

func (gen StringSliceGenerator) GenerateValue() (interface{}, error)

GenerateValue generates the []string value.

type TaskContext

type TaskContext struct {
	Id         string               `json:"id"`
	Type       string               `json:"type"`
	Properties []PropertyDefinition `json:"properties"`
}

TaskContext represents the context of a task.

type TaskOutputContext

type TaskOutputContext struct {
	ExitCode         int64                  `json:"exitCode"`
	OutputProperties map[string]interface{} `json:"outputProperties,omitempty"`
	JobErrorMessage  string                 `json:"jobErrorMessage,omitempty"`
	ReportingRecords interface{}            `json:"reportingRecords,omitempty"`
}

TaskOutputContext represents the output context of a task.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL