Documentation ¶
Overview ¶
Package awmclient contains NATS client to interact with argo workflow mediator service
Index ¶
- Constants
- type AWMProvider
- type AWMWorkflowCreateOpt
- type AWSCredential
- type ArgoWorkflowMediatorClient
- type ArgoWorkflowMediatorMock
- type GitCredential
- type NodeStatus
- type OpenStackCredential
- type TerraformWorkflowData
- type WorkflowCreate
- type WorkflowCreateFailed
- type WorkflowCreated
- type WorkflowFailed
- type WorkflowResubmit
- type WorkflowResubmitFailed
- type WorkflowResubmitted
- type WorkflowStatus
- type WorkflowSucceeded
- type WorkflowTerminate
- type WorkflowTerminateFailed
- type WorkflowTerminated
Constants ¶
const TerraformWorkflowFilename string = "terraform.yml"
TerraformWorkflowFilename is the filename for Terraform workflow
const WorkflowCreateFailedEvent common.EventType = common.EventTypePrefix + "WorkflowCreateFailed"
WorkflowCreateFailedEvent is the event name of WorkflowCreateFailed
const WorkflowCreateRequestedEvent common.EventType = common.EventTypePrefix + "WorkflowCreateRequested"
WorkflowCreateRequestedEvent is the type name of WorkflowCreate request
const WorkflowCreatedEvent common.EventType = common.EventTypePrefix + "WorkflowCreated"
WorkflowCreatedEvent is the cloudevent name of WorkflowCreated defined below
const WorkflowFailedEvent common.EventType = common.EventTypePrefix + "WorkflowFailed"
WorkflowFailedEvent is the event type of WorkflowFailed
const WorkflowResubmitFailedEvent common.EventType = common.EventTypePrefix + "WorkflowResubmitFailed"
WorkflowResubmitFailedEvent is the name of the WorkflowResubmitFailed event
const WorkflowResubmitRequestedEvent common.EventType = common.EventTypePrefix + "WorkflowResubmitRequested"
WorkflowResubmitRequestedEvent is the type name of WorkflowResubmit request
const WorkflowResubmittedEvent common.EventType = common.EventTypePrefix + "WorkflowResubmitted"
WorkflowResubmittedEvent is the name of the WorkflowResubmitted event
const WorkflowSucceededEvent common.EventType = common.EventTypePrefix + "WorkflowSucceeded"
WorkflowSucceededEvent is the event type of WorkflowSucceeded
const WorkflowTerminateFailedEvent common.EventType = common.EventTypePrefix + "WorkflowTerminateFailed"
WorkflowTerminateFailedEvent is the name of the WorkflowTerminateFailed
const WorkflowTerminateRequestedEvent common.EventType = common.EventTypePrefix + "WorkflowTerminateRequested"
WorkflowTerminateRequestedEvent is the type name of WorkflowTerminate request
const WorkflowTerminatedEvent common.EventType = common.EventTypePrefix + "WorkflowTerminated"
WorkflowTerminatedEvent is the name of the WorkflowTerminated
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWMProvider ¶
type AWMProvider string
AWMProvider is the ID of cloud provider, used by Argo Workflow Mediator(AWM)
type AWMWorkflowCreateOpt ¶
type AWMWorkflowCreateOpt func(*awmWorkflowCreateOptions)
AWMWorkflowCreateOpt is function on the options for creating workflow
func AWMTerraformWorflowData ¶
func AWMTerraformWorflowData(wfDat TerraformWorkflowData) AWMWorkflowCreateOpt
AWMTerraformWorflowData is a create option that sets workflow data for Terraform workflow
type AWSCredential ¶
type AWSCredential struct { AccessKeyID string `json:"AWS_ACCESS_KEY_ID" mapstructure:"AWS_ACCESS_KEY_ID"` SecretAccessKey string `json:"AWS_SECRET_ACCESS_KEY" mapstructure:"AWS_SECRET_ACCESS_KEY"` }
AWSCredential is credential for AWS.
type ArgoWorkflowMediatorClient ¶
type ArgoWorkflowMediatorClient interface { // create workflow CreateAsync(provider AWMProvider, username string, workflowFilename string, opts ...AWMWorkflowCreateOpt) error // terminate a workflow TerminateAsync(provider AWMProvider, wfName string) error // resubmit a workflow ResubmitAsync(provider AWMProvider, wfName string) error // create workflow Create(ctx context.Context, provider AWMProvider, username string, workflowFilename string, opts ...AWMWorkflowCreateOpt) (awmProvider AWMProvider, wfName string, err error) // terminate a workflow Terminate(ctx context.Context, provider AWMProvider, wfName string) error // resubmit a workflow // TODO unimplemented Resubmit(ctx context.Context, provider AWMProvider, wfName string) (newWfName string, err error) }
ArgoWorkflowMediatorClient is client for Argo Workflow Mediator. Methods with "Async" suffix are asynchronous, they only sends the request, but do not wait for response.
func NewArgoWorkflowMediator ¶
func NewArgoWorkflowMediator(conn *messaging2.StanConnection) ArgoWorkflowMediatorClient
NewArgoWorkflowMediator creates a new ArgoWorkflowMediator
type ArgoWorkflowMediatorMock ¶
type ArgoWorkflowMediatorMock struct { // ensure only called once Called bool Provider common.ID Username string WorkflowFilename string TFWfData TerraformWorkflowData // contains filtered or unexported fields }
ArgoWorkflowMediatorMock is a mock client for Argo Workflow Mediator. This mock is written because mockery does not support function as argument.
func NewArgoWorkflowMediatorMock ¶
func NewArgoWorkflowMediatorMock(returnWorkflowName string, returnError error) *ArgoWorkflowMediatorMock
NewArgoWorkflowMediatorMock ...
func (*ArgoWorkflowMediatorMock) Create ¶
func (awm *ArgoWorkflowMediatorMock) Create( ctx context.Context, provider common.ID, username string, workflowFilename string, opts ...AWMWorkflowCreateOpt, ) (wfName string, err error)
Create ...
func (*ArgoWorkflowMediatorMock) CreateAsync ¶
func (awm *ArgoWorkflowMediatorMock) CreateAsync( provider common.ID, username string, workflowFilename string, opts ...AWMWorkflowCreateOpt, ) error
CreateAsync is not implemented
type GitCredential ¶
type GitCredential struct { Username string `json:"GIT_USERNAME" mapstructure:"GIT_USERNAME"` Password string `json:"GIT_PASSWORD" mapstructure:"GIT_PASSWORD"` }
GitCredential is credential to access template def in git repo.
type NodeStatus ¶
type NodeStatus string
NodeStatus is status of a node in workflow
const ( NodePending NodeStatus = "Pending" NodeRunning NodeStatus = "Running" NodeSucceeded NodeStatus = "Succeeded" NodeSkipped NodeStatus = "Skipped" NodeFailed NodeStatus = "Failed" NodeError NodeStatus = "Error" NodeOmitted NodeStatus = "Omitted" )
Node statuses
type OpenStackCredential ¶
type OpenStackCredential struct { IdentityAPIVersion string `json:"OS_IDENTITY_API_VERSION" mapstructure:"OS_IDENTITY_API_VERSION"` RegionName string `json:"OS_REGION_NAME" mapstructure:"OS_REGION_NAME"` Interface string `json:"OS_INTERFACE" mapstructure:"OS_INTERFACE"` AuthURL string `json:"OS_AUTH_URL" mapstructure:"OS_AUTH_URL"` ProjectDomainID string `json:"OS_PROJECT_DOMAIN_ID" mapstructure:"OS_PROJECT_DOMAIN_ID"` ProjectDomainName string `json:"OS_PROJECT_DOMAIN_NAME" mapstructure:"OS_PROJECT_DOMAIN_NAME"` ProjectID string `json:"OS_PROJECT_ID" mapstructure:"OS_PROJECT_ID"` ProjectName string `json:"OS_PROJECT_NAME" mapstructure:"OS_PROJECT_NAME"` UserDomainName string `json:"OS_USER_DOMAIN_NAME" mapstructure:"OS_USER_DOMAIN_NAME"` Username string `json:"OS_USERNAME" mapstructure:"OS_USERNAME"` Password string `json:"OS_PASSWORD" mapstructure:"OS_PASSWORD"` AuthType string `json:"OS_AUTH_TYPE" mapstructure:"OS_AUTH_TYPE"` AppCredID string `json:"OS_APPLICATION_CREDENTIAL_ID" mapstructure:"OS_APPLICATION_CREDENTIAL_ID"` AppCredName string `json:"OS_APPLICATION_CREDENTIAL_NAME" mapstructure:"OS_APPLICATION_CREDENTIAL_NAME"` AppCredSecret string `json:"OS_APPLICATION_CREDENTIAL_SECRET" mapstructure:"OS_APPLICATION_CREDENTIAL_SECRET"` }
OpenStackCredential is credential for OpenStack. This include both username/password and Application Credential.
type TerraformWorkflowData ¶
type TerraformWorkflowData struct { Username string `mapstructure:"username"` Deployment common.ID `mapstructure:"deployment_id"` TemplateID common.ID `mapstructure:"template_id"` TemplateTypeName service.TemplateTypeName `mapstructure:"template_type"` // This will be used to key Terraform State (Terraform Workspace name) in the Terraform backend. // Namely, this key is used to look up state in the backend. Typically, this will be some derivation of deployment ID. TerraformStateKey string `mapstructure:"tf_state_key"` GitURL string `mapstructure:"git_url"` GitTrackedUpStream struct { Branch string `mapstructure:"branch"` Tag string `mapstructure:"tag"` Commit string `mapstructure:"commit"` } `mapstructure:"git_upstream"` // Path is path within git repo to the Terraform module Path string `mapstructure:"sub_path"` // ID of the cloud credential to use CloudCredID string `mapstructure:"cloud_cred_id"` AnsibleVars map[string]interface{} `mapstructure:"ansible_vars"` // Encrypted cloud credential encoded in base64 CloudCredentialBase64 string `mapstructure:"cloud_cred"` GitCredID string `mapstructure:"git_cred_id"` GitCredentialBase64 string `mapstructure:"git_cred"` }
TerraformWorkflowData is the parameter to required to create a Terraform workflow. Corresponds to WfDat in WorkflowCreate
type WorkflowCreate ¶
type WorkflowCreate struct { // cloud provider that the workflow operates on, this determines which Argo Cluster to dispatch the workflow to Provider AWMProvider `json:"provider"` // username of the user, null if not user specific Username *string `json:"username"` // filename of the workflow definition WorkflowFilename string `json:"workflow_type"` // workflow data, parameters and other metadata used to create the workflow WfDat map[string]interface{} `json:"workflow_data"` }
WorkflowCreate is an event that request the creation of a workflow.
type WorkflowCreateFailed ¶
type WorkflowCreateFailed struct { // ID of the request event (WorkflowCreate) that caused this event RequestID common.EventID `json:"req_id"` // The provider that the workflow is attempted to be created in Provider AWMProvider `json:"provider"` // Type of the error occurred that cause the creation to fail Error string `json:"error"` // Extra error message Msg string `json:"msg"` }
WorkflowCreateFailed is an event emitted when failure occurred during workflow creation. This event is emitted in response to a WorkflowCreate event.
type WorkflowCreated ¶
type WorkflowCreated struct { // ID of the request event (WorkflowCreate) that caused this event RequestID common.EventID `json:"req_id"` // The provider of which the workflow is created in Provider AWMProvider `json:"provider"` // Name of the created workflow WorkflowName string `json:"workflow_name"` }
WorkflowCreated is an event emitted when a Workflow is created.
type WorkflowFailed ¶
type WorkflowFailed struct { // provider that the workflow operates on Provider common.ID `json:"provider,omitempty"` // name of the workflow WorkflowName string `json:"workflow_name"` // status of the Workflow Status WorkflowStatus `json:"status"` // status of the failed node NodeStatus map[string]NodeStatus `json:"node_status"` // assume workflow output is a json object WfOutputs map[string]interface{} `json:"workflow_outputs"` Metadata map[string]interface{} `json:"metadata"` }
WorkflowFailed is an event emitted when workflow failed or errored
type WorkflowResubmit ¶
type WorkflowResubmit struct { // cloud provider that the workflow operates on, this determines which Argo Cluster to dispatch the workflow to Provider AWMProvider `json:"provider"` // name of the workflow WorkflowName string `json:"workflow_name"` }
WorkflowResubmit is an event that request the resubmission of a workflow.
type WorkflowResubmitFailed ¶
type WorkflowResubmitFailed struct { // ID of the request event (WorkflowTerminate) that caused this event RequestID common.EventID `json:"req_id"` // cloud provider that the workflow operates on, this determines which Argo Cluster to dispatch the workflow to Provider AWMProvider `json:"provider"` // name of the workflow that is requested to be resubmitted WorkflowName string `json:"workflow_name"` // Type of the error occurred that cause the resubmission to fail Error string `json:"error"` // Extra error message Msg string `json:"msg"` }
WorkflowResubmitFailed is an event that is emitted when workflow resubmission failed.
type WorkflowResubmitted ¶
type WorkflowResubmitted struct { // ID of the request event (WorkflowResubmit) that caused this event RequestID common.EventID `json:"req_id"` // cloud provider that the workflow operates on, this determines which Argo Cluster to dispatch the workflow to Provider AWMProvider `json:"provider"` // name of the workflow that is requested to be resubmitted WorkflowName string `json:"workflow_name"` // name of the newly created workflow as the result of the resubmission NewWorkflowName string `json:"new_workflow_name"` }
WorkflowResubmitted is an event that is emitted when workflow resubmission succeeded.
type WorkflowStatus ¶
type WorkflowStatus string
WorkflowStatus is the status of workflow
const ( WfPending WorkflowStatus = "Pending" WfRunning WorkflowStatus = "Running" WfSucceeded WorkflowStatus = "Succeeded" WfSkipped WorkflowStatus = "Skipped" WfFailed WorkflowStatus = "Failed" WfError WorkflowStatus = "Error" WfOmitted WorkflowStatus = "Omitted" )
Workflow statuses
type WorkflowSucceeded ¶
type WorkflowSucceeded struct { // provider that the workflow operates on Provider common.ID `json:"provider,omitempty"` // name of the workflow WorkflowName string `json:"workflow_name"` // status of the Workflow Status WorkflowStatus `json:"status"` // assume workflow output is a json object WfOutputs map[string]interface{} `json:"workflow_outputs"` Metadata map[string]interface{} `json:"metadata"` }
WorkflowSucceeded is an event emitted when workflow succeeded
type WorkflowTerminate ¶
type WorkflowTerminate struct { // cloud provider that the workflow operates on, this determines which Argo Cluster to dispatch the workflow to Provider AWMProvider `json:"provider"` // name of the workflow WorkflowName string `json:"workflow_name"` }
WorkflowTerminate is an event that request the terminatation of a workflow.
type WorkflowTerminateFailed ¶
type WorkflowTerminateFailed struct { // ID of the request event (WorkflowTerminate) that caused this event RequestID common.EventID `json:"req_id"` // cloud provider that the workflow operates on, this determines which Argo Cluster to dispatch the workflow to Provider AWMProvider `json:"provider"` // name of the workflow WorkflowName string `json:"workflow_name"` // Type of the error occurred that cause the termination to fail Error string `json:"error"` // Extra error message Msg string `json:"msg"` }
WorkflowTerminateFailed is an event emitted when fail to terminate a workflow.
type WorkflowTerminated ¶
type WorkflowTerminated struct { // ID of the request event (WorkflowTerminate) that caused this event RequestID common.EventID `json:"req_id"` // cloud provider that the workflow operates on, this determines which Argo Cluster to dispatch the workflow to Provider AWMProvider `json:"provider"` // name of the workflow WorkflowName string `json:"workflow_name"` // status of the workflow WorkflowStatus string `json:"workflow_status"` }
WorkflowTerminated is an event emitted when a workflow is terminated via a WorkflowTerminateCmd event.