fix(switch to unified package for cloudly + api + cli): update
This commit is contained in:
parent
33aa48b0b1
commit
21961fa2d7
@ -16,21 +16,26 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "servezone/private",
|
"gitscope": "servezone/private",
|
||||||
"gitrepo": "cloudly",
|
"gitrepo": "cloudly",
|
||||||
"description": "A cloud manager utilizing Docker Swarmkit, designed for operations on Cloudron, and supports various cloud platforms like DigitalOcean, Hetzner Cloud, and Cloudflare.",
|
"description": "A cloud manager leveraging Docker Swarmkit for multi-cloud operations including DigitalOcean, Hetzner Cloud, and Cloudflare, with integration support and robust configuration management system.",
|
||||||
"npmPackagename": "@serve.zone/cloudly",
|
"npmPackagename": "@serve.zone/cloudly",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"cloud",
|
"cloud management",
|
||||||
"Docker Swarmkit",
|
"Docker Swarmkit",
|
||||||
|
"multi-cloud",
|
||||||
"DigitalOcean",
|
"DigitalOcean",
|
||||||
"Hetzner Cloud",
|
"Hetzner Cloud",
|
||||||
"Cloudflare",
|
"Cloudflare",
|
||||||
"container management",
|
"container orchestration",
|
||||||
"configuration management",
|
"TypeScript",
|
||||||
"LetsEncrypt SSL",
|
|
||||||
"cloud infrastructure automation",
|
|
||||||
"node.js",
|
"node.js",
|
||||||
"TypeScript"
|
"infrastructure automation",
|
||||||
|
"Cloudron",
|
||||||
|
"configuration management",
|
||||||
|
"SSL management",
|
||||||
|
"APIs",
|
||||||
|
"devOps",
|
||||||
|
"cloud integration"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
52
package.json
52
package.json
@ -2,31 +2,35 @@
|
|||||||
"name": "@serve.zone/cloudly",
|
"name": "@serve.zone/cloudly",
|
||||||
"version": "1.0.215",
|
"version": "1.0.215",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A cloud manager utilizing Docker Swarmkit, designed for operations on Cloudron, and supports various cloud platforms like DigitalOcean, Hetzner Cloud, and Cloudflare.",
|
"description": "A cloud manager leveraging Docker Swarmkit for multi-cloud operations including DigitalOcean, Hetzner Cloud, and Cloudflare, with integration support and robust configuration management system.",
|
||||||
"main": "dist_ts/index.js",
|
|
||||||
"typings": "dist_ts/index.d.ts",
|
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js",
|
||||||
|
"./apiclient": "./dist_apiclient/index.js",
|
||||||
|
"./cliclient": "./dist_cliclient/index.js",
|
||||||
|
"./web": "./dist_web/index.js"
|
||||||
|
},
|
||||||
"author": "Task Venture Capital GmbH",
|
"author": "Task Venture Capital GmbH",
|
||||||
"license": "UNLICENSED",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "tsbuild --web --allowimplicitany && tsbundle website --production",
|
"build": "tsbuild tsfolders --web --allowimplicitany && tsbundle website --production",
|
||||||
"start": "node cli.js",
|
"start": "node cli.js",
|
||||||
"startTs": "node cli.ts.js",
|
"startTs": "node cli.ts.js",
|
||||||
"watch": "tswatch website",
|
"watch": "tswatch website",
|
||||||
"localPublish": "gitzone commit"
|
"localPublish": "gitzone commit"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.65",
|
"@git.zone/tsbuild": "^2.1.80",
|
||||||
"@git.zone/tsbundle": "^2.0.15",
|
"@git.zone/tsbundle": "^2.0.15",
|
||||||
"@git.zone/tstest": "^1.0.90",
|
"@git.zone/tstest": "^1.0.90",
|
||||||
"@git.zone/tswatch": "^2.0.23",
|
"@git.zone/tswatch": "^2.0.23",
|
||||||
"@push.rocks/tapbundle": "^5.0.23",
|
"@push.rocks/tapbundle": "^5.0.23",
|
||||||
"@types/node": "^20.12.8"
|
"@types/node": "^20.12.12"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@api.global/typedrequest": "3.0.23",
|
"@api.global/typedrequest": "3.0.25",
|
||||||
"@api.global/typedserver": "^3.0.29",
|
"@api.global/typedserver": "^3.0.50",
|
||||||
"@api.global/typedsocket": "^3.0.1",
|
"@api.global/typedsocket": "^3.0.1",
|
||||||
"@apiclient.xyz/cloudflare": "^6.0.1",
|
"@apiclient.xyz/cloudflare": "^6.0.1",
|
||||||
"@apiclient.xyz/digitalocean": "^1.0.5",
|
"@apiclient.xyz/digitalocean": "^1.0.5",
|
||||||
@ -41,26 +45,27 @@
|
|||||||
"@push.rocks/projectinfo": "^5.0.1",
|
"@push.rocks/projectinfo": "^5.0.1",
|
||||||
"@push.rocks/qenv": "^6.0.5",
|
"@push.rocks/qenv": "^6.0.5",
|
||||||
"@push.rocks/smartacme": "^4.0.8",
|
"@push.rocks/smartacme": "^4.0.8",
|
||||||
"@push.rocks/smartbucket": "^2.0.4",
|
"@push.rocks/smartbucket": "^3.0.9",
|
||||||
"@push.rocks/smartcli": "^4.0.10",
|
"@push.rocks/smartcli": "^4.0.11",
|
||||||
"@push.rocks/smartdata": "^5.2.1",
|
"@push.rocks/smartdata": "^5.2.1",
|
||||||
"@push.rocks/smartdelay": "^3.0.5",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@push.rocks/smartexit": "^1.0.23",
|
"@push.rocks/smartexit": "^1.0.23",
|
||||||
"@push.rocks/smartfile": "^11.0.14",
|
"@push.rocks/smartfile": "^11.0.15",
|
||||||
"@push.rocks/smartguard": "^2.0.1",
|
"@push.rocks/smartguard": "^2.0.1",
|
||||||
"@push.rocks/smartjson": "^5.0.19",
|
"@push.rocks/smartjson": "^5.0.19",
|
||||||
"@push.rocks/smartjwt": "^2.0.4",
|
"@push.rocks/smartjwt": "^2.0.4",
|
||||||
"@push.rocks/smartlog": "^3.0.1",
|
"@push.rocks/smartlog": "^3.0.6",
|
||||||
"@push.rocks/smartlog-destination-clickhouse": "^1.0.11",
|
"@push.rocks/smartlog-destination-clickhouse": "^1.0.11",
|
||||||
"@push.rocks/smartpath": "^5.0.18",
|
"@push.rocks/smartpath": "^5.0.18",
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"@push.rocks/smartrequest": "^2.0.22",
|
"@push.rocks/smartrequest": "^2.0.22",
|
||||||
|
"@push.rocks/smartrx": "^3.0.7",
|
||||||
"@push.rocks/smartssh": "^2.0.1",
|
"@push.rocks/smartssh": "^2.0.1",
|
||||||
"@push.rocks/smartstring": "^4.0.15",
|
"@push.rocks/smartstring": "^4.0.15",
|
||||||
"@push.rocks/smartunique": "^3.0.9",
|
"@push.rocks/smartunique": "^3.0.9",
|
||||||
"@push.rocks/taskbuffer": "^3.0.2",
|
"@push.rocks/taskbuffer": "^3.0.2",
|
||||||
"@push.rocks/webjwt": "^1.0.9",
|
"@push.rocks/webjwt": "^1.0.9",
|
||||||
"@serve.zone/interfaces": "^1.0.51",
|
"@serve.zone/interfaces": "^1.0.56",
|
||||||
"@tsclass/tsclass": "^4.0.54"
|
"@tsclass/tsclass": "^4.0.54"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
@ -87,16 +92,21 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/servezone/private/cloudly#readme",
|
"homepage": "https://gitlab.com/servezone/private/cloudly#readme",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"cloud",
|
"cloud management",
|
||||||
"Docker Swarmkit",
|
"Docker Swarmkit",
|
||||||
|
"multi-cloud",
|
||||||
"DigitalOcean",
|
"DigitalOcean",
|
||||||
"Hetzner Cloud",
|
"Hetzner Cloud",
|
||||||
"Cloudflare",
|
"Cloudflare",
|
||||||
"container management",
|
"container orchestration",
|
||||||
"configuration management",
|
"TypeScript",
|
||||||
"LetsEncrypt SSL",
|
|
||||||
"cloud infrastructure automation",
|
|
||||||
"node.js",
|
"node.js",
|
||||||
"TypeScript"
|
"infrastructure automation",
|
||||||
|
"Cloudron",
|
||||||
|
"configuration management",
|
||||||
|
"SSL management",
|
||||||
|
"APIs",
|
||||||
|
"devOps",
|
||||||
|
"cloud integration"
|
||||||
]
|
]
|
||||||
}
|
}
|
10337
pnpm-lock.yaml
generated
10337
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
346
readme.md
346
readme.md
@ -1,5 +1,5 @@
|
|||||||
# @serve.zone/cloudly
|
# @serve.zone/cloudly
|
||||||
configure the cloud
|
A cloud manager utilizing Docker Swarmkit, designed for operations on Cloudron, and supports various cloud platforms like DigitalOcean, Hetzner Cloud, and Cloudflare.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
To install `@serve.zone/cloudly`, run the following command in your terminal:
|
To install `@serve.zone/cloudly`, run the following command in your terminal:
|
||||||
@ -45,44 +45,346 @@ const myCloudlyInstance = new Cloudly(myCloudlyConfig);
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Managing Docker Swarmkit Cluster
|
#### Managing Docker Swarmkit Cluster
|
||||||
Cloudly allows managing Docker Swarmkit clusters through an abstracted interface, simplifying operations such as deployment and scaling.
|
Cloudly allows managing Docker Swarmkit clusters through an abstracted interface, simplifying operations such as deployment and scaling. Below are examples to demonstrate these capabilities.
|
||||||
|
|
||||||
|
### Example: Start a Cloudly Instance and Add a Cluster
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Assuming myCloudlyInstance is already configured and initialized
|
import { Cloudly, ClusterManager } from '@serve.zone/cloudly';
|
||||||
|
|
||||||
// Start the cloud instance
|
async function main() {
|
||||||
await myCloudlyInstance.start();
|
const myCloudlyConfig = {
|
||||||
|
mongoDescriptor: {
|
||||||
|
mongoDbUrl: 'mongodb+srv://<username>:<password>@<cluster>.mongodb.net/myFirstDatabase',
|
||||||
|
mongoDbName: 'myDatabase',
|
||||||
|
mongoDbUser: 'myUser',
|
||||||
|
mongoDbPass: 'myPassword',
|
||||||
|
},
|
||||||
|
cfToken: 'your_cloudflare_api_token',
|
||||||
|
environment: 'development',
|
||||||
|
letsEncryptEmail: 'lets_encrypt_email@example.com',
|
||||||
|
publicUrl: 'example.com',
|
||||||
|
publicPort: 8443,
|
||||||
|
hetznerToken: 'your_hetzner_api_token'
|
||||||
|
};
|
||||||
|
|
||||||
// Now you can perform various operations on your Docker Swarmkit cluster
|
const myCloudlyInstance = new Cloudly(myCloudlyConfig);
|
||||||
|
await myCloudlyInstance.start();
|
||||||
|
|
||||||
|
const clusterManager = myCloudlyInstance.clusterManager;
|
||||||
|
const newCluster = await clusterManager.storeCluster({
|
||||||
|
id: 'example_cluster_id',
|
||||||
|
data: {
|
||||||
|
name: 'example_cluster',
|
||||||
|
jumpCode: 'random_jump_code',
|
||||||
|
jumpCodeUsedAt: null,
|
||||||
|
secretKey: 'example_secret_key',
|
||||||
|
acmeInfo: null,
|
||||||
|
cloudlyUrl: 'https://example.com:8443',
|
||||||
|
servers: [],
|
||||||
|
sshKeys: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Cluster added:', newCluster);
|
||||||
|
}
|
||||||
|
main();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Integration with Cloud Providers
|
### Example: Manage Cloudflare DNS Records
|
||||||
`@serve.zone/cloudly` integrates seamlessly with cloud providers like DigitalOcean, Hetzner Cloud, etc., by leveraging the power of APIs provided by these platforms.
|
|
||||||
|
|
||||||
#### Managing DigitalOcean Resources
|
|
||||||
To manage DigitalOcean resources, you'll need to configure your DigitalOcean token and then use the provided interfaces to interact with the resources, such as creating droplets, managing volumes, etc.
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Set your DigitalOcean API token
|
import { Cloudly, CloudflareConnector } from '@serve.zone/cloudly';
|
||||||
const digitalOceanToken = "your_digital_ocean_api_token";
|
|
||||||
|
|
||||||
// Now you can use myCloudlyInstance to manage DigitalOcean resources
|
async function manageDNSRecords() {
|
||||||
|
const myCloudlyConfig = {
|
||||||
|
mongoDescriptor: {
|
||||||
|
mongoDbUrl: 'mongodb+srv://<username>:<password>@<cluster>.mongodb.net/myFirstDatabase',
|
||||||
|
mongoDbName: 'myDatabase',
|
||||||
|
mongoDbUser: 'myUser',
|
||||||
|
mongoDbPass: 'myPassword',
|
||||||
|
},
|
||||||
|
cfToken: 'your_cloudflare_api_token',
|
||||||
|
environment: 'development',
|
||||||
|
letsEncryptEmail: 'lets_encrypt_email@example.com',
|
||||||
|
publicUrl: 'example.com',
|
||||||
|
publicPort: 8443,
|
||||||
|
hetznerToken: 'your_hetzner_api_token'
|
||||||
|
};
|
||||||
|
|
||||||
|
const myCloudlyInstance = new Cloudly(myCloudlyConfig);
|
||||||
|
await myCloudlyInstance.start();
|
||||||
|
|
||||||
|
const dnsInfo = {
|
||||||
|
zoneName: 'example.com',
|
||||||
|
recordName: 'sub.example.com',
|
||||||
|
recordType: 'A',
|
||||||
|
recordContent: '127.0.0.1',
|
||||||
|
};
|
||||||
|
|
||||||
|
const cfConnector = myCloudlyInstance.cloudflareConnector.cloudflare;
|
||||||
|
const newRecord = await cfConnector.createDNSRecord(
|
||||||
|
dnsInfo.zoneName,
|
||||||
|
dnsInfo.recordName,
|
||||||
|
dnsInfo.recordType,
|
||||||
|
dnsInfo.recordContent
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('DNS Record created:', newRecord);
|
||||||
|
}
|
||||||
|
manageDNSRecords();
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Using the Cloudflare Integration
|
### Example: Integrate with DigitalOcean
|
||||||
Similarly, for managing DNS records and SSL certificates with Cloudflare, set up your Cloudflare API token:
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const cloudflareToken = "your_cloudflare_api_token";
|
import { Cloudly, DigitalOceanConnector } from '@serve.zone/cloudly';
|
||||||
|
|
||||||
// Use myCloudlyInstance to interact with Cloudflare, such as setting DNS records
|
async function manageDroplet() {
|
||||||
|
const myCloudlyConfig = {
|
||||||
|
mongoDescriptor: {
|
||||||
|
mongoDbUrl: 'mongodb+srv://<username>:<password>@<cluster>.mongodb.net/myFirstDatabase',
|
||||||
|
mongoDbName: 'myDatabase',
|
||||||
|
mongoDbUser: 'myUser',
|
||||||
|
mongoDbPass: 'myPassword',
|
||||||
|
},
|
||||||
|
cfToken: 'your_cloudflare_api_token',
|
||||||
|
environment: 'development',
|
||||||
|
letsEncryptEmail: 'lets_encrypt_email@example.com',
|
||||||
|
publicUrl: 'example.com',
|
||||||
|
publicPort: 8443,
|
||||||
|
hetznerToken: 'your_hetzner_api_token'
|
||||||
|
};
|
||||||
|
|
||||||
|
const myCloudlyInstance = new Cloudly(myCloudlyConfig);
|
||||||
|
await myCloudlyInstance.start();
|
||||||
|
|
||||||
|
const doConnector = myCloudlyInstance.digitaloceanConnector;
|
||||||
|
const dropletInfo = {
|
||||||
|
name: 'example-droplet',
|
||||||
|
region: 'nyc3',
|
||||||
|
size: 's-1vcpu-1gb',
|
||||||
|
image: 'ubuntu-20-04-x64',
|
||||||
|
};
|
||||||
|
|
||||||
|
const newDroplet = await doConnector.createDroplet(
|
||||||
|
dropletInfo.name,
|
||||||
|
dropletInfo.region,
|
||||||
|
dropletInfo.size,
|
||||||
|
dropletInfo.image
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('Droplet created:', newDroplet);
|
||||||
|
}
|
||||||
|
manageDroplet();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Advanced Usage
|
### Using Cloudly Web Interface
|
||||||
`@serve.zone/cloudly` offers more than just cloud resource management. It integrates various modules for error logging, security, working with JSON data, and much more. Explore the comprehensive documentation and typings to leverage the full potential of the package.
|
If your project includes a web interface to manage various sections like DNS, deployments, clusters, etc., you can use the provided elements and state management. Below is an example of setting up a dashboard using the components defined:
|
||||||
|
|
||||||
### Conclusion
|
```typescript
|
||||||
With `@serve.zone/cloudly`, configuring the cloud becomes a less tedious task. By abstracting away the complexities and providing a unified interface to manage cloud resources, development efficiency is significantly improved. The examples provided above merely scratch the surface of what's possible. Dive into the detailed documentation to explore all features and capabilities.
|
import { commitinfo } from '../00_commitinfo_data.js';
|
||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
|
import * as appstate from '../appstate.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
DeesElement,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
state
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import { CloudlyViewBackups } from './cloudly-view-backups.js';
|
||||||
|
import { CloudlyViewClusters } from './cloudly-view-clusters.js';
|
||||||
|
import { CloudlyViewDbs } from './cloudly-view-dbs.js';
|
||||||
|
import { CloudlyViewDeployments } from './cloudly-view-deployments.js';
|
||||||
|
import { CloudlyViewDns } from './cloudly-view-dns.js';
|
||||||
|
import { CloudlyViewImages } from './cloudly-view-images.js';
|
||||||
|
import { CloudlyViewLogs } from './cloudly-view-logs.js';
|
||||||
|
import { CloudlyViewMails } from './cloudly-view-mails.js';
|
||||||
|
import { CloudlyViewOverview } from './cloudly-view-overview.js';
|
||||||
|
import { CloudlyViewS3 } from './cloudly-view-s3.js';
|
||||||
|
import { CloudlyViewSecretBundles } from './cloudly-view-secretbundles.js';
|
||||||
|
import { CloudlyViewSecretGroups } from './cloudly-view-secretgroups.js';
|
||||||
|
import { CloudlyViewServices } from './cloudly-view-services.js';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'cvault-dashboard': CloudlyDashboard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('cloudly-dashboard')
|
||||||
|
export class CloudlyDashboard extends DeesElement {
|
||||||
|
@state() private jwt: string;
|
||||||
|
@state() private data: appstate.IDataState = {
|
||||||
|
secretGroups: [],
|
||||||
|
secretBundles: [],
|
||||||
|
clusters: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
const subcription = appstate.dataState
|
||||||
|
.select((stateArg) => stateArg)
|
||||||
|
.subscribe((dataArg) => {
|
||||||
|
this.data = dataArg;
|
||||||
|
});
|
||||||
|
this.rxSubscriptions.push(subcription);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
.maincontainer {
|
||||||
|
position: relative;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 24px;
|
||||||
|
font-family: 'Cal Sans';
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
public render() {
|
||||||
|
return html`
|
||||||
|
<div class="maincontainer">
|
||||||
|
<dees-simple-login name="cloudly v${commitinfo.version}">
|
||||||
|
<dees-simple-appdash name="cloudly v${commitinfo.version}"
|
||||||
|
.viewTabs=${[
|
||||||
|
{
|
||||||
|
name: 'Overview',
|
||||||
|
element: CloudlyViewOverview,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'SecretGroups',
|
||||||
|
element: CloudlyViewSecretGroups,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'SecretBundles',
|
||||||
|
element: CloudlyViewSecretBundles,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Clusters',
|
||||||
|
element: CloudlyViewClusters,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Images',
|
||||||
|
element: CloudlyViewImages,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Services',
|
||||||
|
element: CloudlyViewServices,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Deployments',
|
||||||
|
element: CloudlyViewDeployments,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DNS',
|
||||||
|
element: CloudlyViewDns,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Mails',
|
||||||
|
element: CloudlyViewMails,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Logs',
|
||||||
|
element: CloudlyViewLogs,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 's3',
|
||||||
|
element: CloudlyViewS3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DBs',
|
||||||
|
element: CloudlyViewDbs,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Backups',
|
||||||
|
element: CloudlyViewBackups,
|
||||||
|
},
|
||||||
|
] as plugins.deesCatalog.IView[]}
|
||||||
|
></dees-simple-appdash>
|
||||||
|
</dees-simple-login>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
public async firstUpdated() {
|
||||||
|
const simpleLogin = this.shadowRoot.querySelector('dees-simple-login');
|
||||||
|
simpleLogin.addEventListener('login', (e: CustomEvent) => {
|
||||||
|
console.log(e.detail);
|
||||||
|
this.login(e.detail.data.username, e.detail.data.password);
|
||||||
|
});
|
||||||
|
this.addEventListener('contextmenu', (eventArg) => {
|
||||||
|
plugins.deesCatalog.DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
||||||
|
{
|
||||||
|
name: 'About',
|
||||||
|
iconName: 'mugHot',
|
||||||
|
action: async () => {
|
||||||
|
await plugins.deesCatalog.DeesModal.createAndShow({
|
||||||
|
heading: 'About',
|
||||||
|
content: html`configvault ${commitinfo.version}`,
|
||||||
|
menuOptions: [
|
||||||
|
{
|
||||||
|
name: 'close',
|
||||||
|
iconName: null,
|
||||||
|
action: async (modalArg) => {
|
||||||
|
await modalArg.destroy();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// lets deal with initial state
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
const loginState = appstate.loginStatePart.getState();
|
||||||
|
console.log(loginState);
|
||||||
|
if (loginState.jwt) {
|
||||||
|
this.jwt = loginState.jwt;
|
||||||
|
await simpleLogin.switchToSlottedContent();
|
||||||
|
await appstate.dataState.dispatchAction(appstate.getDataAction, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async login(username: string, password: string) {
|
||||||
|
console.log(`attempting to login...`);
|
||||||
|
const simpleLogin = this.shadowRoot.querySelector('dees-simple-login');
|
||||||
|
const form = simpleLogin.shadowRoot.querySelector('dees-form');
|
||||||
|
form.setStatus('pending', 'Logging in...');
|
||||||
|
const state = await appstate.loginStatePart.dispatchAction(appstate.loginAction, {
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
});
|
||||||
|
if (state.jwt) {
|
||||||
|
console.log('got jwt');
|
||||||
|
this.jwt = state.jwt;
|
||||||
|
form.setStatus('success', 'Logged in!');
|
||||||
|
await simpleLogin.switchToSlottedContent();
|
||||||
|
await appstate.dataState.dispatchAction(appstate.getDataAction, null);
|
||||||
|
} else {
|
||||||
|
form.setStatus('error', 'Login failed!');
|
||||||
|
await domtools.convenience.smartdelay.delayFor(2000);
|
||||||
|
form.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async logout() {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This script sets up a cloud management dashboard for interacting with various cloud services seamlessly. It covers creating clusters, managing DNS records, handling cloud-provider-specific resources, and much more.
|
||||||
|
|
||||||
|
With the examples provided above, you should now have a good understanding of how to use `@serve.zone/cloudly` to manage your cloud infrastructure programmatically. For deeper insights and additional features, refer to the documentation relevant to specific modules and methods used in your application.
|
||||||
|
|
||||||
## License and Legal Information
|
## License and Legal Information
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/cloudly',
|
name: '@serve.zone/cloudly',
|
||||||
version: '1.0.215',
|
version: '1.0.216',
|
||||||
description: 'A cloud manager utilizing Docker Swarmkit, designed for operations on Cloudron, and supports various cloud platforms like DigitalOcean, Hetzner Cloud, and Cloudflare.'
|
description: 'A cloud manager leveraging Docker Swarmkit for multi-cloud operations including DigitalOcean, Hetzner Cloud, and Cloudflare, with integration support and robust configuration management system.'
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import * as plugins from './cloudly.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import { CloudlyConfig } from './cloudly.classes.config.js';
|
import { CloudlyConfig } from './classes.config.js';
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
import {} from '@tsclass/tsclass';
|
import {} from '@tsclass/tsclass';
|
||||||
|
|
||||||
// Cloudly mods
|
// Cloudly mods
|
||||||
import { CloudlyInfo } from './cloudly.classes.cloudlyinfo.js';
|
import { CloudlyInfo } from './classes.cloudlyinfo.js';
|
||||||
import { CloudlyServer } from './cloudly.classes.server.js';
|
import { CloudlyServer } from './classes.server.js';
|
||||||
|
|
||||||
// connectors
|
// connectors
|
||||||
import { CloudflareConnector } from './connector.cloudflare/connector.js';
|
import { CloudflareConnector } from './connector.cloudflare/connector.js';
|
||||||
@ -17,7 +17,6 @@ import { MongodbConnector } from './connector.mongodb/connector.js';
|
|||||||
import { CloudlyCoreflowManager } from './manager.coreflow/coreflowmanager.js';
|
import { CloudlyCoreflowManager } from './manager.coreflow/coreflowmanager.js';
|
||||||
import { ClusterManager } from './manager.cluster/clustermanager.js';
|
import { ClusterManager } from './manager.cluster/clustermanager.js';
|
||||||
import { CloudlyTaskmanager } from './manager.task/taskmanager.js';
|
import { CloudlyTaskmanager } from './manager.task/taskmanager.js';
|
||||||
import { CloudlyVersionManager } from './manager.version/versionmanager.js';
|
|
||||||
import { CloudlySecretManager } from './manager.secret/classes.secretmanager.js'
|
import { CloudlySecretManager } from './manager.secret/classes.secretmanager.js'
|
||||||
import { CloudlyServerManager } from './manager.server/servermanager.js';
|
import { CloudlyServerManager } from './manager.server/servermanager.js';
|
||||||
import { ExternalApiManager } from './manager.status/statusmanager.js';
|
import { ExternalApiManager } from './manager.status/statusmanager.js';
|
||||||
@ -55,7 +54,6 @@ export class Cloudly {
|
|||||||
public externalApiManager: ExternalApiManager;
|
public externalApiManager: ExternalApiManager;
|
||||||
public imageManager: ImageManager;
|
public imageManager: ImageManager;
|
||||||
public taskManager: CloudlyTaskmanager;
|
public taskManager: CloudlyTaskmanager;
|
||||||
public versionManager: CloudlyVersionManager;
|
|
||||||
public serverManager: CloudlyServerManager;
|
public serverManager: CloudlyServerManager;
|
||||||
|
|
||||||
private readyDeferred = new plugins.smartpromise.Deferred();
|
private readyDeferred = new plugins.smartpromise.Deferred();
|
||||||
@ -79,7 +77,6 @@ export class Cloudly {
|
|||||||
this.externalApiManager = new ExternalApiManager(this);
|
this.externalApiManager = new ExternalApiManager(this);
|
||||||
this.imageManager = new ImageManager(this);
|
this.imageManager = new ImageManager(this);
|
||||||
this.taskManager = new CloudlyTaskmanager(this);
|
this.taskManager = new CloudlyTaskmanager(this);
|
||||||
this.versionManager = new CloudlyVersionManager(this);
|
|
||||||
this.secretManager = new CloudlySecretManager(this);
|
this.secretManager = new CloudlySecretManager(this);
|
||||||
this.serverManager = new CloudlyServerManager(this);
|
this.serverManager = new CloudlyServerManager(this);
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './cloudly.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import * as paths from './cloudly.paths.js';
|
import * as paths from './paths.js';
|
||||||
import { Cloudly } from './index.js';
|
import { Cloudly } from './index.js';
|
||||||
|
|
||||||
export class CloudlyInfo {
|
export class CloudlyInfo {
|
@ -1,7 +1,7 @@
|
|||||||
import * as plugins from './cloudly.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import * as paths from './cloudly.paths.js';
|
import * as paths from './paths.js';
|
||||||
import { logger } from './cloudly.logging.js';
|
import { logger } from './cloudly.logging.js';
|
||||||
import type { Cloudly } from './cloudly.classes.cloudly.js';
|
import type { Cloudly } from './classes.cloudly.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the main cloudly config
|
* the main cloudly config
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from './cloudly.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import * as paths from './cloudly.paths.js';
|
import * as paths from './paths.js';
|
||||||
import { Cloudly } from './cloudly.classes.cloudly.js';
|
import { Cloudly } from './classes.cloudly.js';
|
||||||
import { logger } from './cloudly.logging.js';
|
import { logger } from './cloudly.logging.js';
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './cloudly.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import * as paths from './cloudly.paths.js';
|
import * as paths from './paths.js';
|
||||||
|
|
||||||
export const logger = new plugins.smartlog.Smartlog({
|
export const logger = new plugins.smartlog.Smartlog({
|
||||||
logContext: {
|
logContext: {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
import { Cloudly } from '../classes.cloudly.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the portion of Cloudflare responsible
|
* the portion of Cloudflare responsible
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
import { Cloudly } from '../classes.cloudly.js';
|
||||||
|
|
||||||
export class LetsencryptConnector {
|
export class LetsencryptConnector {
|
||||||
private cloudlyRef: Cloudly;
|
private cloudlyRef: Cloudly;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
import { Cloudly } from '../classes.cloudly.js';
|
||||||
|
|
||||||
export class MongodbConnector {
|
export class MongodbConnector {
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
// Create an array to hold 10 ISecretGroup objects
|
// Create an array to hold 10 ISecretGroup objects
|
||||||
const demoSecretGroups: plugins.servezoneInterfaces.data.ISecretGroup[] = [];
|
const demoSecretGroups: plugins.servezoneInterfaces.data.ISecretGroup[] = [];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { Cloudly } from '../cloudly.classes.cloudly.js';
|
import type { Cloudly } from '../classes.cloudly.js';
|
||||||
|
|
||||||
export const installDemoData = async (cloudlyRef: Cloudly) => {
|
export const installDemoData = async (cloudlyRef: Cloudly) => {
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import * as early from '@push.rocks/early';
|
import * as early from '@push.rocks/early';
|
||||||
early.start('cloudly');
|
early.start('cloudly');
|
||||||
import * as plugins from './cloudly.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import * as paths from './cloudly.paths.js';
|
import * as paths from './paths.js';
|
||||||
import { Cloudly } from './cloudly.classes.cloudly.js';
|
import { Cloudly } from './classes.cloudly.js';
|
||||||
import { logger } from './cloudly.logging.js';
|
import { logger } from './cloudly.logging.js';
|
||||||
const cloudlyQenv = new plugins.qenv.Qenv(paths.packageDir, paths.nogitDir, true);
|
const cloudlyQenv = new plugins.qenv.Qenv(paths.packageDir, paths.nogitDir, true);
|
||||||
early.stop();
|
early.stop();
|
||||||
|
17
ts/manager.auth/classes.authmanager.ts
Normal file
17
ts/manager.auth/classes.authmanager.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import type { Cloudly } from '../classes.cloudly.js';
|
||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
import { Authorization } from './classes.authorization.js';
|
||||||
|
import { User } from './classes.user.js';
|
||||||
|
|
||||||
|
export class AuthManager {
|
||||||
|
cloudlyRef: Cloudly
|
||||||
|
public get db() {
|
||||||
|
return this.cloudlyRef.mongodbConnector.smartdataDb;
|
||||||
|
}
|
||||||
|
public CUser = plugins.smartdata.setDefaultManagerForDoc(this, User);
|
||||||
|
public CAuthorization = plugins.smartdata.setDefaultManagerForDoc(this, Authorization);
|
||||||
|
|
||||||
|
constructor(cloudlyRef: Cloudly) {
|
||||||
|
this.cloudlyRef = cloudlyRef;
|
||||||
|
}
|
||||||
|
}
|
6
ts/manager.auth/classes.authorization.ts
Normal file
6
ts/manager.auth/classes.authorization.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
|
@plugins.smartdata.managed()
|
||||||
|
export class Authorization extends plugins.smartdata.SmartDataDbDoc<Authorization, Authorization> {
|
||||||
|
|
||||||
|
}
|
6
ts/manager.auth/classes.user.ts
Normal file
6
ts/manager.auth/classes.user.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
|
@plugins.smartdata.managed()
|
||||||
|
export class User extends plugins.smartdata.SmartDataDbDoc<User, User> {
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cluster defines a swarmkit cluster
|
* cluster defines a swarmkit cluster
|
||||||
*/
|
*/
|
||||||
@plugins.smartdata.Manager()
|
@plugins.smartdata.managed()
|
||||||
export class Cluster extends plugins.smartdata.SmartDataDbDoc<Cluster, plugins.servezoneInterfaces.data.ICluster> {
|
export class Cluster extends plugins.smartdata.SmartDataDbDoc<Cluster, plugins.servezoneInterfaces.data.ICluster> {
|
||||||
// STATIC
|
// STATIC
|
||||||
public static async fromConfigObject(
|
public static async fromConfigObject(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import * as paths from '../cloudly.paths.js';
|
import * as paths from '../paths.js';
|
||||||
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
import { Cloudly } from '../classes.cloudly.js';
|
||||||
import { logger } from '../cloudly.logging.js';
|
import { logger } from '../cloudly.logging.js';
|
||||||
|
|
||||||
import { Cluster } from './cluster.js';
|
import { Cluster } from './cluster.js';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
import { Cloudly } from '../classes.cloudly.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* in charge of talking to coreflow services on clusters
|
* in charge of talking to coreflow services on clusters
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import type { ImageManager } from './classes.imagemanager.js';
|
import type { ImageManager } from './classes.imagemanager.js';
|
||||||
|
|
||||||
@plugins.smartdata.Manager()
|
@plugins.smartdata.Manager()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { Cloudly } from '../cloudly.classes.cloudly.js';
|
import type { Cloudly } from '../classes.cloudly.js';
|
||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
import { Image } from './classes.image.js';
|
import { Image } from './classes.image.js';
|
||||||
|
|
||||||
@ -49,11 +49,14 @@ export class ImageManager {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.typedrouter.addTypedHandler(
|
this.typedrouter.addTypedHandler(
|
||||||
new plugins.typedrequest.TypedHandler<plugins.servezoneInterfaces.requests.image.IRequest_PushImage>('pushImage', async (reqArg) => {
|
new plugins.typedrequest.TypedHandler<plugins.servezoneInterfaces.requests.image.IRequest_PushImage>(
|
||||||
const pushStream = reqArg.imageStream;
|
'pushImage',
|
||||||
return {}
|
async (reqArg) => {
|
||||||
})
|
const pushStream = reqArg.imageStream;
|
||||||
)
|
return {};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
this.typedrouter.addTypedHandler(
|
this.typedrouter.addTypedHandler(
|
||||||
new plugins.typedrequest.TypedHandler<plugins.servezoneInterfaces.requests.image.IRequest_PullImage>(
|
new plugins.typedrequest.TypedHandler<plugins.servezoneInterfaces.requests.image.IRequest_PullImage>(
|
||||||
@ -62,13 +65,13 @@ export class ImageManager {
|
|||||||
const image = await this.CImage.getInstance({
|
const image = await this.CImage.getInstance({
|
||||||
data: {
|
data: {
|
||||||
name: reqArg.name,
|
name: reqArg.name,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const imageVersion = null;
|
const imageVersion = null;
|
||||||
const imageVirtualStream = new plugins.typedrequest.VirtualStream();
|
const imageVirtualStream = new plugins.typedrequest.VirtualStream();
|
||||||
return {
|
return {
|
||||||
imageStream: imageVirtualStream,
|
imageStream: imageVirtualStream,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -82,7 +85,7 @@ export class ImageManager {
|
|||||||
this.cloudlyRef.config.data.s3Descriptor
|
this.cloudlyRef.config.data.s3Descriptor
|
||||||
);
|
);
|
||||||
const bucket = await this.smartbucketInstance.getBucketByName('cloudly-test');
|
const bucket = await this.smartbucketInstance.getBucketByName('cloudly-test');
|
||||||
await bucket.fastStore('test/test.txt', 'hello');
|
await bucket.fastPut({ path: 'test/test.txt', contents: 'hello' });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createImage(nameArg: string) {
|
public async createImage(nameArg: string) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
import { Cloudly } from '../classes.cloudly.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* takes care of receiving and providing logs
|
* takes care of receiving and providing logs
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// a secret bundle is a set of secrets ready to be used in a project.
|
// a secret bundle is a set of secrets ready to be used in a project.
|
||||||
// it bundles secretgroups
|
// it bundles secretgroups
|
||||||
import { SecretGroup } from './classes.secretgroup.js';
|
import { SecretGroup } from './classes.secretgroup.js';
|
||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
@plugins.smartdata.Manager()
|
@plugins.smartdata.Manager()
|
||||||
export class SecretBundle extends plugins.smartdata.SmartDataDbDoc<
|
export class SecretBundle extends plugins.smartdata.SmartDataDbDoc<
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* a secretgroup is a set of secrets for different environments.
|
* a secretgroup is a set of secrets for different environments.
|
||||||
*/
|
*/
|
||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
@plugins.smartdata.Manager()
|
@plugins.smartdata.Manager()
|
||||||
export class SecretGroup extends plugins.smartdata.SmartDataDbDoc<
|
export class SecretGroup extends plugins.smartdata.SmartDataDbDoc<
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import * as paths from '../cloudly.paths.js';
|
import * as paths from '../paths.js';
|
||||||
import { SecretBundle } from './classes.secretbundle.js';
|
import { SecretBundle } from './classes.secretbundle.js';
|
||||||
import { SecretGroup } from './classes.secretgroup.js';
|
import { SecretGroup } from './classes.secretgroup.js';
|
||||||
import { logger } from '../cloudly.logging.js';
|
import { logger } from '../cloudly.logging.js';
|
||||||
import type { Cloudly } from '../cloudly.classes.cloudly.js';
|
import type { Cloudly } from '../classes.cloudly.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `ConfigVault` class provides methods for reading and writing configuration data to a file.
|
* The `ConfigVault` class provides methods for reading and writing configuration data to a file.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cluster defines a swarmkit cluster
|
* cluster defines a swarmkit cluster
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
import { Cloudly } from '../classes.cloudly.js';
|
||||||
import { Cluster } from '../manager.cluster/cluster.js';
|
import { Cluster } from '../manager.cluster/cluster.js';
|
||||||
import { Server } from './server.js';
|
import { Server } from './server.js';
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import { Cloudly } from '../index.js';
|
import { Cloudly } from '../index.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
import { Cloudly } from '../classes.cloudly.js';
|
||||||
|
|
||||||
import { logger } from '../cloudly.logging.js';
|
import { logger } from '../cloudly.logging.js';
|
||||||
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
|
||||||
|
|
||||||
/*
|
|
||||||
A container version is managed by the versionmanager
|
|
||||||
*/
|
|
||||||
@plugins.smartdata.Manager()
|
|
||||||
export class ContainerVersion
|
|
||||||
extends plugins.smartdata.SmartDataDbDoc<ContainerVersion, unknown>
|
|
||||||
implements plugins.servezoneInterfaces.data.IContainerVersionData
|
|
||||||
{
|
|
||||||
public static async fromIVersionData(
|
|
||||||
dataArg: plugins.servezoneInterfaces.data.IContainerVersionData
|
|
||||||
) {
|
|
||||||
const containerVersionInstance = new ContainerVersion();
|
|
||||||
containerVersionInstance.id = plugins.smartunique.shortId();
|
|
||||||
Object.assign(containerVersionInstance, dataArg);
|
|
||||||
return containerVersionInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@plugins.smartdata.unI()
|
|
||||||
public id: string;
|
|
||||||
|
|
||||||
@plugins.smartdata.svDb()
|
|
||||||
public dockerImageUrl: string;
|
|
||||||
|
|
||||||
@plugins.smartdata.svDb()
|
|
||||||
public dockerImageVersion: string;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
import * as plugins from '../cloudly.plugins.js';
|
|
||||||
|
|
||||||
import { ContainerVersion } from './containerversion.js';
|
|
||||||
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
|
||||||
|
|
||||||
export class CloudlyVersionManager {
|
|
||||||
// INSTANCE
|
|
||||||
public cloudlyRef: Cloudly;
|
|
||||||
public get db() {
|
|
||||||
return this.cloudlyRef.mongodbConnector.smartdataDb;
|
|
||||||
}
|
|
||||||
public typedRouter = new plugins.typedrequest.TypedRouter();
|
|
||||||
|
|
||||||
// connected classes
|
|
||||||
public CContainerVersion = plugins.smartdata.setDefaultManagerForDoc(this, ContainerVersion);
|
|
||||||
|
|
||||||
constructor(cloudlyRefArg: Cloudly) {
|
|
||||||
this.cloudlyRef = cloudlyRefArg;
|
|
||||||
this.cloudlyRef.typedrouter.addTypedRouter(this.typedRouter);
|
|
||||||
// get version
|
|
||||||
this.typedRouter.addTypedHandler<plugins.servezoneInterfaces.requests.version.IRequest_Any_Cloudly_VersionManager_GetLatestContainerVersion>(
|
|
||||||
new plugins.typedrequest.TypedHandler(
|
|
||||||
'getLatestContainerVersion',
|
|
||||||
async (typedRequestData) => {
|
|
||||||
const containerVersionGet: ContainerVersion =
|
|
||||||
await ContainerVersion.getInstance<ContainerVersion>({
|
|
||||||
dockerImageUrl: typedRequestData.dockerImageUrl,
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
dockerImageUrl: containerVersionGet.dockerImageUrl,
|
|
||||||
dockerImageVersion: containerVersionGet.dockerImageVersion,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// update version
|
|
||||||
this.typedRouter.addTypedHandler<plugins.servezoneInterfaces.requests.version.IRequest_Any_Cloudly_VersionManager_InformCloudlyAboutNewContainerVersion>(
|
|
||||||
new plugins.typedrequest.TypedHandler(
|
|
||||||
'informCloudlyAboutNewContainerVersion',
|
|
||||||
async (dataArg) => {
|
|
||||||
console.log(`Got a container version announcement! "${dataArg.dockerImageUrl}"`);
|
|
||||||
let containerVersion: ContainerVersion =
|
|
||||||
await ContainerVersion.getInstance<ContainerVersion>({
|
|
||||||
dockerImageUrl: dataArg.dockerImageUrl,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (containerVersion) {
|
|
||||||
containerVersion.dockerImageVersion = dataArg.dockerImageVersion;
|
|
||||||
await containerVersion.save();
|
|
||||||
} else {
|
|
||||||
containerVersion = await ContainerVersion.fromIVersionData(dataArg);
|
|
||||||
await containerVersion.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
// lets push this info to the relevant clusters
|
|
||||||
const clusters = await this.cloudlyRef.clusterManager.getAllClusters();
|
|
||||||
let foundServices: plugins.servezoneInterfaces.data.IService;
|
|
||||||
let relevantClusterIdentifier: plugins.servezoneInterfaces.data.IClusterIdentifier;
|
|
||||||
for (const clusterArg of clusters) {
|
|
||||||
console.log(clusterArg);
|
|
||||||
for (const serviceArg of await clusterArg.getServices()) {
|
|
||||||
if (serviceArg.image === containerVersion.dockerImageUrl) {
|
|
||||||
foundServices = serviceArg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (foundServices) {
|
|
||||||
relevantClusterIdentifier = {
|
|
||||||
clusterName: clusterArg.data.name,
|
|
||||||
secretKey: clusterArg.data.secretKey,
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!relevantClusterIdentifier) {
|
|
||||||
console.log('no cluster found that needs to update');
|
|
||||||
return {};
|
|
||||||
} else {
|
|
||||||
console.log('found relevant cluster identifier:');
|
|
||||||
console.log(relevantClusterIdentifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
const targetConnection =
|
|
||||||
await this.cloudlyRef.server.typedsocketServer.findTargetConnection(
|
|
||||||
async (connectionArg) => {
|
|
||||||
const identityTag = await connectionArg.getTagById('identity');
|
|
||||||
if (!identityTag) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const result =
|
|
||||||
plugins.smartjson.stringify(identityTag.payload) ===
|
|
||||||
plugins.smartjson.stringify(relevantClusterIdentifier);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (targetConnection) {
|
|
||||||
console.log(`the relevant cluster is connected and is now being informed.`);
|
|
||||||
const informCoreflowTR =
|
|
||||||
this.cloudlyRef.server.typedsocketServer.createTypedRequest<plugins.servezoneInterfaces.requests.version.IRequest_Cloudly_Coreflow_VersionManager_InformCoreflowAboutNewContainerVersion>(
|
|
||||||
'informCoreflowAboutNewContainerVersion',
|
|
||||||
targetConnection
|
|
||||||
);
|
|
||||||
informCoreflowTR.fire({
|
|
||||||
dockerImageUrl: containerVersion.dockerImageUrl,
|
|
||||||
dockerImageVersion: containerVersion.dockerImageVersion,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log('the relevant cluster is not connected at this time.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// lets support the servezone standard
|
|
||||||
this.typedRouter.addTypedHandler(
|
|
||||||
new plugins.typedrequest.TypedHandler<plugins.servezoneInterfaces.requests.IRequest_InformAboutNewContainerImage>(
|
|
||||||
'servezonestandard_InformAboutNewContainerVersion',
|
|
||||||
async (dataArg) => {
|
|
||||||
const result =
|
|
||||||
await this.typedRouter.routeAndAddResponse<plugins.servezoneInterfaces.requests.version.IRequest_Any_Cloudly_VersionManager_InformCloudlyAboutNewContainerVersion>(
|
|
||||||
{
|
|
||||||
method: 'informCloudlyAboutNewContainerVersion',
|
|
||||||
request: {
|
|
||||||
dockerImageUrl: dataArg.containerImageInfo.registryUrl,
|
|
||||||
dockerImageVersion: dataArg.containerImageInfo.version,
|
|
||||||
},
|
|
||||||
response: null
|
|
||||||
},
|
|
||||||
true
|
|
||||||
);
|
|
||||||
return result.response;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gets all versions
|
|
||||||
*/
|
|
||||||
public async getAllVersions() {
|
|
||||||
const result = await ContainerVersion.getInstances<ContainerVersion>({});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './cloudly.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||||
export const nogitDir = plugins.path.join(packageDir, '.nogit/');
|
export const nogitDir = plugins.path.join(packageDir, '.nogit/');
|
@ -1,13 +1,130 @@
|
|||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
export class CloudlyClient {
|
export type TClientType = 'coreflow' | 'cli' | 'serverconfig';
|
||||||
public clientToken: string;
|
|
||||||
|
|
||||||
constructor(clientToken: string) {
|
export class CloudlyClient {
|
||||||
this.clientToken = clientToken;
|
private cloudlyUrl: string;
|
||||||
|
private registerAs: string;
|
||||||
|
|
||||||
|
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||||
|
public typedsocketClient: plugins.typedsocket.TypedSocket;
|
||||||
|
|
||||||
|
// Subjects
|
||||||
|
public configUpdateSubject = new plugins.smartrx.rxjs.Subject<
|
||||||
|
plugins.servezoneInterfaces.requests.config.IRequest_Cloudly_Coreflow_PushClusterConfig['request']
|
||||||
|
>();
|
||||||
|
|
||||||
|
public serverActionSubject = new plugins.smartrx.rxjs.Subject<
|
||||||
|
plugins.servezoneInterfaces.requests.server.IRequest_TriggerServerAction['request']
|
||||||
|
>();
|
||||||
|
|
||||||
|
constructor(registerAsArg: TClientType) {
|
||||||
|
this.cloudlyUrl = process.env.CLOUDLY_URL || 'https://cloudly.layer.io:443';
|
||||||
|
this.registerAs = registerAsArg;
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`creating LoleCloudlyClient: registering as ${this.registerAs} and target url ${this.cloudlyUrl}`
|
||||||
|
);
|
||||||
|
|
||||||
|
this.typedrouter.addTypedHandler<plugins.servezoneInterfaces.requests.config.IRequest_Cloudly_Coreflow_PushClusterConfig>(
|
||||||
|
new plugins.typedrequest.TypedHandler('pushClusterConfig', async (dataArg) => {
|
||||||
|
this.configUpdateSubject.next(dataArg);
|
||||||
|
return {};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
this.typedrouter.addTypedHandler<plugins.servezoneInterfaces.requests.config.IRequest_Cloudly_Coreflow_PushClusterConfig>(
|
||||||
|
new plugins.typedrequest.TypedHandler('pushClusterConfig', async (dataArg) => {
|
||||||
|
this.configUpdateSubject.next(dataArg);
|
||||||
|
return {};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
this.typedrouter.addTypedHandler<plugins.servezoneInterfaces.requests.server.IRequest_TriggerServerAction>(
|
||||||
|
new plugins.typedrequest.TypedHandler('triggerServerAction', async (dataArg) => {
|
||||||
|
this.serverActionSubject.next(dataArg);
|
||||||
|
return {
|
||||||
|
actionConfirmed: true,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getClusters() {
|
public async start() {
|
||||||
|
this.typedsocketClient = await plugins.typedsocket.TypedSocket.createClient(
|
||||||
|
this.typedrouter,
|
||||||
|
this.cloudlyUrl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async stop() {
|
||||||
|
await this.typedsocketClient.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getIdentityByJumpCode(
|
||||||
|
jumpCodeArg: string,
|
||||||
|
tagConnection = false
|
||||||
|
): Promise<plugins.servezoneInterfaces.data.IClusterIdentifier> {
|
||||||
|
const identityRequest =
|
||||||
|
this.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.identity.IRequest_Any_Cloudly_CoreflowManager_GetIdentityByJumpCode>(
|
||||||
|
'getIdentityByJumpCode'
|
||||||
|
);
|
||||||
|
console.log(`trying to get identity from cloudly with supplied jumpCodeArg: ${jumpCodeArg}`);
|
||||||
|
const response = await identityRequest.fire({
|
||||||
|
jumpCode: jumpCodeArg,
|
||||||
|
});
|
||||||
|
console.log('got identity response');
|
||||||
|
const identity = response.clusterIdentifier;
|
||||||
|
|
||||||
|
if (tagConnection) {
|
||||||
|
this.typedsocketClient.addTag('identity', identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getClusterConfigFromCloudlyByIdentity(
|
||||||
|
identityArg: plugins.servezoneInterfaces.data.IClusterIdentifier
|
||||||
|
): Promise<plugins.servezoneInterfaces.data.ICluster> {
|
||||||
|
const clusterConfigRequest =
|
||||||
|
this.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.config.IRequest_Any_Cloudly_GetClusterConfig>(
|
||||||
|
'getClusterConfig'
|
||||||
|
);
|
||||||
|
const response = await clusterConfigRequest.fire({
|
||||||
|
jwt: '', // TODO: do proper auth here
|
||||||
|
clusterIdentifier: identityArg,
|
||||||
|
});
|
||||||
|
return response.configData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getServerConfigFromCloudlyByIdentity(
|
||||||
|
identityArg: plugins.servezoneInterfaces.data.IClusterIdentifier
|
||||||
|
): Promise<plugins.servezoneInterfaces.data.IServer> {
|
||||||
|
const serverConfigRequest =
|
||||||
|
this.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.config.IRequest_Any_Cloudly_GetServerConfig>(
|
||||||
|
'getServerConfig'
|
||||||
|
);
|
||||||
|
const response = await serverConfigRequest.fire({
|
||||||
|
jwt: '', // TODO: do proper auth here
|
||||||
|
serverId: '' // TODO: get server id here
|
||||||
|
});
|
||||||
|
return response.configData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets a certificate for a domain used by a service
|
||||||
|
* @param serviceNameArg
|
||||||
|
* @param domainNameArg
|
||||||
|
*/
|
||||||
|
public async getCertificateForDomainOverHttps(domainNameArg: string): Promise<plugins.tsclass.network.ICert> {
|
||||||
|
const typedCertificateRequest =
|
||||||
|
this.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.certificate.IRequest_Any_Cloudly_GetSslCertificate>(
|
||||||
|
'getSslCertificate'
|
||||||
|
);
|
||||||
|
const typedResponse = await typedCertificateRequest.fire({
|
||||||
|
authToken: '', // do proper auth here
|
||||||
|
requiredCertName: domainNameArg,
|
||||||
|
});
|
||||||
|
return typedResponse.certificate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,5 @@ import * as plugins from './plugins.js';
|
|||||||
|
|
||||||
export class Cluster {
|
export class Cluster {
|
||||||
public getServers() {}
|
public getServers() {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,29 @@
|
|||||||
import * as typedrequest from '@api.global/typedrequest';
|
// @serve.zone scope
|
||||||
|
import * as servezoneInterfaces from '@serve.zone/interfaces';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
typedrequest
|
servezoneInterfaces
|
||||||
|
}
|
||||||
|
|
||||||
|
// @push.rocks scope
|
||||||
|
import * as smartrx from '@push.rocks/smartrx';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartrx,
|
||||||
|
}
|
||||||
|
|
||||||
|
// @api.global scope
|
||||||
|
import * as typedrequest from '@api.global/typedrequest';
|
||||||
|
import * as typedsocket from '@api.global/typedsocket';
|
||||||
|
|
||||||
|
export {
|
||||||
|
typedrequest,
|
||||||
|
typedsocket
|
||||||
|
}
|
||||||
|
|
||||||
|
// @tsclass scope
|
||||||
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
|
export {
|
||||||
|
tsclass,
|
||||||
}
|
}
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/cloudly',
|
name: '@serve.zone/cloudly',
|
||||||
version: '1.0.215',
|
version: '1.0.216',
|
||||||
description: 'A cloud manager utilizing Docker Swarmkit, designed for operations on Cloudron, and supports various cloud platforms like DigitalOcean, Hetzner Cloud, and Cloudflare.'
|
description: 'A cloud manager leveraging Docker Swarmkit for multi-cloud operations including DigitalOcean, Hetzner Cloud, and Cloudflare, with integration support and robust configuration management system.'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user