2016-12-18 05:21:29 +00:00
|
|
|
package portainer
|
|
|
|
|
|
|
|
type (
|
|
|
|
// Pair defines a key/value string pair
|
|
|
|
Pair struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Value string `json:"value"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// CLIFlags represents the available flags on the CLI
|
2016-12-18 05:21:29 +00:00
|
|
|
CLIFlags struct {
|
2017-02-06 05:29:34 +00:00
|
|
|
Addr *string
|
2018-01-24 20:58:58 +00:00
|
|
|
AdminPassword *string
|
|
|
|
AdminPasswordFile *string
|
2017-02-06 05:29:34 +00:00
|
|
|
Assets *string
|
|
|
|
Data *string
|
2018-05-19 14:25:11 +00:00
|
|
|
EndpointURL *string
|
2018-01-15 18:34:07 +00:00
|
|
|
ExternalEndpoints *string
|
2018-01-24 20:58:58 +00:00
|
|
|
Labels *[]Pair
|
|
|
|
Logo *string
|
2017-02-06 05:29:34 +00:00
|
|
|
NoAuth *bool
|
2017-03-03 11:54:22 +00:00
|
|
|
NoAnalytics *bool
|
2018-01-24 20:58:58 +00:00
|
|
|
Templates *string
|
2018-07-03 18:31:02 +00:00
|
|
|
TemplateFile *string
|
2018-05-19 14:25:11 +00:00
|
|
|
TLS *bool
|
2018-05-06 07:15:57 +00:00
|
|
|
TLSSkipVerify *bool
|
2017-02-06 05:29:34 +00:00
|
|
|
TLSCacert *string
|
|
|
|
TLSCert *string
|
|
|
|
TLSKey *string
|
2017-04-25 09:51:22 +00:00
|
|
|
SSL *bool
|
|
|
|
SSLCert *string
|
|
|
|
SSLKey *string
|
2018-01-15 18:34:07 +00:00
|
|
|
SyncInterval *string
|
2018-07-11 08:39:20 +00:00
|
|
|
Snapshot *bool
|
|
|
|
SnapshotInterval *string
|
2017-06-01 08:14:55 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// Status represents the application status
|
2017-06-01 08:14:55 +00:00
|
|
|
Status struct {
|
|
|
|
Authentication bool `json:"Authentication"`
|
|
|
|
EndpointManagement bool `json:"EndpointManagement"`
|
2018-07-11 08:39:20 +00:00
|
|
|
Snapshot bool `json:"Snapshot"`
|
2017-06-01 08:14:55 +00:00
|
|
|
Analytics bool `json:"Analytics"`
|
|
|
|
Version string `json:"Version"`
|
2016-12-18 05:21:29 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// LDAPSettings represents the settings used to connect to a LDAP server
|
2017-08-10 08:35:23 +00:00
|
|
|
LDAPSettings struct {
|
2018-07-23 04:57:38 +00:00
|
|
|
ReaderDN string `json:"ReaderDN"`
|
2018-11-23 19:40:56 +00:00
|
|
|
Password string `json:"Password,omitempty"`
|
2018-07-23 04:57:38 +00:00
|
|
|
URL string `json:"URL"`
|
|
|
|
TLSConfig TLSConfiguration `json:"TLSConfig"`
|
|
|
|
StartTLS bool `json:"StartTLS"`
|
|
|
|
SearchSettings []LDAPSearchSettings `json:"SearchSettings"`
|
|
|
|
GroupSearchSettings []LDAPGroupSearchSettings `json:"GroupSearchSettings"`
|
2018-07-24 06:49:17 +00:00
|
|
|
AutoCreateUsers bool `json:"AutoCreateUsers"`
|
2017-08-10 08:35:23 +00:00
|
|
|
}
|
|
|
|
|
2018-12-30 16:02:22 +00:00
|
|
|
// OAuthSettings represents the settings used to authorize with an authorization server
|
|
|
|
OAuthSettings struct {
|
|
|
|
ClientID string `json:"ClientID"`
|
|
|
|
ClientSecret string `json:"ClientSecret,omitempty"`
|
|
|
|
AccessTokenURI string `json:"AccessTokenURI"`
|
|
|
|
AuthorizationURI string `json:"AuthorizationURI"`
|
|
|
|
ResourceURI string `json:"ResourceURI"`
|
|
|
|
RedirectURI string `json:"RedirectURI"`
|
|
|
|
UserIdentifier string `json:"UserIdentifier"`
|
|
|
|
Scopes string `json:"Scopes"`
|
|
|
|
OAuthAutoCreateUsers bool `json:"OAuthAutoCreateUsers"`
|
2019-02-18 01:46:34 +00:00
|
|
|
DefaultTeamID TeamID `json:"DefaultTeamID"`
|
2018-12-30 16:02:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TLSConfiguration represents a TLS configuration
|
2017-08-10 08:35:23 +00:00
|
|
|
TLSConfiguration struct {
|
|
|
|
TLS bool `json:"TLS"`
|
|
|
|
TLSSkipVerify bool `json:"TLSSkipVerify"`
|
|
|
|
TLSCACertPath string `json:"TLSCACert,omitempty"`
|
|
|
|
TLSCertPath string `json:"TLSCert,omitempty"`
|
|
|
|
TLSKeyPath string `json:"TLSKey,omitempty"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// LDAPSearchSettings represents settings used to search for users in a LDAP server
|
2017-08-10 08:35:23 +00:00
|
|
|
LDAPSearchSettings struct {
|
|
|
|
BaseDN string `json:"BaseDN"`
|
|
|
|
Filter string `json:"Filter"`
|
|
|
|
UserNameAttribute string `json:"UserNameAttribute"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// LDAPGroupSearchSettings represents settings used to search for groups in a LDAP server
|
2018-07-23 04:57:38 +00:00
|
|
|
LDAPGroupSearchSettings struct {
|
|
|
|
GroupBaseDN string `json:"GroupBaseDN"`
|
|
|
|
GroupFilter string `json:"GroupFilter"`
|
|
|
|
GroupAttribute string `json:"GroupAttribute"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// Settings represents the application settings
|
2016-12-18 05:21:29 +00:00
|
|
|
Settings struct {
|
2017-09-27 07:26:04 +00:00
|
|
|
LogoURL string `json:"LogoURL"`
|
|
|
|
BlackListedLabels []Pair `json:"BlackListedLabels"`
|
|
|
|
AuthenticationMethod AuthenticationMethod `json:"AuthenticationMethod"`
|
|
|
|
LDAPSettings LDAPSettings `json:"LDAPSettings"`
|
2018-12-30 16:02:22 +00:00
|
|
|
OAuthSettings OAuthSettings `json:"OAuthSettings"`
|
2017-09-27 07:26:04 +00:00
|
|
|
AllowBindMountsForRegularUsers bool `json:"AllowBindMountsForRegularUsers"`
|
|
|
|
AllowPrivilegedModeForRegularUsers bool `json:"AllowPrivilegedModeForRegularUsers"`
|
2018-07-11 08:39:20 +00:00
|
|
|
SnapshotInterval string `json:"SnapshotInterval"`
|
2018-08-07 15:43:36 +00:00
|
|
|
TemplatesURL string `json:"TemplatesURL"`
|
2018-12-05 22:36:25 +00:00
|
|
|
EnableHostManagementFeatures bool `json:"EnableHostManagementFeatures"`
|
2018-07-11 08:39:20 +00:00
|
|
|
|
2018-05-28 14:40:59 +00:00
|
|
|
// Deprecated fields
|
2018-07-03 18:31:02 +00:00
|
|
|
DisplayDonationHeader bool
|
|
|
|
DisplayExternalContributors bool
|
2016-12-18 05:21:29 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// User represents a user account
|
2016-12-18 05:21:29 +00:00
|
|
|
User struct {
|
2017-03-12 16:24:15 +00:00
|
|
|
ID UserID `json:"Id"`
|
|
|
|
Username string `json:"Username"`
|
|
|
|
Password string `json:"Password,omitempty"`
|
|
|
|
Role UserRole `json:"Role"`
|
2016-12-18 05:21:29 +00:00
|
|
|
}
|
|
|
|
|
2017-03-12 16:24:15 +00:00
|
|
|
// UserID represents a user identifier
|
|
|
|
UserID int
|
|
|
|
|
|
|
|
// UserRole represents the role of a user. It can be either an administrator
|
2017-05-23 18:56:10 +00:00
|
|
|
// or a regular user
|
2017-03-12 16:24:15 +00:00
|
|
|
UserRole int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// AuthenticationMethod represents the authentication method used to authenticate a user
|
2017-08-10 08:35:23 +00:00
|
|
|
AuthenticationMethod int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// Team represents a list of user accounts
|
2017-05-23 18:56:10 +00:00
|
|
|
Team struct {
|
|
|
|
ID TeamID `json:"Id"`
|
|
|
|
Name string `json:"Name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// TeamID represents a team identifier
|
|
|
|
TeamID int
|
|
|
|
|
|
|
|
// TeamMembership represents a membership association between a user and a team
|
|
|
|
TeamMembership struct {
|
|
|
|
ID TeamMembershipID `json:"Id"`
|
|
|
|
UserID UserID `json:"UserID"`
|
|
|
|
TeamID TeamID `json:"TeamID"`
|
|
|
|
Role MembershipRole `json:"Role"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// TeamMembershipID represents a team membership identifier
|
|
|
|
TeamMembershipID int
|
|
|
|
|
|
|
|
// MembershipRole represents the role of a user within a team
|
|
|
|
MembershipRole int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TokenData represents the data embedded in a JWT token
|
2016-12-18 05:21:29 +00:00
|
|
|
TokenData struct {
|
2017-03-12 16:24:15 +00:00
|
|
|
ID UserID
|
2016-12-18 05:21:29 +00:00
|
|
|
Username string
|
2017-03-12 16:24:15 +00:00
|
|
|
Role UserRole
|
2016-12-18 05:21:29 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// StackID represents a stack identifier (it must be composed of Name + "_" + SwarmID to create a unique identifier)
|
2018-06-18 10:07:56 +00:00
|
|
|
StackID int
|
2017-10-15 17:24:40 +00:00
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// StackType represents the type of the stack (compose v2, stack deploy v3)
|
2018-06-11 13:13:19 +00:00
|
|
|
StackType int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// Stack represents a Docker stack created via docker stack deploy
|
2017-10-15 17:24:40 +00:00
|
|
|
Stack struct {
|
2018-06-11 13:13:19 +00:00
|
|
|
ID StackID `json:"Id"`
|
|
|
|
Name string `json:"Name"`
|
|
|
|
Type StackType `json:"Type"`
|
|
|
|
EndpointID EndpointID `json:"EndpointId"`
|
|
|
|
SwarmID string `json:"SwarmId"`
|
|
|
|
EntryPoint string `json:"EntryPoint"`
|
|
|
|
Env []Pair `json:"Env"`
|
2017-10-15 17:24:40 +00:00
|
|
|
ProjectPath string
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// RegistryID represents a registry identifier
|
2017-06-20 11:00:32 +00:00
|
|
|
RegistryID int
|
|
|
|
|
2018-12-09 03:49:27 +00:00
|
|
|
// RegistryType represents a type of registry
|
|
|
|
RegistryType int
|
|
|
|
|
2017-06-20 11:00:32 +00:00
|
|
|
// Registry represents a Docker registry with all the info required
|
2018-08-21 18:40:42 +00:00
|
|
|
// to connect to it
|
2017-06-20 11:00:32 +00:00
|
|
|
Registry struct {
|
2018-12-09 03:49:27 +00:00
|
|
|
ID RegistryID `json:"Id"`
|
|
|
|
Type RegistryType `json:"Type"`
|
|
|
|
Name string `json:"Name"`
|
|
|
|
URL string `json:"URL"`
|
|
|
|
Authentication bool `json:"Authentication"`
|
|
|
|
Username string `json:"Username"`
|
|
|
|
Password string `json:"Password,omitempty"`
|
|
|
|
AuthorizedUsers []UserID `json:"AuthorizedUsers"`
|
|
|
|
AuthorizedTeams []TeamID `json:"AuthorizedTeams"`
|
|
|
|
ManagementConfiguration *RegistryManagementConfiguration `json:"ManagementConfiguration"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegistryManagementConfiguration represents a configuration that can be used to query
|
|
|
|
// the registry API via the registry management extension.
|
|
|
|
RegistryManagementConfiguration struct {
|
|
|
|
Type RegistryType `json:"Type"`
|
|
|
|
Authentication bool `json:"Authentication"`
|
|
|
|
Username string `json:"Username"`
|
|
|
|
Password string `json:"Password"`
|
|
|
|
TLSConfig TLSConfiguration `json:"TLSConfig"`
|
2017-06-20 11:00:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DockerHub represents all the required information to connect and use the
|
2018-08-21 18:40:42 +00:00
|
|
|
// Docker Hub
|
2017-06-20 11:00:32 +00:00
|
|
|
DockerHub struct {
|
|
|
|
Authentication bool `json:"Authentication"`
|
|
|
|
Username string `json:"Username"`
|
2018-03-22 22:44:43 +00:00
|
|
|
Password string `json:"Password,omitempty"`
|
2017-06-20 11:00:32 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// EndpointID represents an endpoint identifier
|
2016-12-25 20:34:02 +00:00
|
|
|
EndpointID int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// EndpointType represents the type of an endpoint
|
2018-05-06 07:15:57 +00:00
|
|
|
EndpointType int
|
|
|
|
|
2018-07-11 08:39:20 +00:00
|
|
|
// EndpointStatus represents the status of an endpoint
|
|
|
|
EndpointStatus int
|
|
|
|
|
2016-12-25 20:34:02 +00:00
|
|
|
// Endpoint represents a Docker endpoint with all the info required
|
2018-08-21 18:40:42 +00:00
|
|
|
// to connect to it
|
2016-12-25 20:34:02 +00:00
|
|
|
Endpoint struct {
|
2018-05-28 14:40:33 +00:00
|
|
|
ID EndpointID `json:"Id"`
|
|
|
|
Name string `json:"Name"`
|
|
|
|
Type EndpointType `json:"Type"`
|
|
|
|
URL string `json:"URL"`
|
|
|
|
GroupID EndpointGroupID `json:"GroupId"`
|
|
|
|
PublicURL string `json:"PublicURL"`
|
|
|
|
TLSConfig TLSConfiguration `json:"TLSConfig"`
|
|
|
|
AuthorizedUsers []UserID `json:"AuthorizedUsers"`
|
|
|
|
AuthorizedTeams []TeamID `json:"AuthorizedTeams"`
|
|
|
|
Extensions []EndpointExtension `json:"Extensions"`
|
|
|
|
AzureCredentials AzureCredentials `json:"AzureCredentials,omitempty"`
|
2018-06-15 07:18:25 +00:00
|
|
|
Tags []string `json:"Tags"`
|
2018-07-11 08:39:20 +00:00
|
|
|
Status EndpointStatus `json:"Status"`
|
|
|
|
Snapshots []Snapshot `json:"Snapshots"`
|
2017-09-14 06:08:37 +00:00
|
|
|
|
|
|
|
// Deprecated fields
|
|
|
|
// Deprecated in DBVersion == 4
|
|
|
|
TLS bool `json:"TLS,omitempty"`
|
|
|
|
TLSCACertPath string `json:"TLSCACert,omitempty"`
|
|
|
|
TLSCertPath string `json:"TLSCert,omitempty"`
|
|
|
|
TLSKeyPath string `json:"TLSKey,omitempty"`
|
2016-12-18 05:21:29 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 20:58:15 +00:00
|
|
|
// ScheduleID represents a schedule identifier.
|
|
|
|
ScheduleID int
|
|
|
|
|
2018-11-06 09:49:48 +00:00
|
|
|
// JobType represents a job type
|
|
|
|
JobType int
|
|
|
|
|
|
|
|
// ScriptExecutionJob represents a scheduled job that can execute a script via a privileged container
|
|
|
|
ScriptExecutionJob struct {
|
2018-11-09 02:22:08 +00:00
|
|
|
Endpoints []EndpointID
|
|
|
|
Image string
|
|
|
|
ScriptPath string
|
|
|
|
RetryCount int
|
|
|
|
RetryInterval int
|
2018-11-06 09:49:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SnapshotJob represents a scheduled job that can create endpoint snapshots
|
2018-11-13 01:39:26 +00:00
|
|
|
SnapshotJob struct{}
|
2018-11-06 09:49:48 +00:00
|
|
|
|
|
|
|
// EndpointSyncJob represents a scheduled job that synchronize endpoints based on an external file
|
2018-11-13 01:39:26 +00:00
|
|
|
EndpointSyncJob struct{}
|
2018-11-06 09:49:48 +00:00
|
|
|
|
|
|
|
// Schedule represents a scheduled job.
|
|
|
|
// It only contains a pointer to one of the JobRunner implementations
|
2018-12-06 19:53:23 +00:00
|
|
|
// based on the JobType.
|
|
|
|
// NOTE: The Recurring option is only used by ScriptExecutionJob at the moment
|
2018-11-05 20:58:15 +00:00
|
|
|
Schedule struct {
|
2018-11-06 09:49:48 +00:00
|
|
|
ID ScheduleID `json:"Id"`
|
|
|
|
Name string
|
|
|
|
CronExpression string
|
2018-12-06 19:53:23 +00:00
|
|
|
Recurring bool
|
2018-11-06 20:22:30 +00:00
|
|
|
Created int64
|
2018-11-06 09:49:48 +00:00
|
|
|
JobType JobType
|
|
|
|
ScriptExecutionJob *ScriptExecutionJob
|
|
|
|
SnapshotJob *SnapshotJob
|
|
|
|
EndpointSyncJob *EndpointSyncJob
|
2018-11-05 20:58:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// WebhookID represents a webhook identifier.
|
2018-09-03 10:08:03 +00:00
|
|
|
WebhookID int
|
|
|
|
|
|
|
|
// WebhookType represents the type of resource a webhook is related to
|
|
|
|
WebhookType int
|
|
|
|
|
|
|
|
// Webhook represents a url webhook that can be used to update a service
|
|
|
|
Webhook struct {
|
|
|
|
ID WebhookID `json:"Id"`
|
|
|
|
Token string `json:"Token"`
|
|
|
|
ResourceID string `json:"ResourceId"`
|
|
|
|
EndpointID EndpointID `json:"EndpointId"`
|
|
|
|
WebhookType WebhookType `json:"Type"`
|
|
|
|
}
|
|
|
|
|
2018-05-28 14:40:33 +00:00
|
|
|
// AzureCredentials represents the credentials used to connect to an Azure
|
|
|
|
// environment.
|
|
|
|
AzureCredentials struct {
|
|
|
|
ApplicationID string `json:"ApplicationID"`
|
|
|
|
TenantID string `json:"TenantID"`
|
|
|
|
AuthenticationKey string `json:"AuthenticationKey"`
|
|
|
|
}
|
|
|
|
|
2018-07-11 08:39:20 +00:00
|
|
|
// Snapshot represents a snapshot of a specific endpoint at a specific time
|
|
|
|
Snapshot struct {
|
2018-10-28 09:27:06 +00:00
|
|
|
Time int64 `json:"Time"`
|
|
|
|
DockerVersion string `json:"DockerVersion"`
|
|
|
|
Swarm bool `json:"Swarm"`
|
|
|
|
TotalCPU int `json:"TotalCPU"`
|
|
|
|
TotalMemory int64 `json:"TotalMemory"`
|
|
|
|
RunningContainerCount int `json:"RunningContainerCount"`
|
|
|
|
StoppedContainerCount int `json:"StoppedContainerCount"`
|
|
|
|
VolumeCount int `json:"VolumeCount"`
|
|
|
|
ImageCount int `json:"ImageCount"`
|
|
|
|
ServiceCount int `json:"ServiceCount"`
|
|
|
|
StackCount int `json:"StackCount"`
|
|
|
|
SnapshotRaw SnapshotRaw `json:"SnapshotRaw"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// SnapshotRaw represents all the information related to a snapshot as returned by the Docker API
|
|
|
|
SnapshotRaw struct {
|
|
|
|
Containers interface{} `json:"Containers"`
|
|
|
|
Volumes interface{} `json:"Volumes"`
|
|
|
|
Networks interface{} `json:"Networks"`
|
|
|
|
Images interface{} `json:"Images"`
|
|
|
|
Info interface{} `json:"Info"`
|
|
|
|
Version interface{} `json:"Version"`
|
2018-07-11 08:39:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// EndpointGroupID represents an endpoint group identifier
|
2018-04-26 16:08:46 +00:00
|
|
|
EndpointGroupID int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// EndpointGroup represents a group of endpoints
|
2018-04-26 16:08:46 +00:00
|
|
|
EndpointGroup struct {
|
|
|
|
ID EndpointGroupID `json:"Id"`
|
|
|
|
Name string `json:"Name"`
|
|
|
|
Description string `json:"Description"`
|
|
|
|
AuthorizedUsers []UserID `json:"AuthorizedUsers"`
|
|
|
|
AuthorizedTeams []TeamID `json:"AuthorizedTeams"`
|
2018-06-15 07:18:25 +00:00
|
|
|
Tags []string `json:"Tags"`
|
|
|
|
|
|
|
|
// Deprecated fields
|
|
|
|
Labels []Pair `json:"Labels"`
|
2018-04-26 16:08:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-09 03:49:27 +00:00
|
|
|
// EndpointExtension represents a deprecated form of Portainer extension
|
|
|
|
// TODO: legacy extension management
|
2018-02-23 02:10:26 +00:00
|
|
|
EndpointExtension struct {
|
|
|
|
Type EndpointExtensionType `json:"Type"`
|
|
|
|
URL string `json:"URL"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// EndpointExtensionType represents the type of an endpoint extension. Only
|
2018-08-21 18:40:42 +00:00
|
|
|
// one extension of each type can be associated to an endpoint
|
2018-02-23 02:10:26 +00:00
|
|
|
EndpointExtensionType int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// ResourceControlID represents a resource control identifier
|
2017-05-23 18:56:10 +00:00
|
|
|
ResourceControlID int
|
|
|
|
|
|
|
|
// ResourceControl represent a reference to a Docker resource with specific access controls
|
2017-03-12 16:24:15 +00:00
|
|
|
ResourceControl struct {
|
2018-08-19 05:57:28 +00:00
|
|
|
ID ResourceControlID `json:"Id"`
|
|
|
|
ResourceID string `json:"ResourceId"`
|
|
|
|
SubResourceIDs []string `json:"SubResourceIds"`
|
|
|
|
Type ResourceControlType `json:"Type"`
|
|
|
|
UserAccesses []UserResourceAccess `json:"UserAccesses"`
|
|
|
|
TeamAccesses []TeamResourceAccess `json:"TeamAccesses"`
|
|
|
|
Public bool `json:"Public"`
|
2017-05-23 18:56:10 +00:00
|
|
|
|
|
|
|
// Deprecated fields
|
2017-09-14 06:08:37 +00:00
|
|
|
// Deprecated in DBVersion == 2
|
|
|
|
OwnerID UserID `json:"OwnerId,omitempty"`
|
|
|
|
AccessLevel ResourceAccessLevel `json:"AccessLevel,omitempty"`
|
2018-08-19 05:57:28 +00:00
|
|
|
|
|
|
|
// Deprecated in DBVersion == 14
|
|
|
|
AdministratorsOnly bool `json:"AdministratorsOnly,omitempty"`
|
2017-03-12 16:24:15 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// ResourceControlType represents the type of resource associated to the resource control (volume, container, service...)
|
2017-03-12 16:24:15 +00:00
|
|
|
ResourceControlType int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// UserResourceAccess represents the level of control on a resource for a specific user
|
2017-05-23 18:56:10 +00:00
|
|
|
UserResourceAccess struct {
|
|
|
|
UserID UserID `json:"UserId"`
|
|
|
|
AccessLevel ResourceAccessLevel `json:"AccessLevel"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TeamResourceAccess represents the level of control on a resource for a specific team
|
2017-05-23 18:56:10 +00:00
|
|
|
TeamResourceAccess struct {
|
|
|
|
TeamID TeamID `json:"TeamId"`
|
|
|
|
AccessLevel ResourceAccessLevel `json:"AccessLevel"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TagID represents a tag identifier
|
2018-06-15 07:18:25 +00:00
|
|
|
TagID int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// Tag represents a tag that can be associated to a resource
|
2018-06-15 07:18:25 +00:00
|
|
|
Tag struct {
|
|
|
|
ID TagID
|
|
|
|
Name string `json:"Name"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TemplateID represents a template identifier
|
2018-07-03 18:31:02 +00:00
|
|
|
TemplateID int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TemplateType represents the type of a template
|
2018-07-03 18:31:02 +00:00
|
|
|
TemplateType int
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// Template represents an application template
|
2018-07-03 18:31:02 +00:00
|
|
|
Template struct {
|
|
|
|
// Mandatory container/stack fields
|
|
|
|
ID TemplateID `json:"Id"`
|
|
|
|
Type TemplateType `json:"type"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Description string `json:"description"`
|
|
|
|
AdministratorOnly bool `json:"administrator_only"`
|
|
|
|
|
|
|
|
// Mandatory container fields
|
|
|
|
Image string `json:"image"`
|
|
|
|
|
|
|
|
// Mandatory stack fields
|
|
|
|
Repository TemplateRepository `json:"repository"`
|
|
|
|
|
|
|
|
// Optional stack/container fields
|
|
|
|
Name string `json:"name,omitempty"`
|
|
|
|
Logo string `json:"logo,omitempty"`
|
|
|
|
Env []TemplateEnv `json:"env,omitempty"`
|
|
|
|
Note string `json:"note,omitempty"`
|
|
|
|
Platform string `json:"platform,omitempty"`
|
|
|
|
Categories []string `json:"categories,omitempty"`
|
|
|
|
|
|
|
|
// Optional container fields
|
|
|
|
Registry string `json:"registry,omitempty"`
|
|
|
|
Command string `json:"command,omitempty"`
|
|
|
|
Network string `json:"network,omitempty"`
|
|
|
|
Volumes []TemplateVolume `json:"volumes,omitempty"`
|
|
|
|
Ports []string `json:"ports,omitempty"`
|
|
|
|
Labels []Pair `json:"labels,omitempty"`
|
|
|
|
Privileged bool `json:"privileged,omitempty"`
|
|
|
|
Interactive bool `json:"interactive,omitempty"`
|
|
|
|
RestartPolicy string `json:"restart_policy,omitempty"`
|
|
|
|
Hostname string `json:"hostname,omitempty"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TemplateEnv represents a template environment variable configuration
|
2018-07-03 18:31:02 +00:00
|
|
|
TemplateEnv struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Label string `json:"label,omitempty"`
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
Default string `json:"default,omitempty"`
|
|
|
|
Preset bool `json:"preset,omitempty"`
|
|
|
|
Select []TemplateEnvSelect `json:"select,omitempty"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TemplateVolume represents a template volume configuration
|
2018-07-03 18:31:02 +00:00
|
|
|
TemplateVolume struct {
|
|
|
|
Container string `json:"container"`
|
|
|
|
Bind string `json:"bind,omitempty"`
|
|
|
|
ReadOnly bool `json:"readonly,omitempty"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TemplateRepository represents the git repository configuration for a template
|
2018-07-03 18:31:02 +00:00
|
|
|
TemplateRepository struct {
|
|
|
|
URL string `json:"url"`
|
|
|
|
StackFile string `json:"stackfile"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// TemplateEnvSelect represents text/value pair that will be displayed as a choice for the
|
2018-08-21 18:40:42 +00:00
|
|
|
// template user
|
2018-07-03 18:31:02 +00:00
|
|
|
TemplateEnvSelect struct {
|
|
|
|
Text string `json:"text"`
|
|
|
|
Value string `json:"value"`
|
|
|
|
Default bool `json:"default"`
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// ResourceAccessLevel represents the level of control associated to a resource
|
2017-03-12 16:24:15 +00:00
|
|
|
ResourceAccessLevel int
|
|
|
|
|
2016-12-25 20:34:02 +00:00
|
|
|
// TLSFileType represents a type of TLS file required to connect to a Docker endpoint.
|
2018-08-21 18:40:42 +00:00
|
|
|
// It can be either a TLS CA file, a TLS certificate file or a TLS key file
|
2016-12-25 20:34:02 +00:00
|
|
|
TLSFileType int
|
|
|
|
|
2018-12-09 03:49:27 +00:00
|
|
|
// ExtensionID represents a extension identifier
|
|
|
|
ExtensionID int
|
|
|
|
|
|
|
|
// Extension represents a Portainer extension
|
|
|
|
Extension struct {
|
|
|
|
ID ExtensionID `json:"Id"`
|
|
|
|
Enabled bool `json:"Enabled"`
|
|
|
|
Name string `json:"Name,omitempty"`
|
|
|
|
ShortDescription string `json:"ShortDescription,omitempty"`
|
|
|
|
Description string `json:"Description,omitempty"`
|
2018-12-11 21:28:21 +00:00
|
|
|
DescriptionURL string `json:"DescriptionURL,omitempty"`
|
2018-12-09 03:49:27 +00:00
|
|
|
Price string `json:"Price,omitempty"`
|
|
|
|
PriceDescription string `json:"PriceDescription,omitempty"`
|
|
|
|
Deal bool `json:"Deal,omitempty"`
|
|
|
|
Available bool `json:"Available,omitempty"`
|
|
|
|
License LicenseInformation `json:"License,omitempty"`
|
|
|
|
Version string `json:"Version"`
|
|
|
|
UpdateAvailable bool `json:"UpdateAvailable"`
|
2018-12-11 21:28:21 +00:00
|
|
|
ShopURL string `json:"ShopURL,omitempty"`
|
2018-12-09 03:49:27 +00:00
|
|
|
Images []string `json:"Images,omitempty"`
|
|
|
|
Logo string `json:"Logo,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// LicenseInformation represents information about an extension license
|
|
|
|
LicenseInformation struct {
|
|
|
|
LicenseKey string `json:"LicenseKey,omitempty"`
|
|
|
|
Company string `json:"Company,omitempty"`
|
|
|
|
Expiration string `json:"Expiration,omitempty"`
|
2019-01-17 21:00:18 +00:00
|
|
|
Valid bool `json:"Valid,omitempty"`
|
2018-12-09 03:49:27 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// CLIService represents a service for managing CLI
|
2016-12-18 05:21:29 +00:00
|
|
|
CLIService interface {
|
|
|
|
ParseFlags(version string) (*CLIFlags, error)
|
|
|
|
ValidateFlags(flags *CLIFlags) error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// DataStore defines the interface to manage the data
|
2016-12-18 05:21:29 +00:00
|
|
|
DataStore interface {
|
|
|
|
Open() error
|
2018-04-26 16:08:46 +00:00
|
|
|
Init() error
|
2016-12-18 05:21:29 +00:00
|
|
|
Close() error
|
2017-03-12 16:24:15 +00:00
|
|
|
MigrateData() error
|
2016-12-18 05:21:29 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// Server defines the interface to serve the API
|
2016-12-18 05:21:29 +00:00
|
|
|
Server interface {
|
|
|
|
Start() error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// UserService represents a service for managing user data
|
2016-12-18 05:21:29 +00:00
|
|
|
UserService interface {
|
2017-03-12 16:24:15 +00:00
|
|
|
User(ID UserID) (*User, error)
|
|
|
|
UserByUsername(username string) (*User, error)
|
|
|
|
Users() ([]User, error)
|
|
|
|
UsersByRole(role UserRole) ([]User, error)
|
|
|
|
CreateUser(user *User) error
|
|
|
|
UpdateUser(ID UserID, user *User) error
|
|
|
|
DeleteUser(ID UserID) error
|
2016-12-18 05:21:29 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TeamService represents a service for managing user data
|
2017-05-23 18:56:10 +00:00
|
|
|
TeamService interface {
|
|
|
|
Team(ID TeamID) (*Team, error)
|
|
|
|
TeamByName(name string) (*Team, error)
|
|
|
|
Teams() ([]Team, error)
|
|
|
|
CreateTeam(team *Team) error
|
|
|
|
UpdateTeam(ID TeamID, team *Team) error
|
|
|
|
DeleteTeam(ID TeamID) error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TeamMembershipService represents a service for managing team membership data
|
2017-05-23 18:56:10 +00:00
|
|
|
TeamMembershipService interface {
|
|
|
|
TeamMembership(ID TeamMembershipID) (*TeamMembership, error)
|
|
|
|
TeamMemberships() ([]TeamMembership, error)
|
|
|
|
TeamMembershipsByUserID(userID UserID) ([]TeamMembership, error)
|
|
|
|
TeamMembershipsByTeamID(teamID TeamID) ([]TeamMembership, error)
|
|
|
|
CreateTeamMembership(membership *TeamMembership) error
|
|
|
|
UpdateTeamMembership(ID TeamMembershipID, membership *TeamMembership) error
|
|
|
|
DeleteTeamMembership(ID TeamMembershipID) error
|
|
|
|
DeleteTeamMembershipByUserID(userID UserID) error
|
|
|
|
DeleteTeamMembershipByTeamID(teamID TeamID) error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// EndpointService represents a service for managing endpoint data
|
2016-12-25 20:34:02 +00:00
|
|
|
EndpointService interface {
|
|
|
|
Endpoint(ID EndpointID) (*Endpoint, error)
|
|
|
|
Endpoints() ([]Endpoint, error)
|
|
|
|
CreateEndpoint(endpoint *Endpoint) error
|
|
|
|
UpdateEndpoint(ID EndpointID, endpoint *Endpoint) error
|
|
|
|
DeleteEndpoint(ID EndpointID) error
|
2017-02-06 05:29:34 +00:00
|
|
|
Synchronize(toCreate, toUpdate, toDelete []*Endpoint) error
|
2018-07-24 12:47:19 +00:00
|
|
|
GetNextIdentifier() int
|
2016-12-25 20:34:02 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// EndpointGroupService represents a service for managing endpoint group data
|
2018-04-26 16:08:46 +00:00
|
|
|
EndpointGroupService interface {
|
|
|
|
EndpointGroup(ID EndpointGroupID) (*EndpointGroup, error)
|
|
|
|
EndpointGroups() ([]EndpointGroup, error)
|
|
|
|
CreateEndpointGroup(group *EndpointGroup) error
|
|
|
|
UpdateEndpointGroup(ID EndpointGroupID, group *EndpointGroup) error
|
|
|
|
DeleteEndpointGroup(ID EndpointGroupID) error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// RegistryService represents a service for managing registry data
|
2017-06-20 11:00:32 +00:00
|
|
|
RegistryService interface {
|
|
|
|
Registry(ID RegistryID) (*Registry, error)
|
|
|
|
Registries() ([]Registry, error)
|
|
|
|
CreateRegistry(registry *Registry) error
|
|
|
|
UpdateRegistry(ID RegistryID, registry *Registry) error
|
|
|
|
DeleteRegistry(ID RegistryID) error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// StackService represents a service for managing stack data
|
2017-10-15 17:24:40 +00:00
|
|
|
StackService interface {
|
|
|
|
Stack(ID StackID) (*Stack, error)
|
2018-06-11 13:13:19 +00:00
|
|
|
StackByName(name string) (*Stack, error)
|
2017-10-15 17:24:40 +00:00
|
|
|
Stacks() ([]Stack, error)
|
|
|
|
CreateStack(stack *Stack) error
|
|
|
|
UpdateStack(ID StackID, stack *Stack) error
|
|
|
|
DeleteStack(ID StackID) error
|
2018-06-18 10:07:56 +00:00
|
|
|
GetNextIdentifier() int
|
2017-10-15 17:24:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// DockerHubService represents a service for managing the DockerHub object
|
2017-06-20 11:00:32 +00:00
|
|
|
DockerHubService interface {
|
|
|
|
DockerHub() (*DockerHub, error)
|
2018-06-19 11:15:10 +00:00
|
|
|
UpdateDockerHub(registry *DockerHub) error
|
2017-06-20 11:00:32 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// SettingsService represents a service for managing application settings
|
2017-06-01 08:14:55 +00:00
|
|
|
SettingsService interface {
|
|
|
|
Settings() (*Settings, error)
|
2018-06-19 11:15:10 +00:00
|
|
|
UpdateSettings(settings *Settings) error
|
2017-06-01 08:14:55 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// VersionService represents a service for managing version data
|
2017-03-12 16:24:15 +00:00
|
|
|
VersionService interface {
|
|
|
|
DBVersion() (int, error)
|
|
|
|
StoreDBVersion(version int) error
|
|
|
|
}
|
|
|
|
|
2018-09-03 10:08:03 +00:00
|
|
|
// WebhookService represents a service for managing webhook data.
|
|
|
|
WebhookService interface {
|
|
|
|
Webhooks() ([]Webhook, error)
|
|
|
|
Webhook(ID WebhookID) (*Webhook, error)
|
|
|
|
CreateWebhook(portainer *Webhook) error
|
|
|
|
WebhookByResourceID(resourceID string) (*Webhook, error)
|
|
|
|
WebhookByToken(token string) (*Webhook, error)
|
|
|
|
DeleteWebhook(serviceID WebhookID) error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// ResourceControlService represents a service for managing resource control data
|
2017-03-12 16:24:15 +00:00
|
|
|
ResourceControlService interface {
|
2017-05-23 18:56:10 +00:00
|
|
|
ResourceControl(ID ResourceControlID) (*ResourceControl, error)
|
|
|
|
ResourceControlByResourceID(resourceID string) (*ResourceControl, error)
|
|
|
|
ResourceControls() ([]ResourceControl, error)
|
|
|
|
CreateResourceControl(rc *ResourceControl) error
|
|
|
|
UpdateResourceControl(ID ResourceControlID, resourceControl *ResourceControl) error
|
|
|
|
DeleteResourceControl(ID ResourceControlID) error
|
2017-03-12 16:24:15 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 20:58:15 +00:00
|
|
|
// ScheduleService represents a service for managing schedule data
|
|
|
|
ScheduleService interface {
|
|
|
|
Schedule(ID ScheduleID) (*Schedule, error)
|
|
|
|
Schedules() ([]Schedule, error)
|
2018-11-06 09:49:48 +00:00
|
|
|
SchedulesByJobType(jobType JobType) ([]Schedule, error)
|
2018-11-05 20:58:15 +00:00
|
|
|
CreateSchedule(schedule *Schedule) error
|
|
|
|
UpdateSchedule(ID ScheduleID, schedule *Schedule) error
|
|
|
|
DeleteSchedule(ID ScheduleID) error
|
|
|
|
GetNextIdentifier() int
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TagService represents a service for managing tag data
|
2018-06-15 07:18:25 +00:00
|
|
|
TagService interface {
|
|
|
|
Tags() ([]Tag, error)
|
|
|
|
CreateTag(tag *Tag) error
|
|
|
|
DeleteTag(ID TagID) error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// TemplateService represents a service for managing template data
|
2018-07-03 18:31:02 +00:00
|
|
|
TemplateService interface {
|
|
|
|
Templates() ([]Template, error)
|
|
|
|
Template(ID TemplateID) (*Template, error)
|
|
|
|
CreateTemplate(template *Template) error
|
|
|
|
UpdateTemplate(ID TemplateID, template *Template) error
|
|
|
|
DeleteTemplate(ID TemplateID) error
|
|
|
|
}
|
|
|
|
|
2018-12-09 03:49:27 +00:00
|
|
|
// ExtensionService represents a service for managing extension data
|
|
|
|
ExtensionService interface {
|
|
|
|
Extension(ID ExtensionID) (*Extension, error)
|
|
|
|
Extensions() ([]Extension, error)
|
|
|
|
Persist(extension *Extension) error
|
|
|
|
DeleteExtension(ID ExtensionID) error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// CryptoService represents a service for encrypting/hashing data
|
2016-12-18 05:21:29 +00:00
|
|
|
CryptoService interface {
|
|
|
|
Hash(data string) (string, error)
|
|
|
|
CompareHashAndData(hash string, data string) error
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// DigitalSignatureService represents a service to manage digital signatures
|
2018-05-06 07:15:57 +00:00
|
|
|
DigitalSignatureService interface {
|
|
|
|
ParseKeyPair(private, public []byte) error
|
|
|
|
GenerateKeyPair() ([]byte, []byte, error)
|
|
|
|
EncodedPublicKey() string
|
|
|
|
PEMHeaders() (string, string)
|
2018-12-11 22:19:23 +00:00
|
|
|
CreateSignature(message string) (string, error)
|
2018-05-06 07:15:57 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// JWTService represents a service for managing JWT tokens
|
2016-12-18 05:21:29 +00:00
|
|
|
JWTService interface {
|
|
|
|
GenerateToken(data *TokenData) (string, error)
|
2017-03-12 16:24:15 +00:00
|
|
|
ParseAndVerifyToken(token string) (*TokenData, error)
|
2016-12-18 05:21:29 +00:00
|
|
|
}
|
2016-12-25 20:34:02 +00:00
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// FileService represents a service for managing files
|
2016-12-25 20:34:02 +00:00
|
|
|
FileService interface {
|
2018-07-03 18:31:02 +00:00
|
|
|
GetFileContent(filePath string) ([]byte, error)
|
2018-06-18 10:07:56 +00:00
|
|
|
Rename(oldPath, newPath string) error
|
2017-10-15 17:24:40 +00:00
|
|
|
RemoveDirectory(directoryPath string) error
|
2018-06-11 13:13:19 +00:00
|
|
|
StoreTLSFileFromBytes(folder string, fileType TLSFileType, data []byte) (string, error)
|
2017-08-10 08:35:23 +00:00
|
|
|
GetPathForTLSFile(folder string, fileType TLSFileType) (string, error)
|
2017-09-14 06:08:37 +00:00
|
|
|
DeleteTLSFile(folder string, fileType TLSFileType) error
|
2017-08-10 08:35:23 +00:00
|
|
|
DeleteTLSFiles(folder string) error
|
2017-10-15 17:24:40 +00:00
|
|
|
GetStackProjectPath(stackIdentifier string) string
|
2018-06-11 13:13:19 +00:00
|
|
|
StoreStackFileFromBytes(stackIdentifier, fileName string, data []byte) (string, error)
|
2018-12-09 03:49:27 +00:00
|
|
|
StoreRegistryManagementFileFromBytes(folder, fileName string, data []byte) (string, error)
|
2018-05-06 07:15:57 +00:00
|
|
|
KeyPairFilesExist() (bool, error)
|
|
|
|
StoreKeyPair(private, public []byte, privatePEMHeader, publicPEMHeader string) error
|
|
|
|
LoadKeyPair() ([]byte, []byte, error)
|
|
|
|
WriteJSONToFile(path string, content interface{}) error
|
2018-06-19 11:15:10 +00:00
|
|
|
FileExists(path string) (bool, error)
|
2018-11-07 04:19:10 +00:00
|
|
|
StoreScheduledJobFileFromBytes(identifier string, data []byte) (string, error)
|
|
|
|
GetScheduleFolder(identifier string) string
|
2018-12-09 03:49:27 +00:00
|
|
|
ExtractExtensionArchive(data []byte) error
|
|
|
|
GetBinaryFolder() string
|
2017-10-15 17:24:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// GitService represents a service for managing Git
|
2017-10-15 17:24:40 +00:00
|
|
|
GitService interface {
|
2018-07-24 14:11:35 +00:00
|
|
|
ClonePublicRepository(repositoryURL, referenceName string, destination string) error
|
|
|
|
ClonePrivateRepositoryWithBasicAuth(repositoryURL, referenceName string, destination, username, password string) error
|
2016-12-25 20:34:02 +00:00
|
|
|
}
|
2017-02-06 05:29:34 +00:00
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// JobScheduler represents a service to run jobs on a periodic basis
|
2018-07-11 08:39:20 +00:00
|
|
|
JobScheduler interface {
|
2018-11-13 01:39:26 +00:00
|
|
|
ScheduleJob(runner JobRunner) error
|
|
|
|
UpdateJobSchedule(runner JobRunner) error
|
|
|
|
UpdateSystemJobSchedule(jobType JobType, newCronExpression string) error
|
|
|
|
UnscheduleJob(ID ScheduleID)
|
2018-07-11 08:39:20 +00:00
|
|
|
Start()
|
|
|
|
}
|
|
|
|
|
2018-11-06 09:49:48 +00:00
|
|
|
// JobRunner represents a service that can be used to run a job
|
|
|
|
JobRunner interface {
|
2018-11-05 20:58:15 +00:00
|
|
|
Run()
|
2018-11-13 01:39:26 +00:00
|
|
|
GetSchedule() *Schedule
|
2018-11-05 20:58:15 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// Snapshotter represents a service used to create endpoint snapshots
|
2018-07-11 08:39:20 +00:00
|
|
|
Snapshotter interface {
|
|
|
|
CreateSnapshot(endpoint *Endpoint) (*Snapshot, error)
|
2017-02-06 05:29:34 +00:00
|
|
|
}
|
2017-08-10 08:35:23 +00:00
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// LDAPService represents a service used to authenticate users against a LDAP/AD
|
2017-08-10 08:35:23 +00:00
|
|
|
LDAPService interface {
|
|
|
|
AuthenticateUser(username, password string, settings *LDAPSettings) error
|
|
|
|
TestConnectivity(settings *LDAPSettings) error
|
2018-07-23 04:57:38 +00:00
|
|
|
GetUserGroups(username string, settings *LDAPSettings) ([]string, error)
|
2017-08-10 08:35:23 +00:00
|
|
|
}
|
2017-10-15 17:24:40 +00:00
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// SwarmStackManager represents a service to manage Swarm stacks
|
2018-06-11 13:13:19 +00:00
|
|
|
SwarmStackManager interface {
|
2018-02-07 07:37:01 +00:00
|
|
|
Login(dockerhub *DockerHub, registries []Registry, endpoint *Endpoint)
|
2017-10-26 12:22:09 +00:00
|
|
|
Logout(endpoint *Endpoint) error
|
2018-01-20 17:05:01 +00:00
|
|
|
Deploy(stack *Stack, prune bool, endpoint *Endpoint) error
|
2017-10-15 17:24:40 +00:00
|
|
|
Remove(stack *Stack, endpoint *Endpoint) error
|
|
|
|
}
|
2018-06-11 13:13:19 +00:00
|
|
|
|
2018-08-21 18:40:42 +00:00
|
|
|
// ComposeStackManager represents a service to manage Compose stacks
|
2018-06-11 13:13:19 +00:00
|
|
|
ComposeStackManager interface {
|
|
|
|
Up(stack *Stack, endpoint *Endpoint) error
|
|
|
|
Down(stack *Stack, endpoint *Endpoint) error
|
|
|
|
}
|
2018-10-22 21:03:30 +00:00
|
|
|
|
2018-10-22 21:07:39 +00:00
|
|
|
// JobService represents a service to manage job execution on hosts
|
2018-10-22 21:03:30 +00:00
|
|
|
JobService interface {
|
2018-11-13 01:39:26 +00:00
|
|
|
ExecuteScript(endpoint *Endpoint, nodeName, image string, script []byte, schedule *Schedule) error
|
2018-10-22 21:03:30 +00:00
|
|
|
}
|
2018-12-09 03:49:27 +00:00
|
|
|
|
|
|
|
// ExtensionManager represents a service used to manage extensions
|
|
|
|
ExtensionManager interface {
|
|
|
|
FetchExtensionDefinitions() ([]Extension, error)
|
|
|
|
EnableExtension(extension *Extension, licenseKey string) error
|
|
|
|
DisableExtension(extension *Extension) error
|
|
|
|
UpdateExtension(extension *Extension, version string) error
|
|
|
|
}
|
2016-12-18 05:21:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2018-08-21 18:40:42 +00:00
|
|
|
// APIVersion is the version number of the Portainer API
|
2019-01-31 00:15:18 +00:00
|
|
|
APIVersion = "1.20.1"
|
2018-08-21 18:40:42 +00:00
|
|
|
// DBVersion is the version number of the Portainer database
|
2019-01-17 21:00:18 +00:00
|
|
|
DBVersion = 17
|
2018-12-11 20:46:05 +00:00
|
|
|
// AssetsServerURL represents the URL of the Portainer asset server
|
|
|
|
AssetsServerURL = "https://portainer-io-assets.sfo2.digitaloceanspaces.com"
|
2018-08-21 18:40:42 +00:00
|
|
|
// MessageOfTheDayURL represents the URL where Portainer MOTD message can be retrieved
|
2018-12-11 20:46:05 +00:00
|
|
|
MessageOfTheDayURL = AssetsServerURL + "/motd.html"
|
2018-12-09 03:49:27 +00:00
|
|
|
// ExtensionDefinitionsURL represents the URL where Portainer extension definitions can be retrieved
|
2019-02-18 01:46:34 +00:00
|
|
|
// TODO: UPDATE URL to production URL
|
|
|
|
ExtensionDefinitionsURL = AssetsServerURL + "/extensions-dev.json"
|
2018-05-06 07:15:57 +00:00
|
|
|
// PortainerAgentHeader represents the name of the header available in any agent response
|
|
|
|
PortainerAgentHeader = "Portainer-Agent"
|
2018-08-21 18:40:42 +00:00
|
|
|
// PortainerAgentTargetHeader represent the name of the header containing the target node name
|
2018-05-06 07:15:57 +00:00
|
|
|
PortainerAgentTargetHeader = "X-PortainerAgent-Target"
|
|
|
|
// PortainerAgentSignatureHeader represent the name of the header containing the digital signature
|
|
|
|
PortainerAgentSignatureHeader = "X-PortainerAgent-Signature"
|
|
|
|
// PortainerAgentPublicKeyHeader represent the name of the header containing the public key
|
|
|
|
PortainerAgentPublicKeyHeader = "X-PortainerAgent-PublicKey"
|
|
|
|
// PortainerAgentSignatureMessage represents the message used to create a digital signature
|
|
|
|
// to be used when communicating with an agent
|
|
|
|
PortainerAgentSignatureMessage = "Portainer-App"
|
2018-08-21 18:40:42 +00:00
|
|
|
// SupportedDockerAPIVersion is the minimum Docker API version supported by Portainer
|
2018-07-11 08:39:20 +00:00
|
|
|
SupportedDockerAPIVersion = "1.24"
|
2016-12-18 05:21:29 +00:00
|
|
|
)
|
2016-12-25 20:34:02 +00:00
|
|
|
|
|
|
|
const (
|
2018-08-21 18:40:42 +00:00
|
|
|
// TLSFileCA represents a TLS CA certificate file
|
2016-12-25 20:34:02 +00:00
|
|
|
TLSFileCA TLSFileType = iota
|
2018-08-21 18:40:42 +00:00
|
|
|
// TLSFileCert represents a TLS certificate file
|
2016-12-25 20:34:02 +00:00
|
|
|
TLSFileCert
|
2018-08-21 18:40:42 +00:00
|
|
|
// TLSFileKey represents a TLS key file
|
2016-12-25 20:34:02 +00:00
|
|
|
TLSFileKey
|
|
|
|
)
|
2017-03-12 16:24:15 +00:00
|
|
|
|
2017-05-23 18:56:10 +00:00
|
|
|
const (
|
|
|
|
_ MembershipRole = iota
|
|
|
|
// TeamLeader represents a leader role inside a team
|
|
|
|
TeamLeader
|
|
|
|
// TeamMember represents a member role inside a team
|
|
|
|
TeamMember
|
|
|
|
)
|
|
|
|
|
2017-03-12 16:24:15 +00:00
|
|
|
const (
|
|
|
|
_ UserRole = iota
|
|
|
|
// AdministratorRole represents an administrator user role
|
|
|
|
AdministratorRole
|
|
|
|
// StandardUserRole represents a regular user role
|
|
|
|
StandardUserRole
|
|
|
|
)
|
|
|
|
|
2017-08-10 08:35:23 +00:00
|
|
|
const (
|
|
|
|
_ AuthenticationMethod = iota
|
|
|
|
// AuthenticationInternal represents the internal authentication method (authentication against Portainer API)
|
|
|
|
AuthenticationInternal
|
|
|
|
// AuthenticationLDAP represents the LDAP authentication method (authentication against a LDAP server)
|
|
|
|
AuthenticationLDAP
|
2018-12-30 16:02:22 +00:00
|
|
|
//AuthenticationOAuth represents the OAuth authentication method (authentication against a authorization server)
|
|
|
|
AuthenticationOAuth
|
2017-08-10 08:35:23 +00:00
|
|
|
)
|
|
|
|
|
2017-05-23 18:56:10 +00:00
|
|
|
const (
|
|
|
|
_ ResourceAccessLevel = iota
|
|
|
|
// ReadWriteAccessLevel represents an access level with read-write permissions on a resource
|
|
|
|
ReadWriteAccessLevel
|
|
|
|
)
|
|
|
|
|
2017-03-12 16:24:15 +00:00
|
|
|
const (
|
|
|
|
_ ResourceControlType = iota
|
2017-05-23 18:56:10 +00:00
|
|
|
// ContainerResourceControl represents a resource control associated to a Docker container
|
2017-03-12 16:24:15 +00:00
|
|
|
ContainerResourceControl
|
2017-05-23 18:56:10 +00:00
|
|
|
// ServiceResourceControl represents a resource control associated to a Docker service
|
2017-03-12 16:24:15 +00:00
|
|
|
ServiceResourceControl
|
2017-05-23 18:56:10 +00:00
|
|
|
// VolumeResourceControl represents a resource control associated to a Docker volume
|
2017-03-12 16:24:15 +00:00
|
|
|
VolumeResourceControl
|
2017-09-19 14:58:30 +00:00
|
|
|
// NetworkResourceControl represents a resource control associated to a Docker network
|
|
|
|
NetworkResourceControl
|
2017-09-19 15:10:15 +00:00
|
|
|
// SecretResourceControl represents a resource control associated to a Docker secret
|
|
|
|
SecretResourceControl
|
2017-10-15 17:24:40 +00:00
|
|
|
// StackResourceControl represents a resource control associated to a stack composed of Docker services
|
|
|
|
StackResourceControl
|
2017-11-06 08:47:31 +00:00
|
|
|
// ConfigResourceControl represents a resource control associated to a Docker config
|
|
|
|
ConfigResourceControl
|
2017-03-12 16:24:15 +00:00
|
|
|
)
|
2018-02-23 02:10:26 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
_ EndpointExtensionType = iota
|
|
|
|
// StoridgeEndpointExtension represents the Storidge extension
|
|
|
|
StoridgeEndpointExtension
|
|
|
|
)
|
2018-05-06 07:15:57 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
_ EndpointType = iota
|
|
|
|
// DockerEnvironment represents an endpoint connected to a Docker environment
|
|
|
|
DockerEnvironment
|
|
|
|
// AgentOnDockerEnvironment represents an endpoint connected to a Portainer agent deployed on a Docker environment
|
|
|
|
AgentOnDockerEnvironment
|
2018-05-28 14:40:33 +00:00
|
|
|
// AzureEnvironment represents an endpoint connected to an Azure environment
|
|
|
|
AzureEnvironment
|
2018-05-06 07:15:57 +00:00
|
|
|
)
|
2018-06-11 13:13:19 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
_ StackType = iota
|
|
|
|
// DockerSwarmStack represents a stack managed via docker stack
|
|
|
|
DockerSwarmStack
|
|
|
|
// DockerComposeStack represents a stack managed via docker-compose
|
|
|
|
DockerComposeStack
|
|
|
|
)
|
2018-07-03 18:31:02 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
_ TemplateType = iota
|
|
|
|
// ContainerTemplate represents a container template
|
|
|
|
ContainerTemplate
|
|
|
|
// SwarmStackTemplate represents a template used to deploy a Swarm stack
|
|
|
|
SwarmStackTemplate
|
|
|
|
// ComposeStackTemplate represents a template used to deploy a Compose stack
|
|
|
|
ComposeStackTemplate
|
|
|
|
)
|
2018-07-11 08:39:20 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
_ EndpointStatus = iota
|
|
|
|
// EndpointStatusUp is used to represent an available endpoint
|
|
|
|
EndpointStatusUp
|
|
|
|
// EndpointStatusDown is used to represent an unavailable endpoint
|
|
|
|
EndpointStatusDown
|
|
|
|
)
|
2018-09-03 10:08:03 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
_ WebhookType = iota
|
|
|
|
// ServiceWebhook is a webhook for restarting a docker service
|
|
|
|
ServiceWebhook
|
|
|
|
)
|
2018-11-06 09:49:48 +00:00
|
|
|
|
2018-12-09 03:49:27 +00:00
|
|
|
const (
|
|
|
|
_ ExtensionID = iota
|
|
|
|
// RegistryManagementExtension represents the registry management extension
|
|
|
|
RegistryManagementExtension
|
2019-02-18 01:46:34 +00:00
|
|
|
// OAuthAuthenticationExtension represents the OAuth authentication extension
|
|
|
|
OAuthAuthenticationExtension
|
2018-12-09 03:49:27 +00:00
|
|
|
)
|
|
|
|
|
2018-11-06 09:49:48 +00:00
|
|
|
const (
|
|
|
|
_ JobType = iota
|
|
|
|
// ScriptExecutionJobType is a non-system job used to execute a script against a list of
|
|
|
|
// endpoints via privileged containers
|
|
|
|
ScriptExecutionJobType
|
|
|
|
// SnapshotJobType is a system job used to create endpoint snapshots
|
|
|
|
SnapshotJobType
|
|
|
|
// EndpointSyncJobType is a system job used to synchronize endpoints from
|
|
|
|
// an external definition store
|
|
|
|
EndpointSyncJobType
|
|
|
|
)
|
2018-12-09 03:49:27 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
_ RegistryType = iota
|
|
|
|
// QuayRegistry represents a Quay.io registry
|
|
|
|
QuayRegistry
|
|
|
|
// AzureRegistry represents an ACR registry
|
|
|
|
AzureRegistry
|
|
|
|
// CustomRegistry represents a custom registry
|
|
|
|
CustomRegistry
|
|
|
|
)
|