models

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArgoRolloutAppSuccess      = "success"
	ArgoRolloutAppNotSynced    = "not synced"
	ArgoRolloutAppNotAvailable = "not available"
	ArgoRolloutAppNotHealthy   = "not healthy"
	ArgoRolloutAppDegraded     = "degraded"
)
View Source
const (
	StatusAppNotFoundMessage       = "app not found"
	StatusInProgressMessage        = "in progress"
	StatusFailedMessage            = "failed"
	StatusAborted                  = "aborted"
	StatusArgoCDUnavailableMessage = "argocd is unavailable"
	StatusConnectionUnavailable    = "cannot connect to database"
	StatusArgoCDFailedLogin        = "failed to login to argocd"
	StatusDeployedMessage          = "deployed"
	StatusAccepted                 = "accepted"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	Metadata ApplicationMetadata `json:"metadata"`
	Spec     ApplicationSpec     `json:"spec"`
	Status   ApplicationStatus   `json:"status"`
}

func (*Application) GetRolloutMessage added in v0.6.0

func (app *Application) GetRolloutMessage(status string, rolloutImages []string) string

GetRolloutMessage generates rollout failure message.

func (*Application) GetRolloutStatus added in v0.6.0

func (app *Application) GetRolloutStatus(rolloutImages []string, registryProxyUrl string, acceptSuspended bool) string

GetRolloutStatus calculates application rollout status depending on the expected images and proxy configuration.

func (*Application) IsManagedByWatcher added in v0.6.0

func (app *Application) IsManagedByWatcher() bool

IsManagedByWatcher checks if the application is managed by the watcher. It checks if the application's metadata contains the "argo-watcher/managed" annotation with the value "true".

func (*Application) ListSyncResultResources added in v0.3.0

func (app *Application) ListSyncResultResources() []string

ListSyncResultResources returns a list of strings representing the sync result resources of the application. Each string in the list contains information about the resource's kind, name, hook type, hook phase, and message. The information is formatted as "{kind}({name}) {hookType} {hookPhase} with message {message}". The list is generated based on the Application's status and its operation state's sync result resources.

func (*Application) ListUnhealthyResources added in v0.3.0

func (app *Application) ListUnhealthyResources() []string

ListUnhealthyResources returns a list of strings representing the unhealthy resources of the application. Each string in the list contains information about the resource's kind, name, and health status. If available, the resource's health message is also included in the string. The format of each string is "{kind}({name}) {status}" or "{kind}({name}) {status} with message {message}". The list is generated based on the Application's status and its resources with non-empty health status.

func (*Application) UpdateGitImageTag added in v0.6.0

func (app *Application) UpdateGitImageTag(task *Task) error

type ApplicationMetadata added in v0.8.0

type ApplicationMetadata struct {
	Name        string            `json:"name"`
	Annotations map[string]string `json:"annotations"`
}

type ApplicationOperationResource added in v0.6.0

type ApplicationOperationResource struct {
	HookPhase string `json:"hookPhase"` // example: Failed
	HookType  string `json:"hookType"`  // example: PreSync
	Kind      string `json:"kind"`      // example: Pod | Job
	Message   string `json:"message"`   // example: Job has reached the specified backoff limit
	Status    string `json:"status"`    // example: Synced
	SyncPhase string `json:"syncPhase"` // example: PreSync
	Name      string `json:"name"`      // example: app-migrations
	Namespace string `json:"namespace"` // example: app
}

type ApplicationResource added in v0.6.0

type ApplicationResource struct {
	Kind      string `json:"kind"`      // example: Pod | Job
	Name      string `json:"name"`      // example: app-migrations
	Namespace string `json:"namespace"` // example: app
	Health    struct {
		Message string `json:"message"` // example: Job has reached the specified backoff limit
		Status  string `json:"status"`  // example: Synced
	} `json:"health"`
}

type ApplicationSource added in v0.8.0

type ApplicationSource struct {
	RepoURL        string `json:"repoURL"`
	TargetRevision string `json:"targetRevision"`
	Path           string `json:"path"`
}

type ApplicationSpec added in v0.8.0

type ApplicationSpec struct {
	Source  ApplicationSource   `json:"source"`
	Sources []ApplicationSource `json:"sources"`
}

type ApplicationStatus added in v0.8.0

type ApplicationStatus struct {
	Health struct {
		Status string `json:"status"`
	}
	OperationState ApplicationStatusOperationState `json:"operationState"`
	Resources      []ApplicationResource           `json:"resources"`
	Summary        struct {
		Images []string `json:"images"`
	}
	Sync struct {
		Status string `json:"status"`
	}
}

type ApplicationStatusOperationState added in v0.8.0

type ApplicationStatusOperationState struct {
	Phase      string `json:"phase"`
	Message    string `json:"message"`
	SyncResult struct {
		Resources []ApplicationOperationResource `json:"resources"`
	} `json:"syncResult"`
}

type ArgoApiErrorResponse added in v0.3.0

type ArgoApiErrorResponse struct {
	Error   string `json:"error"`
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

type GitopsRepo added in v0.8.0

type GitopsRepo struct {
	RepoUrl    string `validate:"required"`
	BranchName string `validate:"required"`
	Path       string `validate:"required"`
	Filename   string
}

func NewGitopsRepo added in v0.8.0

func NewGitopsRepo(app *Application) (GitopsRepo, error)

type HealthStatus

type HealthStatus struct {
	Status string `json:"status"`
}

type Image

type Image struct {
	Image string `json:"image" example:"ghcr.io/shini4i/argo-watcher"`
	Tag   string `json:"tag" example:"dev"`
}

type LockdownSchedule added in v0.8.0

type LockdownSchedule struct {
	Cron     string `json:"cron" example:"0 2 * * *"`
	Duration string `json:"duration" example:"2h"`
}

type SavedAppStatus added in v0.6.6

type SavedAppStatus struct {
	Status     string `json:"app_status"`
	ImagesHash []byte `json:"app_hash"`
}

type Task

type Task struct {
	Id             string         `json:"id,omitempty"`
	Created        float64        `json:"created,omitempty"`
	Updated        float64        `json:"updated,omitempty"`
	App            string         `json:"app" binding:"required" example:"argo-watcher"`
	Author         string         `json:"author" binding:"required" example:"John Doe"`
	Project        string         `json:"project" binding:"required" example:"Demo"`
	Images         []Image        `json:"images" binding:"required"`
	Status         string         `json:"status,omitempty"`
	StatusReason   string         `json:"status_reason,omitempty"`
	Validated      bool           `json:"validated,omitempty"`
	SavedAppStatus SavedAppStatus `json:"-"`
}

func (*Task) IsAppNotFoundError added in v0.6.0

func (task *Task) IsAppNotFoundError(err error) bool

IsAppNotFoundError check if app not found error.

func (*Task) ListImages added in v0.3.0

func (task *Task) ListImages() []string

ListImages returns a list of strings representing the images of the task. Each string in the list is in the format "{image}:{tag}". The list is generated based on the Task's Images field.

type TaskStatus

type TaskStatus struct {
	Id           string  `json:"id,omitempty"`
	Created      float64 `json:"created,omitempty"`
	Updated      float64 `json:"updated,omitempty"`
	App          string  `json:"app,omitempty" binding:"required" example:"argo-watcher"`
	Author       string  `json:"author,omitempty" binding:"required" example:"John Doe"`
	Project      string  `json:"project,omitempty" binding:"required" example:"Demo"`
	Images       []Image `json:"images,omitempty" binding:"required"`
	Status       string  `json:"status,omitempty"`
	StatusReason string  `json:"status_reason,omitempty"`
	Error        string  `json:"error,omitempty"`
}

type TasksResponse added in v0.2.0

type TasksResponse struct {
	Tasks []Task `json:"tasks"`
	Error string `json:"error,omitempty"`
}

type Userinfo added in v0.2.0

type Userinfo struct {
	LoggedIn bool   `json:"loggedIn"`
	Username string `json:"username"`
}

Jump to

Keyboard shortcuts

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