Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

chore: Moved common models from shipyard to go-utils #412

Merged
merged 6 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions pkg/api/models/expanded_project.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package models

// ExpandedProject expanded project
//
// swagger:model ExpandedProject
type ExpandedProject struct {

// Creation date of the project
CreationDate string `json:"creationDate,omitempty"`

// Git remote URI
GitRemoteURI string `json:"gitRemoteURI,omitempty"`

// Git User
GitUser string `json:"gitUser,omitempty"`

// last event context
LastEventContext *EventContextInfo `json:"lastEventContext,omitempty"`

// Project name
ProjectName string `json:"projectName,omitempty"`

// Shipyard file content
Shipyard string `json:"shipyard,omitempty"`

// Version of the shipyard file
ShipyardVersion string `json:"shipyardVersion,omitempty"`

// stages
Stages []*ExpandedStage `json:"stages"`
}
19 changes: 19 additions & 0 deletions pkg/api/models/expanded_projects.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package models

// ExpandedProjects expanded projects
//
// swagger:model ExpandedProjects
type ExpandedProjects struct {

// Pointer to next page, base64 encoded
NextPageKey string `json:"nextPageKey,omitempty"`

// Size of returned page
PageSize float64 `json:"pageSize,omitempty"`

// projects
Projects []*ExpandedProject `json:"projects"`

// Total number of projects
TotalCount float64 `json:"totalCount,omitempty"`
}
22 changes: 22 additions & 0 deletions pkg/api/models/expanded_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package models

// ExpandedService service expanded with remediaitons
//
// swagger:model ExpandedService
type ExpandedService struct {

// Creation date of the service
CreationDate string `json:"creationDate,omitempty"`

// Currently deployed image
DeployedImage string `json:"deployedImage,omitempty"`

// last event types
LastEventTypes map[string]EventContextInfo `json:"lastEventTypes,omitempty"`

// open remediations
OpenRemediations []*Remediation `json:"openRemediations"`

// Service name
ServiceName string `json:"serviceName,omitempty"`
}
19 changes: 19 additions & 0 deletions pkg/api/models/expanded_services.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package models

// ExpandedServices expanded services
//
// swagger:model ExpandedProjects
type ExpandedServices struct {

// Pointer to next page, base64 encoded
NextPageKey string `json:"nextPageKey,omitempty"`

// Size of returned page
PageSize float64 `json:"pageSize,omitempty"`

// projects
Services []*ExpandedService `json:"services"`

// Total number of projects
TotalCount float64 `json:"totalCount,omitempty"`
}
19 changes: 19 additions & 0 deletions pkg/api/models/expanded_stage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package models

// ExpandedStage stage with expanded service
//
// swagger:model ExpandedStage
type ExpandedStage struct {

// last event context
LastEventContext *EventContextInfo `json:"lastEventContext,omitempty"`

// services
Services []*ExpandedService `json:"services"`

// Stage name
StageName string `json:"stageName,omitempty"`

// Parent Stages
ParentStages []string `json:"parentStages,omitempty"`
}
17 changes: 17 additions & 0 deletions pkg/api/models/expanded_stages.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package models

// ExpandedStages stores ExpandedStage
type ExpandedStages struct {
RealAnna marked this conversation as resolved.
Show resolved Hide resolved

// Pointer to next page, base64 encoded
NextPageKey string `json:"nextPageKey,omitempty"`

// Size of returned page
PageSize float64 `json:"pageSize,omitempty"`

// stages
Stages []*ExpandedStage `json:"stages"`

// Total number of stages
TotalCount float64 `json:"totalCount,omitempty"`
}
22 changes: 22 additions & 0 deletions pkg/api/models/remediation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package models

// Remediation remediation
//
// swagger:model Remediation
type Remediation struct {

// Executed action
Action string `json:"action,omitempty"`

// ID of the event
EventID string `json:"eventId,omitempty"`

// Keptn Context ID of the event
KeptnContext string `json:"keptnContext,omitempty"`

// Time of the event
Time string `json:"time,omitempty"`

// Type of the event
Type string `json:"type,omitempty"`
}
29 changes: 29 additions & 0 deletions pkg/api/models/sequencecancellation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package models

// SequenceTimeout is used to signal via channel that a sequence needs to be timed out
type SequenceTimeout struct {
RealAnna marked this conversation as resolved.
Show resolved Hide resolved
KeptnContext string
LastEvent KeptnContextExtendedCE
}

// SequenceControlState represent the wanted state of a sequence
type SequenceControlState string
RealAnna marked this conversation as resolved.
Show resolved Hide resolved

const (
// PauseSequence represent a paused sequence
PauseSequence SequenceControlState = "pause"

// ResumeSequence represent a sequence that was paused and should now be resumed
ResumeSequence SequenceControlState = "resume"

// AbortSequence represent a sequence that needs to be aborted
AbortSequence SequenceControlState = "abort"
)

// SequenceControl represents the wanted SequenceControlState for a certain Project Stage and Context
type SequenceControl struct {
RealAnna marked this conversation as resolved.
Show resolved Hide resolved
State SequenceControlState
KeptnContext string
Stage string
Project string
}
10 changes: 10 additions & 0 deletions pkg/api/models/sequencecontrol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package models

// SequenceControlCommand contains instructions to issue a Sequence state change request
type SequenceControlCommand struct {
RealAnna marked this conversation as resolved.
Show resolved Hide resolved
State SequenceControlState `json:"state" binding:"required"`
Stage string `json:"stage"`
}

type SequenceControlResponse struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type SequenceControlResponse should have comment or be unexported

}
107 changes: 107 additions & 0 deletions pkg/api/models/state.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package models

const (
SequenceTriggeredState = "triggered"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported const SequenceTriggeredState should have comment (or a comment on this block) or be unexported

SequenceStartedState = "started"
SequenceWaitingState = "waiting"
SequenceWaitingForApprovalState = "waitingForApproval"
SequenceFinished = "finished"
TimedOut = "timedOut"
SequencePaused = "paused"
SequenceAborted = "aborted"
)

type GetSequenceStateParams struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type GetSequenceStateParams should have comment or be unexported

/*Pointer to the next set of items
In: query
*/
NextPageKey int64 `form:"nextPageKey" json:"nextPageKey"`
/*The number of items to return
Maximum: 50
Minimum: 1
In: query
Default: 20
*/
PageSize int64 `form:"pageSize" json:"pageSize"`
/*Project name
In: query
*/
Project string `form:"project" json:"project"`

/*Sequence name
In: query
*/
Name string `form:"name" json:"name"`

/*Sequence status
In: query
*/
State string `form:"state" json:"state"`

/*From time to fetch sequence states
In: query
*/
FromTime string `form:"fromTime" json:"fromTime"`

/*Before time to fetch sequence states
In: query
*/
BeforeTime string `form:"beforeTime" json:"beforeTime"`

/** Keptn context
In: query
*/
KeptnContext string `form:"keptnContext" json:"keptnContext"`
}

type StateFilter struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type StateFilter should have comment or be unexported

GetSequenceStateParams
}

//SequenceStateEvaluation returns evaluation details
type SequenceStateEvaluation struct {
RealAnna marked this conversation as resolved.
Show resolved Hide resolved
Result string `json:"result" bson:"result"`
Score float64 `json:"score" bson:"score"`
}

// SequenceStateEvent contains information about the Event type time and ID
type SequenceStateEvent struct {
RealAnna marked this conversation as resolved.
Show resolved Hide resolved
Type string `json:"type" bson:"type"`
ID string `json:"id" bson:"id"`
Time string `json:"time" bson:"time"`
}

// SequenceStateStage represent current state of a stage in a sequence
type SequenceStateStage struct {
RealAnna marked this conversation as resolved.
Show resolved Hide resolved
Name string `json:"name" bson:"name"`
Image string `json:"image,omitempty" bson:"image"`
State string `json:"state" bson:"state"`
LatestEvaluation *SequenceStateEvaluation `json:"latestEvaluation,omitempty" bson:"latestEvaluation"`
LatestEvent *SequenceStateEvent `json:"latestEvent,omitempty" bson:"latestEvent"`
LatestFailedEvent *SequenceStateEvent `json:"latestFailedEvent,omitempty" bson:"latestFailedEvent"`
}

// SequenceState represent the current state of a sequence
type SequenceState struct {
RealAnna marked this conversation as resolved.
Show resolved Hide resolved
Name string `json:"name" bson:"name"`
Service string `json:"service" bson:"service"`
Project string `json:"project" bson:"project"`
Time string `json:"time" bson:"time"`
Shkeptncontext string `json:"shkeptncontext" bson:"shkeptncontext"`
State string `json:"state" bson:"state"`
Stages []SequenceStateStage `json:"stages" bson:"stages"`
ProblemTitle string `json:"problemTitle,omitempty" bson:"problemTitle"`
}

// SequenceStates collects all states of a sequence
type SequenceStates struct {
RealAnna marked this conversation as resolved.
Show resolved Hide resolved
States []SequenceState `json:"states"`
// Pointer to next page
NextPageKey int64 `json:"nextPageKey,omitempty"`

// Size of returned page
PageSize int64 `json:"pageSize,omitempty"`

// Total number of events
TotalCount int64 `json:"totalCount,omitempty"`
}