scripts

package module
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanityCheck

func SanityCheck(i *Input, o *Output) error

SanityCheck checks if o is a sane Output of a script when i s the corresponding input

func UnmarshalInput

func UnmarshalInput(inputBytes []byte, i *Input) (err error)

UnmarshalInput decodes a json encoded input and does some minor sanity checking

func UnmarshalOutput

func UnmarshalOutput(inputBytes []byte, o *Output) (err error)

UnmarshalOutput decodes a json encoded output and does some minor sanity checking

Types

type Credential

type Credential struct {
	ID    int    `json:"id,omitempty"`
	Type  string `json:"type,omitempty"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

Credential is currently a ssh key, but may be a password hash in the future

type Input

type Input struct {
	// StateTarget is the state which is to be reached by this deployment task
	// StateTarget is either Deployed or NotDeployed
	StateTarget State `json:"state_target"`

	// User describes the user of this deployment task
	User User `json:"user"`

	// Answers is an answered questionnaire relating to an Output.Questionnaire
	//
	// Maps question names (corresponding to the Output.Questionnaire) to the answers of the user.
	// The type of an answer must be string, if there is no mapping for the key in the corresponding Output.QuestionnaireAnswers.
	// If there is such a mapping the answer type must be of the type indicated by the mapping. See Output.QuestionnaireAnswers for details.
	Answers map[string]interface{} `json:"answers,omitempty"`
}

Input of the deployment script

func (Input) Marshal

func (i Input) Marshal() (iBytes []byte, err error)

Marshal encodes an Input as json

func (Input) String

func (i Input) String() string

type Output

type Output struct {
	// State describes the state of the deployment, after the script execution.
	// When State == Questionnaire then Output.Questionnaire *must* be set.
	// When State == Questionnaire then Output.QuestionnaireAnswers *can* be set.
	// When State == Deployed then Output.Credentials *can* be set.
	State State `json:"state"`

	// Msg is a message for the user.
	Msg string `json:"message"`

	// Questionnaire allows the script to requets further information from the user.
	//
	// This field is Ignored when Output.State is not Questionnaire.
	// Questionnaire maps a question name to a question text.
	Questionnaire map[string]string `json:"questionnaire,omitempty"`

	// QuestionnaireAnswers allows the script to control which answers the user can give.
	//
	// This field is Ignored when Output.State is not Questionnaire.
	// QuestionnaireAnswers maps a question name (corresponding to the question names in Output.Questionnaire) to one of the following:
	// 	- a boolean value indicating a yes/no question with the default selection being the value itself
	// 	- a list of strings or integers indicating that the user must select one of the options of the list
	// 	- a string value indicating that the answer must be of type string. The value itself will be set as default answer for the user.
	//
	// Providing a mapping in QuestionnaireAnswers for a question is optional. If no mapping is provided the default answer must be a string.
	QuestionnaireAnswers map[string]interface{} `json:"questionnaire_answers,omitempty"`

	// Credentials are additionnal credentials for the user.
	// Examples are additional passwords.
	// This field is ignored by the client when Output.State is not Deployed.
	// Credentials maps a credential name to a credential value.
	Credentials map[string]string `json:"credentials,omitempty"`

	// UserCredentialStates are the State s of the credentials found in Input.User.Credentials.
	// This field is not mandatory. The client will assume that all credentials have the State
	// Output.State if this field is not given.
	UserCredentialStates UserCredentialStates `json:"user_credential_states,omitempty"`
}

Output of the deployment script

func (Output) Marshal

func (o Output) Marshal() (oBytes []byte, err error)

Marshal encodes an Output as json

func (Output) String

func (o Output) String() string

type State

type State string

State is a string enum The enum values for State are listed below

const (
	// Deployed value for State
	Deployed State = "deployed"

	// NotDeployed value for State
	NotDeployed State = "not_deployed"

	// Rejected value for State
	// the user can never be deployed
	Rejected State = "rejected"

	// Failed value for State
	// the deployment can be retried
	Failed State = "failed"

	// Questionnaire value for State
	// the user has to fill the questionnaire
	// with the questionnaire data the deployment can be retried
	Questionnaire State = "questionnaire"
)

type User

type User struct {
	UserInfo    UserInfo        `json:"userinfo"`
	Credentials UserCredentials `json:"credentials"`
}

User contains information concerning the user of a deployment

func (User) String

func (u User) String() string

type UserCredentialStates

type UserCredentialStates map[string]map[string]State

UserCredentialStates serves to inform the backend about the per credential states after the script run This maps a credential type like "ssh_key" to a map of the states of credentials of this type.

type UserCredentials

type UserCredentials map[string][]Credential

UserCredentials maps a credential type to the credentials of this type

type UserInfo

type UserInfo map[string]interface{}

UserInfo info about the user

Jump to

Keyboard shortcuts

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