caprover-api 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.json +6 -0
- package/.vscode/settings.json +6 -0
- package/.yarnrc.yml +1 -0
- package/README.md +44 -0
- package/dist/api/ApiManager.d.ts +114 -0
- package/dist/api/ApiManager.js +486 -0
- package/dist/api/ErrorFactory.d.ts +26 -0
- package/dist/api/ErrorFactory.js +35 -0
- package/dist/api/HttpClient.d.ts +16 -0
- package/dist/api/HttpClient.js +130 -0
- package/dist/example.d.ts +1 -0
- package/dist/example.js +30 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +43 -0
- package/dist/models/AppDefinition.d.ts +105 -0
- package/dist/models/AppDefinition.js +2 -0
- package/dist/models/AppDefinitionsResponse.d.ts +7 -0
- package/dist/models/AppDefinitionsResponse.js +2 -0
- package/dist/models/AppDeleteResponse.d.ts +3 -0
- package/dist/models/AppDeleteResponse.js +2 -0
- package/dist/models/AutomatedCleanupConfigs.d.ts +12 -0
- package/dist/models/AutomatedCleanupConfigs.js +15 -0
- package/dist/models/BackupMeta.d.ts +19 -0
- package/dist/models/BackupMeta.js +2 -0
- package/dist/models/BuildLogsResponse.d.ts +8 -0
- package/dist/models/BuildLogsResponse.js +2 -0
- package/dist/models/CapRoverTheme.d.ts +10 -0
- package/dist/models/CapRoverTheme.js +2 -0
- package/dist/models/CaptainInfo.d.ts +6 -0
- package/dist/models/CaptainInfo.js +2 -0
- package/dist/models/ContainerProps.d.ts +3 -0
- package/dist/models/ContainerProps.js +2 -0
- package/dist/models/DockerAuthObj.d.ts +11 -0
- package/dist/models/DockerAuthObj.js +2 -0
- package/dist/models/DockerSecret.d.ts +4 -0
- package/dist/models/DockerSecret.js +2 -0
- package/dist/models/DockerService.d.ts +99 -0
- package/dist/models/DockerService.js +2 -0
- package/dist/models/GoAccessInfo.d.ts +7 -0
- package/dist/models/GoAccessInfo.js +2 -0
- package/dist/models/GoAccessReportResponse.d.ts +6 -0
- package/dist/models/GoAccessReportResponse.js +2 -0
- package/dist/models/IBuiltImage.d.ts +4 -0
- package/dist/models/IBuiltImage.js +2 -0
- package/dist/models/ICaptainDefinition.d.ts +7 -0
- package/dist/models/ICaptainDefinition.js +2 -0
- package/dist/models/IGoAccessInfo.d.ts +7 -0
- package/dist/models/IGoAccessInfo.js +2 -0
- package/dist/models/IHashMapGeneric.d.ts +3 -0
- package/dist/models/IHashMapGeneric.js +2 -0
- package/dist/models/IImageSource.d.ts +12 -0
- package/dist/models/IImageSource.js +2 -0
- package/dist/models/IOneClickAppModels.d.ts +45 -0
- package/dist/models/IOneClickAppModels.js +2 -0
- package/dist/models/IProFeatures.d.ts +32 -0
- package/dist/models/IProFeatures.js +14 -0
- package/dist/models/IRegistryInfo.d.ts +21 -0
- package/dist/models/IRegistryInfo.js +8 -0
- package/dist/models/IServerBlockDetails.d.ts +17 -0
- package/dist/models/IServerBlockDetails.js +2 -0
- package/dist/models/IVersionInfo.d.ts +6 -0
- package/dist/models/IVersionInfo.js +2 -0
- package/dist/models/LoadBalancerInfo.d.ts +9 -0
- package/dist/models/LoadBalancerInfo.js +2 -0
- package/dist/models/LogsResponse.d.ts +3 -0
- package/dist/models/LogsResponse.js +2 -0
- package/dist/models/NetDataInfo.d.ts +27 -0
- package/dist/models/NetDataInfo.js +2 -0
- package/dist/models/NginxConfig.d.ts +10 -0
- package/dist/models/NginxConfig.js +2 -0
- package/dist/models/OneClickAppDefinitionResponse.d.ts +3 -0
- package/dist/models/OneClickAppDefinitionResponse.js +2 -0
- package/dist/models/OneClickAppRepositories.d.ts +3 -0
- package/dist/models/OneClickAppRepositories.js +2 -0
- package/dist/models/OneClickAppResponse.d.ts +4 -0
- package/dist/models/OneClickAppResponse.js +2 -0
- package/dist/models/OtherTypes.d.ts +29 -0
- package/dist/models/OtherTypes.js +2 -0
- package/dist/models/ProjectDefinition.d.ts +6 -0
- package/dist/models/ProjectDefinition.js +2 -0
- package/dist/models/ProjectsResponse.d.ts +4 -0
- package/dist/models/ProjectsResponse.js +2 -0
- package/dist/models/RegistriesResponse.d.ts +5 -0
- package/dist/models/RegistriesResponse.js +2 -0
- package/dist/models/ServerDockerInfo.d.ts +14 -0
- package/dist/models/ServerDockerInfo.js +2 -0
- package/dist/models/UnusedImagesResponse.d.ts +6 -0
- package/dist/models/UnusedImagesResponse.js +2 -0
- package/dist/models/index.d.ts +40 -0
- package/dist/models/index.js +56 -0
- package/package.json +30 -0
- package/src/api/ApiManager.ts +825 -0
- package/src/api/ErrorFactory.ts +35 -0
- package/src/api/HttpClient.ts +143 -0
- package/src/example.ts +36 -0
- package/src/index.ts +5 -0
- package/src/models/AppDefinition.ts +124 -0
- package/src/models/AppDefinitionsResponse.ts +8 -0
- package/src/models/AppDeleteResponse.ts +3 -0
- package/src/models/AutomatedCleanupConfigs.ts +18 -0
- package/src/models/BackupMeta.ts +26 -0
- package/src/models/BuildLogsResponse.ts +5 -0
- package/src/models/CapRoverTheme.ts +11 -0
- package/src/models/CaptainInfo.ts +6 -0
- package/src/models/ContainerProps.ts +3 -0
- package/src/models/DockerAuthObj.ts +25 -0
- package/src/models/DockerSecret.ts +4 -0
- package/src/models/DockerService.ts +117 -0
- package/src/models/GoAccessInfo.ts +7 -0
- package/src/models/GoAccessReportResponse.ts +6 -0
- package/src/models/IBuiltImage.ts +4 -0
- package/src/models/ICaptainDefinition.ts +7 -0
- package/src/models/IGoAccessInfo.ts +7 -0
- package/src/models/IHashMapGeneric.ts +3 -0
- package/src/models/IImageSource.ts +10 -0
- package/src/models/IOneClickAppModels.ts +51 -0
- package/src/models/IProFeatures.ts +39 -0
- package/src/models/IRegistryInfo.ts +30 -0
- package/src/models/IServerBlockDetails.ts +18 -0
- package/src/models/IVersionInfo.ts +6 -0
- package/src/models/LoadBalancerInfo.ts +11 -0
- package/src/models/LogsResponse.ts +3 -0
- package/src/models/NetDataInfo.ts +27 -0
- package/src/models/NginxConfig.ts +10 -0
- package/src/models/OneClickAppDefinitionResponse.ts +3 -0
- package/src/models/OneClickAppRepositories.ts +3 -0
- package/src/models/OneClickAppResponse.ts +5 -0
- package/src/models/OtherTypes.ts +32 -0
- package/src/models/ProjectDefinition.ts +6 -0
- package/src/models/ProjectsResponse.ts +5 -0
- package/src/models/RegistriesResponse.ts +6 -0
- package/src/models/ServerDockerInfo.ts +14 -0
- package/src/models/UnusedImagesResponse.ts +3 -0
- package/src/models/index.ts +41 -0
- package/tsconfig.json +14 -0
- package/tslint.json +46 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class ErrorFactory {
|
|
2
|
+
public readonly OKAY = 100
|
|
3
|
+
public readonly OKAY_BUILD_STARTED = 101
|
|
4
|
+
public readonly OK_PARTIALLY = 102
|
|
5
|
+
|
|
6
|
+
public readonly STATUS_ERROR_GENERIC = 1000
|
|
7
|
+
public readonly STATUS_ERROR_CAPTAIN_NOT_INITIALIZED = 1001
|
|
8
|
+
public readonly STATUS_ERROR_USER_NOT_INITIALIZED = 1101
|
|
9
|
+
public readonly STATUS_ERROR_NOT_AUTHORIZED = 1102
|
|
10
|
+
public readonly STATUS_ERROR_ALREADY_EXIST = 1103
|
|
11
|
+
public readonly STATUS_ERROR_BAD_NAME = 1104
|
|
12
|
+
public readonly STATUS_WRONG_PASSWORD = 1105
|
|
13
|
+
public readonly STATUS_AUTH_TOKEN_INVALID = 1106
|
|
14
|
+
public readonly VERIFICATION_FAILED = 1107
|
|
15
|
+
public readonly ILLEGAL_OPERATION = 1108
|
|
16
|
+
public readonly BUILD_ERROR = 1109
|
|
17
|
+
public readonly ILLEGAL_PARAMETER = 1110
|
|
18
|
+
public readonly NOT_FOUND = 1111
|
|
19
|
+
public readonly AUTHENTICATION_FAILED = 1112
|
|
20
|
+
public readonly STATUS_PASSWORD_BACK_OFF = 1113
|
|
21
|
+
public readonly STATUS_ERROR_OTP_REQUIRED = 1114
|
|
22
|
+
static readonly STATUS_ERROR_PRO_API_KEY_INVALIDATED = 1115
|
|
23
|
+
public readonly UNKNOWN_ERROR = 1999
|
|
24
|
+
|
|
25
|
+
createError(status: number, message: string) {
|
|
26
|
+
let e = new Error(message || 'null') as any
|
|
27
|
+
e.captainStatus = status
|
|
28
|
+
e.captainMessage = message
|
|
29
|
+
return e
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const errorFactory = new ErrorFactory()
|
|
34
|
+
|
|
35
|
+
export default errorFactory
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import ErrorFactory from './ErrorFactory'
|
|
3
|
+
|
|
4
|
+
let TOKEN_HEADER = 'x-captain-auth'
|
|
5
|
+
let NAMESPACE = 'x-namespace'
|
|
6
|
+
let CAPTAIN = 'captain'
|
|
7
|
+
|
|
8
|
+
export default class HttpClient {
|
|
9
|
+
public readonly GET = 'GET'
|
|
10
|
+
public readonly POST = 'POST'
|
|
11
|
+
public isDestroyed = false
|
|
12
|
+
private authToken: string = ''
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
private baseUrl: string,
|
|
16
|
+
private onAuthFailure: () => Promise<string>
|
|
17
|
+
) {
|
|
18
|
+
//
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
createHeaders() {
|
|
22
|
+
let headers: any = {}
|
|
23
|
+
if (this.authToken) headers[TOKEN_HEADER] = this.authToken
|
|
24
|
+
headers[NAMESPACE] = CAPTAIN
|
|
25
|
+
|
|
26
|
+
// check user/appData or apiManager.uploadAppData before changing this signature.
|
|
27
|
+
return headers
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setAuthToken(authToken: string) {
|
|
31
|
+
this.authToken = authToken
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
destroy() {
|
|
35
|
+
this.isDestroyed = true
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fetch(method: 'GET' | 'POST', endpoint: string, variables: any) {
|
|
39
|
+
const self = this
|
|
40
|
+
return function (): Promise<any> {
|
|
41
|
+
return Promise.resolve() //
|
|
42
|
+
.then(function () {
|
|
43
|
+
return self.fetchInternal(method, endpoint, variables) //
|
|
44
|
+
})
|
|
45
|
+
.then(function (axiosResponse) {
|
|
46
|
+
const data = axiosResponse.data // this is an axios thing!
|
|
47
|
+
|
|
48
|
+
if (
|
|
49
|
+
data.status === ErrorFactory.STATUS_AUTH_TOKEN_INVALID
|
|
50
|
+
) {
|
|
51
|
+
return self
|
|
52
|
+
.onAuthFailure() //
|
|
53
|
+
.then(function (authToken) {
|
|
54
|
+
self.setAuthToken(authToken)
|
|
55
|
+
return self
|
|
56
|
+
.fetchInternal(method, endpoint, variables)
|
|
57
|
+
.then(function (newAxiosResponse) {
|
|
58
|
+
return newAxiosResponse.data
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
.catch(function (error) {
|
|
62
|
+
// Upon wrong password or back-off error, we force logout the user
|
|
63
|
+
// to avoid getting stuck with wrong password loop
|
|
64
|
+
if (
|
|
65
|
+
error.captainStatus + '' ===
|
|
66
|
+
ErrorFactory.STATUS_PASSWORD_BACK_OFF +
|
|
67
|
+
'' ||
|
|
68
|
+
error.captainStatus + '' ===
|
|
69
|
+
ErrorFactory.STATUS_WRONG_PASSWORD + ''
|
|
70
|
+
) {
|
|
71
|
+
self.setAuthToken('')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return Promise.reject(error)
|
|
75
|
+
})
|
|
76
|
+
} else {
|
|
77
|
+
return data
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
.then(function (data) {
|
|
81
|
+
if (
|
|
82
|
+
data.status !== ErrorFactory.OKAY &&
|
|
83
|
+
data.status !== ErrorFactory.OK_PARTIALLY &&
|
|
84
|
+
data.status !== ErrorFactory.OKAY_BUILD_STARTED
|
|
85
|
+
) {
|
|
86
|
+
throw ErrorFactory.createError(
|
|
87
|
+
data.status || ErrorFactory.UNKNOWN_ERROR,
|
|
88
|
+
data.description || ''
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
return data
|
|
92
|
+
})
|
|
93
|
+
.then(function (data) {
|
|
94
|
+
// These two blocks are clearly memory leaks! But I don't have time to fix them now... I need to CANCEL the promise, but since I don't
|
|
95
|
+
// have CANCEL method on the native Promise, I return a promise that will never RETURN if the HttpClient is destroyed.
|
|
96
|
+
// Will fix them later... but it shouldn't be a big deal anyways as it's only a problem when user navigates away from a page before the
|
|
97
|
+
// network request returns back.
|
|
98
|
+
return new Promise(function (resolve, reject) {
|
|
99
|
+
// data.data here is the "data" field inside the API response! {status: 100, description: "Login succeeded", data: {…}}
|
|
100
|
+
if (!self.isDestroyed) return resolve(data.data)
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
.catch(function (error) {
|
|
104
|
+
return new Promise(function (resolve, reject) {
|
|
105
|
+
if (!self.isDestroyed) return reject(error)
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
fetchInternal(method: 'GET' | 'POST', endpoint: string, variables: any) {
|
|
112
|
+
if (method === this.GET) return this.getReq(endpoint, variables)
|
|
113
|
+
|
|
114
|
+
if (method === this.POST) return this.postReq(endpoint, variables)
|
|
115
|
+
|
|
116
|
+
throw new Error(`Unknown method: ${method}`)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
getReq(endpoint: string, variables: any) {
|
|
120
|
+
const self = this
|
|
121
|
+
return axios
|
|
122
|
+
.get(this.baseUrl + endpoint, {
|
|
123
|
+
params: variables,
|
|
124
|
+
headers: self.createHeaders(),
|
|
125
|
+
}) //
|
|
126
|
+
.then(function (data) {
|
|
127
|
+
// console.log(data);
|
|
128
|
+
return data
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
postReq(endpoint: string, variables: any) {
|
|
133
|
+
const self = this
|
|
134
|
+
return axios
|
|
135
|
+
.post(this.baseUrl + endpoint, variables, {
|
|
136
|
+
headers: self.createHeaders(),
|
|
137
|
+
}) //
|
|
138
|
+
.then(function (data) {
|
|
139
|
+
// console.log(data);
|
|
140
|
+
return data
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
}
|
package/src/example.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import CapRoverAPI, { CapRoverModels } from './index'
|
|
2
|
+
|
|
3
|
+
const caprover = new CapRoverAPI(
|
|
4
|
+
'https://captain.server.demo.caprover.com',
|
|
5
|
+
() => {
|
|
6
|
+
// get password and otp from user
|
|
7
|
+
return Promise.resolve({
|
|
8
|
+
password: 'captain42',
|
|
9
|
+
otpToken: undefined,
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
console.log('===============================================')
|
|
15
|
+
|
|
16
|
+
Promise.resolve()
|
|
17
|
+
.then(() => {
|
|
18
|
+
return caprover.getAllNodes()
|
|
19
|
+
})
|
|
20
|
+
.then((response) => {
|
|
21
|
+
console.log(
|
|
22
|
+
'=============================================== getAllNodes:'
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
console.log(response)
|
|
26
|
+
return caprover.getDockerRegistries()
|
|
27
|
+
})
|
|
28
|
+
.then((response) => {
|
|
29
|
+
console.log(
|
|
30
|
+
'=============================================== getDockerRegistries:'
|
|
31
|
+
)
|
|
32
|
+
console.log(response)
|
|
33
|
+
})
|
|
34
|
+
.catch((error) => {
|
|
35
|
+
console.log(error)
|
|
36
|
+
})
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { IHashMapGeneric } from './IHashMapGeneric'
|
|
2
|
+
|
|
3
|
+
export type IAllAppDefinitions = IHashMapGeneric<IAppDef>
|
|
4
|
+
|
|
5
|
+
export interface IAppEnvVar {
|
|
6
|
+
key: string
|
|
7
|
+
value: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const enum VolumesTypes {
|
|
11
|
+
BIND = 'bind',
|
|
12
|
+
VOLUME = 'volume',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IAppVolume {
|
|
16
|
+
containerPath: string
|
|
17
|
+
volumeName?: string
|
|
18
|
+
hostPath?: string
|
|
19
|
+
mode?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IAppPort {
|
|
23
|
+
containerPort: number
|
|
24
|
+
hostPort: number
|
|
25
|
+
protocol?: 'udp' | 'tcp'
|
|
26
|
+
|
|
27
|
+
publishMode?: 'ingress' | 'host'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface RepoInfo {
|
|
31
|
+
repo: string
|
|
32
|
+
branch: string
|
|
33
|
+
user: string
|
|
34
|
+
sshKey?: string
|
|
35
|
+
password: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface RepoInfoEncrypted {
|
|
39
|
+
repo: string
|
|
40
|
+
branch: string
|
|
41
|
+
user: string
|
|
42
|
+
sshKeyEncrypted?: string
|
|
43
|
+
passwordEncrypted: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface IAppVersion {
|
|
47
|
+
version: number
|
|
48
|
+
deployedImageName?: string // empty if the deploy is not completed
|
|
49
|
+
timeStamp: string
|
|
50
|
+
gitHash: string | undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface IAppCustomDomain {
|
|
54
|
+
publicDomain: string
|
|
55
|
+
hasSsl: boolean
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface IAppTag {
|
|
59
|
+
tagName: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface IAppDefinitionBase {
|
|
63
|
+
projectId?: string | undefined
|
|
64
|
+
description: string
|
|
65
|
+
deployedVersion: number
|
|
66
|
+
notExposeAsWebApp: boolean
|
|
67
|
+
hasPersistentData: boolean
|
|
68
|
+
hasDefaultSubDomainSsl: boolean
|
|
69
|
+
containerHttpPort?: number
|
|
70
|
+
captainDefinitionRelativeFilePath: string
|
|
71
|
+
forceSsl: boolean
|
|
72
|
+
websocketSupport: boolean
|
|
73
|
+
nodeId?: string
|
|
74
|
+
instanceCount: number
|
|
75
|
+
preDeployFunction?: string
|
|
76
|
+
serviceUpdateOverride?: string
|
|
77
|
+
customNginxConfig?: string
|
|
78
|
+
redirectDomain?: string
|
|
79
|
+
networks: string[]
|
|
80
|
+
customDomain: IAppCustomDomain[]
|
|
81
|
+
tags?: IAppTag[]
|
|
82
|
+
ports: IAppPort[]
|
|
83
|
+
volumes: IAppVolume[]
|
|
84
|
+
envVars: IAppEnvVar[]
|
|
85
|
+
versions: IAppVersion[]
|
|
86
|
+
appDeployTokenConfig?: AppDeployTokenConfig
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface IHttpAuth {
|
|
90
|
+
user: string
|
|
91
|
+
password?: string
|
|
92
|
+
passwordHashed?: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface AppDeployTokenConfig {
|
|
96
|
+
enabled: boolean
|
|
97
|
+
appDeployToken?: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface IAppDef extends IAppDefinitionBase {
|
|
101
|
+
appPushWebhook?: {
|
|
102
|
+
tokenVersion: string
|
|
103
|
+
repoInfo: RepoInfo
|
|
104
|
+
pushWebhookToken: string
|
|
105
|
+
}
|
|
106
|
+
httpAuth?: IHttpAuth
|
|
107
|
+
appName?: string
|
|
108
|
+
isAppBuilding?: boolean
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface IAppDefSaved extends IAppDefinitionBase {
|
|
112
|
+
appPushWebhook:
|
|
113
|
+
| {
|
|
114
|
+
tokenVersion: string
|
|
115
|
+
repoInfo: RepoInfoEncrypted
|
|
116
|
+
pushWebhookToken: string
|
|
117
|
+
}
|
|
118
|
+
| undefined
|
|
119
|
+
|
|
120
|
+
httpAuth?: {
|
|
121
|
+
user: string
|
|
122
|
+
passwordHashed: string
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface IAutomatedCleanupConfigs {
|
|
2
|
+
mostRecentLimit: number
|
|
3
|
+
cronSchedule: string
|
|
4
|
+
timezone: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export class AutomatedCleanupConfigsCleaner {
|
|
8
|
+
static sanitizeInput(instance: IAutomatedCleanupConfigs) {
|
|
9
|
+
return {
|
|
10
|
+
mostRecentLimit:
|
|
11
|
+
Number(instance.mostRecentLimit) > 0
|
|
12
|
+
? Number(instance.mostRecentLimit)
|
|
13
|
+
: 1,
|
|
14
|
+
cronSchedule: `${instance.cronSchedule || ''}`.trim(),
|
|
15
|
+
timezone: `${instance.timezone || ''}`.trim() || 'UTC',
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ServerDockerInfo } from './ServerDockerInfo'
|
|
2
|
+
|
|
3
|
+
export interface RestoringNode {
|
|
4
|
+
oldIp: string
|
|
5
|
+
newIp: string
|
|
6
|
+
user: string
|
|
7
|
+
privateKeyPath: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface OldNodesForReference {
|
|
11
|
+
appsLockOnThisNode: string[]
|
|
12
|
+
|
|
13
|
+
nodeData: ServerDockerInfo
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface RestoringInfo {
|
|
17
|
+
nodesMapping: RestoringNode[]
|
|
18
|
+
|
|
19
|
+
oldNodesForReference: OldNodesForReference[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface BackupMeta {
|
|
23
|
+
salt: string
|
|
24
|
+
|
|
25
|
+
nodes: ServerDockerInfo[]
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface DockerAuthObj {
|
|
2
|
+
serveraddress: string
|
|
3
|
+
username: string
|
|
4
|
+
password: string
|
|
5
|
+
// email: string // Email is optional in auth
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
{
|
|
10
|
+
"docker.example.com": {
|
|
11
|
+
"username": "janedoe",
|
|
12
|
+
"password": "hunter2"
|
|
13
|
+
},
|
|
14
|
+
"https://index.docker.io/v1/": {
|
|
15
|
+
"username": "mobydock",
|
|
16
|
+
"password": "conta1n3rize14"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
*/
|
|
20
|
+
export interface DockerRegistryConfig {
|
|
21
|
+
[serveraddress: string]: {
|
|
22
|
+
username: string
|
|
23
|
+
password: string
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export interface Version {
|
|
2
|
+
Index: number
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface Labels {
|
|
6
|
+
[id: string]: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Mount {
|
|
10
|
+
Type: string
|
|
11
|
+
Source: string
|
|
12
|
+
Target: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ContainerSpecType {
|
|
16
|
+
Image: string
|
|
17
|
+
Env: string[]
|
|
18
|
+
Mounts: Mount[]
|
|
19
|
+
Isolation: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Resources {
|
|
23
|
+
Limits: {
|
|
24
|
+
MemoryBytes: number
|
|
25
|
+
NanoCPUs: number
|
|
26
|
+
}
|
|
27
|
+
Reservations: {
|
|
28
|
+
MemoryBytes: number
|
|
29
|
+
NanoCPUs: number
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Placement {
|
|
34
|
+
Constraints: string[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface Options {
|
|
38
|
+
'max-size': string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface LogDriver {
|
|
42
|
+
Name: string
|
|
43
|
+
Options: Options
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface TaskTemplate {
|
|
47
|
+
ContainerSpec: ContainerSpecType
|
|
48
|
+
Resources: Resources
|
|
49
|
+
Placement: Placement
|
|
50
|
+
LogDriver: LogDriver
|
|
51
|
+
ForceUpdate: number
|
|
52
|
+
Runtime: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface Replicated {
|
|
56
|
+
Replicas: number
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface Mode {
|
|
60
|
+
Replicated: Replicated
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface Port {
|
|
64
|
+
Protocol: string
|
|
65
|
+
TargetPort: number
|
|
66
|
+
PublishedPort: number
|
|
67
|
+
PublishMode: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface EndpointSpec {
|
|
71
|
+
Mode: string
|
|
72
|
+
Ports: Port[]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface Spec {
|
|
76
|
+
Name: string
|
|
77
|
+
Labels: Labels
|
|
78
|
+
TaskTemplate: TaskTemplate
|
|
79
|
+
Mode: Mode
|
|
80
|
+
EndpointSpec: EndpointSpec
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface PreviousSpec {
|
|
84
|
+
Name: string
|
|
85
|
+
Labels: Labels
|
|
86
|
+
TaskTemplate: TaskTemplate
|
|
87
|
+
Mode: Mode
|
|
88
|
+
EndpointSpec: EndpointSpec
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface VirtualIP {
|
|
92
|
+
NetworkID: string
|
|
93
|
+
Addr: string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface Endpoint {
|
|
97
|
+
Spec: Spec
|
|
98
|
+
Ports: Port[]
|
|
99
|
+
VirtualIPs: VirtualIP[]
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface UpdateStatus {
|
|
103
|
+
State: string
|
|
104
|
+
StartedAt: string
|
|
105
|
+
Message: string
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default interface DockerService {
|
|
109
|
+
ID: string
|
|
110
|
+
Version: Version
|
|
111
|
+
CreatedAt: string
|
|
112
|
+
UpdatedAt: string
|
|
113
|
+
Spec: Spec
|
|
114
|
+
PreviousSpec: PreviousSpec
|
|
115
|
+
Endpoint: Endpoint
|
|
116
|
+
UpdateStatus: UpdateStatus
|
|
117
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RepoInfo } from './AppDefinition'
|
|
2
|
+
|
|
3
|
+
export interface IImageSource {
|
|
4
|
+
uploadedTarPathSource?: { uploadedTarPath: string; gitHash: string }
|
|
5
|
+
captainDefinitionContentSource?: {
|
|
6
|
+
captainDefinitionContent: string
|
|
7
|
+
gitHash: string
|
|
8
|
+
}
|
|
9
|
+
repoInfoSource?: RepoInfo
|
|
10
|
+
}
|