Documentation ¶
Index ¶
- Variables
- func GenerateTag() string
- func Transform(ctx context.Context, model interface{}) error
- func Validate(ctx context.Context, model interface{}) validator.ValidationErrors
- type AWSDetail
- type AWSReservation
- type Account
- type AzureDetail
- type AzureReservation
- type GCPDetail
- type GCPReservation
- type NoopReservation
- type ProviderType
- type Pubkey
- type PubkeyResource
- type Reservation
- type ReservationInstance
- type ReservationInstanceDetail
- type Statistics
- type UsageStat
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPubkeyFormat = errors.New("invalid public key format")
Functions ¶
func GenerateTag ¶
func GenerateTag() string
GenerateTag sets Tag field to a random base62 (base64 without / or +) with a length of 22 characters. Values are cryptographically pseudo-random and pseudo-unique with probability of getting same values the same as for random UUID.
Types ¶
type AWSDetail ¶
type AWSDetail struct { Region string `json:"region"` // Optional instance name Name string `json:"name"` // Optional launch template id ("lt-987432987342") or empty string LaunchTemplateID string `json:"launch_template_id"` // AWS Instance type. Can be blank if LaunchTemplateID is set. InstanceType string `json:"instance_type"` // Amount of instances to provision of type: Instance type. Amount int32 `json:"amount"` // Immediately power off the system after initialization PowerOff bool `json:"poweroff"` // PubkeyName on AWS in given region. Found by the EnsurePubkey job. PubkeyName string `json:"pubkey_name"` }
type AWSReservation ¶
type AWSReservation struct { Reservation // Pubkey ID. PubkeyID *int64 `db:"pubkey_id" json:"pubkey_id,omitempty"` // Source ID. SourceID string `db:"source_id" json:"source_id"` // The ID of the aws reservation which was created or nil when reservation was not yet created. AWSReservationID *string `db:"aws_reservation_id" json:"aws_reservation_id"` // The ID of the image from which the instance is created. AMI's must be prefixed with 'ami-'. // Can be also set to blank, in that case launch template with a valid AMI must be provided. ImageID string `db:"image_id" json:"image_id"` // Detail information is stored as JSON in DB Detail *AWSDetail `db:"detail" json:"detail"` }
type Account ¶
type Account struct { // Required auto-generated PK. ID int64 `db:"id"` // Organization ID. Required. OrgID string `db:"org_id"` // EBS account number. Can be NULL but not blank. AccountNumber sql.NullString `db:"account_number"` }
Account represents a Red Hat Console account
func (Account) CacheKeyName ¶
type AzureDetail ¶
type AzureDetail struct { Location string `json:"location"` // Instance name Name string `json:"name"` // InstanceSize of Azure VM. InstanceSize string `json:"instance_size"` // Amount of instances to provision of type: Instance type. Amount int64 `json:"amount"` // Immediately power off the system after initialization PowerOff bool `json:"poweroff"` // ResourceGroup is name of Resource Group to put the created resources into ResourceGroup string `json:"resource_group"` }
type AzureReservation ¶
type AzureReservation struct { Reservation // Pubkey ID. PubkeyID *int64 `db:"pubkey_id" json:"pubkey_id,omitempty"` // Source ID. SourceID string `db:"source_id" json:"source_id"` // The image-builder compose ID of the image or valid Azure Image ID from Azure Marketplace. ImageID string `json:"image_id"` // Detail information is stored as JSON in DB Detail *AzureDetail `db:"detail" json:"detail"` }
type GCPDetail ¶
type GCPDetail struct { Zone string `json:"zone"` // Optional instance name NamePattern *string `json:"name_pattern"` // GCP Machine type. MachineType string `json:"machine_type"` // Amount of instances to provision of type: Instance type. Amount int64 `json:"amount"` // UUID of instances created in the same reservation UUID string `json:"uuid"` // Optional launch template id global/instanceTemplates/ID or empty string LaunchTemplateID string `json:"launch_template_id"` // Immediately power off the system after initialization PowerOff bool `json:"poweroff"` }
type GCPReservation ¶
type GCPReservation struct { Reservation // Pubkey ID. PubkeyID *int64 `db:"pubkey_id" json:"pubkey_id,omitempty"` // Source ID. SourceID string `db:"source_id" json:"source_id"` // The ID of the gcp reservation which was created. GCPOperationName string `db:"gcp_operation_name"` // The ID of the image from which the instance is created. Can be either UUID // which represents an image-builder compose ID, or Google Image URL which is // passed into the Google API directly. ImageID string `json:"image_id"` // Detail information is stored as JSON in DB Detail *GCPDetail `db:"detail" json:"detail"` }
type NoopReservation ¶
type NoopReservation struct {
Reservation
}
type ProviderType ¶
type ProviderType int
const ( // ProviderTypeUnknown is reserved ProviderTypeUnknown ProviderType = iota // No operation (testing) provider ProviderTypeNoop // Amazon AWS provider ProviderTypeAWS // Microsoft Azure provider ProviderTypeAzure // Google Compute Engine provider ProviderTypeGCP )
func ProviderTypeFromSourcesName ¶
func ProviderTypeFromSourcesName(str string) ProviderType
func ProviderTypeFromString ¶
func ProviderTypeFromString(str string) ProviderType
func (ProviderType) SourcesProviderName ¶
func (pt ProviderType) SourcesProviderName() string
func (ProviderType) String ¶
func (pt ProviderType) String() string
type Pubkey ¶
type Pubkey struct { // Set to true to skip model validation and transformation during save. SkipValidation bool `db:"-"` // Required auto-generated PK. ID int64 `db:"id"` // Associated Account model. Required. AccountID int64 `db:"account_id"` // User-facing name. Required. Name string `db:"name" validate:"required"` // Public key body encoded in base64 (.pub format). Required. Body string `db:"body" validate:"required,sshPubkey"` // Key type: "ssh-ed25519" or "ssh-rsa". Type string `db:"type" validate:"omitempty,oneof=test ssh-rsa ssh-ed25519"` // SHA256 base64 encoded fingerprint with padding without any prefix. Note OpenSSH // typically prints the fingerprint without padding: ssh-keygen -l -f $HOME/.ssh/key.pub // The length is exactly 45 characters including the padding. // Example: "gL/y6MvNmJ8jDXtsL/oMmK8jUuIefN39BBuvYw/Rndk=" Fingerprint string `db:"fingerprint" validate:"omitempty,len=44"` // MD5 fingerprint stored as hexadecimal with colons without any prefix. To generate // such fingerprint: ssh-keygen -l -E md5 -f $HOME/.ssh/key.pub // Example: "89:c5:99:b5:33:48:1c:84:be:da:cb:97:45:b0:4a:ee" FingerprintLegacy string `db:"fingerprint_legacy" validate:"omitempty,len=47"` }
Pubkey represents SSH public key that can be deployed to clients.
func (*Pubkey) BodyWithUsername ¶
type PubkeyResource ¶
type PubkeyResource struct { // Required auto-generated PK. ID int64 `db:"id" json:"id"` // Auto-generated random string, not DB-unique but pseudo-unique (128 bits), // not returned through API, read-only. Used to "tag" resources in clouds for // later use (e.g. search a resource by a tag). Use FormattedTag function to // format it with a proper prefix. Tag string `db:"tag" json:"-"` // Associated Pubkey model. Required. PubkeyID int64 `db:"pubkey_id" json:"pubkey_id"` // Provider constant (for example ProviderTypeAWS). Required. Provider ProviderType `db:"provider" json:"provider"` // Required. SourceID string `db:"source_id" json:"source_id"` // Resource handle (id). Format is provider-dependant. Required. Handle string `db:"handle" json:"handle"` // Region name. This is provider-dependant. Required for providers which don't have global public keys. Region string `db:"region" json:"region"` }
PubkeyResource represents uploaded SSH key-pair resource.
func (*PubkeyResource) FormattedTag ¶
func (p *PubkeyResource) FormattedTag() string
FormattedTag returns Tag concatenated in a safe way for clouds. That means it does not start with a number, only includes alpha-num characters and dash. Tag is
func (*PubkeyResource) RandomizeTag ¶
func (p *PubkeyResource) RandomizeTag()
RandomizeTag sets Tag field via GenerateTag function if and only if the Tag is currently blank.
type Reservation ¶
type Reservation struct { // Required auto-generated PK. ID int64 `db:"id" json:"id"` // Provider type. Required. Provider ProviderType `db:"provider" json:"provider"` // Account ID. Required. AccountID int64 `db:"account_id" json:"-"` // Time when reservation was made. CreatedAt time.Time `db:"created_at" json:"created_at"` // Total number of job steps for this reservation. Steps int32 `db:"steps" json:"steps"` // User-facing step descriptions for each step. Length of StepTitles must be equal to Steps. StepTitles []string `db:"step_titles" json:"step_titles"` // Active job step for this reservation. See Status for more details. Step int32 `db:"step" json:"step"` // Textual status of the reservation or error when there was a failure. This is user-facing message, // it should not contain error details. See Error field for more details. Status string `db:"status" json:"status"` // Error contains error message from the last step. When a job returns an error, execution of // reservation should stop, Success flag should be set to false and Error will contain the error // message. Error string `db:"error" json:"error,omitempty"` // Time when reservation was finished or nil when it's still processing. FinishedAt sql.NullTime `db:"finished_at" json:"finished_at"` // Flag indicating success, error or unknown state (NULL). See Status for the actual error. Success sql.NullBool `db:"success" json:"success"` }
Reservation represents an instance launch reservation. They are associated with a background job system with a particular job with its own ID. The function handlers update the reservation Status, Success and FinishedAt attributes until the job is considered finished.
type ReservationInstance ¶
type ReservationInstance struct { // Reservation ID. ReservationID int64 `db:"reservation_id" json:"reservation_id"` // Instance ID which has been created on a cloud provider. InstanceID string `db:"instance_id" json:"instance_id"` // Instance's description, ip and dns Detail ReservationInstanceDetail `db:"detail" json:"detail" yaml:"detail"` }
type Statistics ¶
type UsageStat ¶
type UsageStat struct { Provider ProviderType `db:"provider"` Result string `db:"result"` Count int64 `db:"count"` }