models

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: Apache-2.0 Imports: 2 Imported by: 31

Documentation

Index

Constants

View Source
const (

	// GITHUB based hooks
	GITHUB = iota + 1
	// GITLAB based hooks
	GITLAB
	// GITEA based hooks
	GITEA
)

Variables

View Source
var SupportedPlatforms = map[int]Platform{
	GITHUB: {
		ID:   GITHUB,
		Name: "github",
	},
	GITLAB: {
		ID:   GITLAB,
		Name: "gitlab",
	},
	GITEA: {
		ID:   GITEA,
		Name: "gitea",
	},
}

SupportedPlatforms a map of supported platforms by Krok.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	// ID of the key. This is auto-generated.
	//
	// required: true
	ID int `json:"id"`
	// Name of the key
	//
	// required: true
	Name string `json:"name,omitempty"`
	// UserID is the ID of the user to which this key belongs.
	//
	// required: true
	UserID int `json:"user_id"`
	// APIKeyID is a generated id of the key.
	//
	// required: true
	APIKeyID string `json:"api_key_id"`
	// APIKeySecret is a generated secret, aka, the key.
	//
	// required: true
	APIKeySecret string `json:"api_key_secret"`
	// TTL defines how long this key can live in duration.
	//
	// required: true
	// example: 1h10m10s
	TTL string `json:"ttl"`
	// CreateAt defines when this key was created.
	//
	// required: true
	// example: time.Now()
	CreateAt time.Time `json:"create_at"`
}

APIKey is an api key pair generated by the user to access the api without the frontend. swagger:model

type APIKeyAuthRequest

type APIKeyAuthRequest struct {
	Email        string `json:"email"`
	APIKeyID     string `json:"api_key_id"`
	APIKeySecret string `json:"api_key_secret"`
}

APIKeyAuthRequest contains a user email and their api key.

type Auth

type Auth struct {
	// SSH private key.
	//
	// required: false
	SSH string `json:"ssh,omitempty"`
	// Username is the username required to access the platform for this repositroy.
	//
	// required: false
	Username string `json:"username,omitempty"`
	// Password is the password required to access the platform for this repositroy.
	//
	// required: false
	Password string `json:"password,omitempty"`
	// Hook secret to create a hook with on the respective platform.
	//
	// required: true
	Secret string `json:"secret"`
}

Auth is authentication option for a repository. swagger:model

type Command

type Command struct {
	// Name of the command.
	//
	// required: true
	Name string `json:"name"`
	// ID of the command. Generated.
	//
	// required: true
	ID int `json:"id"`
	// Schedule of the command.
	//
	// required: false
	// example: 0 * * * * // follows cron job syntax.
	Schedule string `json:"schedule,omitempty"`
	// Repositories that this command can execute on.
	//
	// required: false
	Repositories []*Repository `json:"repositories,omitempty"`
	// Image defines the image name and tag of the command
	// Note: At the moment, only docker is supported. Later, runc, containerd...
	//
	// required: true
	// example: krok-hook/slack-notification:v0.0.1
	Image string `json:"image"`
	// Enabled defines if this command can be executed or not.
	//
	// required: false
	// example: false
	Enabled bool `json:"enabled"`
	// Platforms holds all the platforms which this command supports.
	// Calculated, not saved.
	//
	// required: false
	Platforms []Platform `json:"providers,omitempty"`
	// RequiresClone defines if this command wants to clone the repository
	// and thus, requires auth information from the repository (which should have it).
	//
	// required: false
	RequiresClone bool `json:"requires_clone"`
}

Command is a command which can be executed by Krok. swagger:model

type CommandRun

type CommandRun struct {
	// ID is a generatd identifier.
	//
	// required: true
	ID int `json:"id"`
	// EventID is the ID of the event that this run belongs to.
	//
	// required: true
	EventID int `json:"event_id"`
	// CommandName is the name of the command that is being executed.
	//
	// required: true
	CommandName string `json:"command_name"`
	// Status is the current state of the command run.
	//
	// required: true
	// example: created, running, failed, success
	Status string `json:"status"`
	// Outcome is any output of the command. Stdout and stderr combined.
	//
	// required: false
	Outcome string `json:"outcome"`
	// CreatedAt is the time when this command run was created.
	//
	// required: true
	CreateAt time.Time `json:"create_at"`
}

CommandRun is a single run of a command belonging to an event including things like, state, event, and created at. swagger:model

type CommandSetting

type CommandSetting struct {
	// ID is a generated ID.
	//
	// required: true
	ID int `json:"id"`
	// CommandID is the ID of the command to which these settings belong to.
	//
	// required: true
	CommandID int `json:"command_id"`
	// Key is the name of the setting.
	//
	// required: true
	Key string `json:"key"`
	// Value is the value of the setting.
	//
	// required: true
	Value string `json:"value"`
	// InVault defines if this is sensitive information and should be stored securely.
	//
	// required: false
	InVault bool `json:"in_vault"`
}

CommandSetting defines the settings a command can have. swagger:model

type Event

type Event struct {
	// ID is a generated ID.
	//
	// required: true
	ID int `json:"id"`
	// EvenID is the ID of the corresponding event on the given platform. If that cannot be determined
	// an ID is generated.
	//
	// required: true
	EventID string `json:"event_id"`
	// CreatedAt contains the timestamp when this event occurred.
	//
	// required: true
	CreateAt time.Time `json:"create_at"`
	// RepositoryID contains the ID of the repository for which this event occurred.
	//
	// required: true
	RepositoryID int `json:"repository_id"`
	// CommandRuns contains a list of CommandRuns which executed for this event.
	//
	// required: false
	CommandRuns []*CommandRun `json:"command_runs"`
	// Payload defines the information received from the platform for this event.
	//
	// required: true
	Payload string `json:"payload"`
	// VCS is the ID of the platform on which this even occurred.
	//
	// required: true
	VCS int `json:"vcs"`
	// EventType of the name, i.e.: push, ping, pull-request...
	//
	// required: true
	EventType string `json:"event_type"`
}

Event contains details about a platform event, such as the repository it belongs to and the event that created it... swagger:model

type GitLab

type GitLab struct {
	// ProjectID is an optional ID which defines a project in Gitlab.
	//
	// required: false
	ProjectID int `json:"project_id,omitempty"`
}

GitLab contains gitLab specific settings. swagger:model

func (*GitLab) GetProjectID

func (g *GitLab) GetProjectID() int

GetProjectID returns the project id.

type ListOptions

type ListOptions struct {
	// Name of the context for which this option is used.
	//
	// required: false
	// example: "partialNameOfACommand"
	Name string `json:"name,omitempty"`
	// Only list all entries for a given platform ID.
	//
	// required: false
	// example: 1
	VCS int `json:"vcs,omitempty"`
	// Page defines the current page.
	//
	// required: false
	// example: 0
	Page int `json:"page,omitempty"`
	// PageSize defines the number of items per page.
	//
	// required false
	// example: 10
	PageSize int `json:"page_size,omitempty"`
	// StartingDate defines a date of start to look for events. Inclusive.
	//
	// required: false
	// example: 2021-02-02
	StartingDate *time.Time `json:"starting_date,omitempty"`
	// EndDate defines a date of end to look for events. Not Inclusive.
	//
	// required: false
	// example: 2021-02-03
	EndDate *time.Time `json:"end_date,omitempty"`
}

ListOptions provides options for List operations with additional filters. swagger:model

type Platform

type Platform struct {
	// ID of the platform. This is chosen.
	//
	// required: true
	ID int `json:"id"`
	// Name of the platform.
	//
	// required: true
	// example: github, gitlab, gitea
	Name string `json:"name"`
}

Platform defines a platform like Github, Gitlab etc. swagger:model

type Repository

type Repository struct {
	// Name of the repository.
	//
	// required: false
	Name string `json:"name"`
	// ID of the repository. Auto-generated.
	//
	// required: true
	ID int `json:"id"`
	// URL of the repository.
	//
	// required: true
	URL string `json:"url"`
	// VCS Defines which handler will be used. For values, see platforms.go.
	//
	// required: true
	VCS int `json:"vcs"`
	// GitLab specific settings.
	//
	// required: false
	GitLab *GitLab `json:"git_lab,omitempty"`
	// Auth contains authentication details for this repository.
	//
	// required: true
	Auth *Auth `json:"auth,omitempty"`
	// Commands contains all the commands which this repository is attached to.
	//
	// required: false
	Commands []*Command `json:"commands,omitempty"`
	// This field is not saved in the DB but generated every time the repository
	// details needs to be displayed.
	//
	// required: true
	UniqueURL string `json:"unique_url,omitempty"`
	// TODO: Think about storing this
	Events []string `json:"events,omitempty"`
}

Repository is a repository which can be managed by Krok. swagger:model

func (*Repository) Validate

func (r *Repository) Validate() (ok bool, field string, err error)

Validate validates this model.

type TokenResponse

type TokenResponse struct {
	// The generated token
	// in: body
	Token string
}

TokenResponse contains the generated JWT token. swagger:response TokenResponse

type User

type User struct {
	// DisplayName is the name of the user.
	//
	// required: false
	DisplayName string `json:"display_name,omitempty"`
	// Email of the user.
	//
	// required: true
	Email string `json:"email"`
	// ID of the user. This is auto-generated.
	//
	// required: true
	ID int `json:"id"`
	// LastLogin contains the timestamp of the last successful login of this user.
	//
	// required: true
	LastLogin time.Time `json:"last_login,omitempty"`
	// APIKeys contains generated api access keys for this user.
	//
	// required: false
	APIKeys []*APIKey `json:"api_keys,omitempty"`
}

User is a user in the Krok system. swagger:model

type UserAuthDetails

type UserAuthDetails struct {
	// Email is the email of the registered user.
	//
	// required: true
	Email string
	// FirstName is the first name of the user.
	//
	// required: true
	FirstName string
	// LastName is the last name of the user.
	//
	// required: true
	LastName string
}

UserAuthDetails represents the authenticated user details. swagger:model

type VCSToken

type VCSToken struct {
	// Token is the actual token.
	//
	// required: true
	Token string `json:"token"`
	// VCS is the ID of the platform to which this token belongs to.
	//
	// required: true
	VCS int `json:"vcs"`
}

VCSToken represents a token for a platform. swagger:model

type VaultSetting

type VaultSetting struct {
	// Key is the name of the setting.
	//
	// required: true
	Key string `json:"key"`
	// Value is the value of the setting.
	//
	// required: true
	Value string `json:"value"`
}

VaultSetting defines a setting that comes from the vault swagger:model

Jump to

Keyboard shortcuts

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