Skip to content

Commit 8f5fc5c

Browse files
committed
Merge branch 'generator-do' into final_fix
2 parents d236271 + b6eae0f commit 8f5fc5c

File tree

12 files changed

+552
-7
lines changed

12 files changed

+552
-7
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ Once `@nodecloud/common` is installed, you need to install the plugins to intera
7575
| -------------------- | --------------------------------------------------------------------------------- |
7676
| AWS plugin | `yarn add @nodecloud/aws-plugin` or `npm i @nodecloud/aws-plugin` |
7777
| Azure plugin | `yarn add @nodecloud/gcp-plugin` or `npm i @nodecloud/gcp-plugin` |
78-
| Google Cloud plugin | `yarn add @nodecloud/azure-plugin` or `npm i @nodecloud/azure-plugin` |
79-
| Alibaba plugin | `yarn add nodecloud-ali-plugin` or `npm i nodecloud-ali-plugin` |
80-
| Digital Ocean plugin | `yarn add nodecloud-digitalocean-plugin` or `npm i nodecloud-digitalocean-plugin` |
81-
78+
| Google Cloud plugin | `yarn add @nodecloud/azure-plugin` or `npm i @nodecloud/azure-plugin` | |
79+
| Digital Ocean plugin | `yarn add @nodecloud/do-plugin` or `npm i @nodecloud/do-plugin` |
80+
| Alibaba plugin | `yarn add nodecloud-ali-plugin` or `npm i nodecloud-ali-plugin`
8281
**3️⃣ Create the NodeCloud config file**
8382

8483
Create the `.nc.config.js` file in the project root in the following format.
@@ -98,6 +97,7 @@ This config file can contain an array of objects for all providers and all will
9897
const nodeCloudAwsPlugin = require("@nodecloud/aws-plugin");
9998
const nodeCloudGcpPlugin = require("@nodecloud/gcp-plugin");
10099
const nodeCloudAzurePlugin = require("@nodecloud/azure-plugin");
100+
const nodeCloudDoPlugin = require("@nodecloud/do-plugin");
101101

102102
const providers = [
103103
{
@@ -120,6 +120,11 @@ const providers = [
120120
tag: "azure",
121121
plugin: nodeCloudAzurePlugin,
122122
},
123+
{
124+
name: "digitalocean",
125+
tag: "do",
126+
plugin: nodeCloudDoPlugin,
127+
},
123128
];
124129
module.exports = providers;
125130
```
@@ -198,18 +203,19 @@ const ncProviders = nodeCloud.getProviders(options);
198203
| ----------------------- | ----------------------------------- | :-----------------------------------: | :-------------------------------: | :---------------------------------------------------------------------: | :---------------------------------------: | :---------------------------------------------------: |
199204
| Compute | IaaS | EC2 | Compute Engine | Virtual Machine | Droplets | ECS |
200205
| | Faas | AWS Lambda\* | Cloud Functions\* | Azure Functions\* | - | Function Compute\* |
201-
| | Containers | ECS, EKS | Google Kubernetes Engine | AKS, Azure Service Fabric\* | DO Kubernetes\* | Container Service*, Container Service for Kubernetes* |
206+
| | Containers | ECS, EKS | Google Kubernetes Engine | AKS, Azure Service Fabric\* | DO Kubernetes | Container Service*, Container Service for Kubernetes* |
202207
| | Containers (without infrastructure) | AWS Fargate\* | Cloud Run\* | - | - | ECI\* |
203208
| | Paas | AWS Elastic Beanstalk | App Engine\* | App Service | - | Simple Application Server\* |
204209
| Storage | Object Storage | S3 | Cloud Storage | Azure Blob Storage | Spaces\* | Bucket (OSS) |
205210
| | Block Storage | EBS | Persistent Disks | Disk Storage | Volumes | NAS\* |
206211
| Networking | Load Balancer | ELB | Cloud Load Balancing\* | Azure Load Balancer | DO Load Balancer | SLB |
207212
| | Peering/Dedicated Interconnect | Direct Connect | Cloud Interconnect\* | ExpressRoute\* | - | Express Connect\* |
208-
| | DNS | Route53 | Google Domains, Cloud DNS | Azure DNS | DO DNS\* | Alibaba Cloud DNS\* |
209-
| Databases | RDBMS | RDS, Amazon Aurora*, Amazon Redshift* | Cloud SQL\*, Cloud Spanner | SQL Database, Azure Database for MySQL*, Azure Database for PostgreSQL* | Managed Databases(PostgreSQL* and MySQL*) | ApsaraDB (MySQL, MariaDB TX, SQL Server, PostgreSQL) |
213+
| | DNS | Route53 | Google Domains, Cloud DNS | Azure DNS | DO DNS | Alibaba Cloud DNS\* |
214+
| Databases | RDBMS | RDS, Amazon Aurora*, Amazon Redshift* | Cloud SQL\*, Cloud Spanner | SQL Database, Azure Database for MySQL*, Azure Database for PostgreSQL* | Managed Databases(PostgreSQL* and MySQL) | ApsaraDB (MySQL, MariaDB TX, SQL Server, PostgreSQL) |
210215
| | NoSQL: key-value | DynamoDB | Cloud Firestore, Cloud Bigtable\* | Table Storage | Managed Databases(Redis)\* | ApsaraDB for Redis\* |
211216
| | NoSQL: indexed | Amazon SimpleDB\* | Cloud Firestore | Cosmos DB | - | ApsaraDB for MongoDB\* |
212217
| Security/ Authorization | Identity Access Management | AWS IAM | Cloud IAM\* | Azure Active Directory*, Azure Role Based Access Control* | - | Resource Access Management\* |
218+
| Management | Key Management | AWS-KMS | - | - | Do-Keys | - |
213219

214220
\*yet to be implemented
215221

212 KB
Loading
11.3 MB
Loading
36.4 MB
Loading
1.55 MB
Loading

examples/compute/do-droplet.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const nodeCloud = require("../../lib/");
2+
const optionsProvider = {
3+
overrideProviders: false
4+
};
5+
const ncProviders = nodeCloud.getProviders(optionsProvider);
6+
7+
// get compute object for Digital Ocean
8+
const droplet = ncProviders.do.compute();
9+
10+
function launchInstance() {
11+
const instanceParams = {
12+
name: "digitalocean.fi",
13+
region: "nyc3",
14+
size: "s-1vcpu-1gb",
15+
image: "ubuntu-16-04-x64",
16+
ssh_keys: null,
17+
backups: false,
18+
ipv6: true,
19+
user_data: null,
20+
private_networking: null,
21+
volumes: null,
22+
tags: ["web"]
23+
};
24+
25+
// create DO Droplet instance
26+
droplet
27+
.create(instanceParams)
28+
.then(res => {
29+
console.log(`All done ! ${res}`);
30+
})
31+
.catch(err => {
32+
console.log(`Oops something happened ${err}`);
33+
});
34+
}
35+
36+
function listInstances() {
37+
droplet
38+
.list()
39+
.then(res => {
40+
console.log("Instances are" + res);
41+
})
42+
.catch(err => {
43+
console.log(`Oops something happened ${err}`);
44+
});
45+
}
46+
47+
function destroyInstance() {
48+
let instanceId = "3164444";
49+
droplet
50+
.destroy(instanceId)
51+
.then(res => {
52+
console.log("Output is" + res);
53+
})
54+
.catch(err => {
55+
console.log(`Oops something happened ${err}`);
56+
});
57+
}

examples/compute/do-ks.js

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
const nodeCloud = require("../../lib/");
2+
const optionsProvider = {
3+
overrideProviders: false
4+
};
5+
const ncProviders = nodeCloud.getProviders(optionsProvider);
6+
const kubernetes = ncProviders.do.kubernetes();
7+
8+
function createCluster() {
9+
let clusterDetails = {
10+
name: "Nodecloud",
11+
region: "nyc1",
12+
version: "1.18.6-do.0",
13+
node_pools: [
14+
{
15+
size: "s-1vcpu-2gb",
16+
count: 3,
17+
name: "worker-pool"
18+
}
19+
]
20+
};
21+
22+
kubernetes.create(clusterDetails).then(
23+
result => {
24+
console.log("Output :", result);
25+
},
26+
error => {
27+
console.error("Error :", error);
28+
}
29+
);
30+
}
31+
32+
function getClusterDetails() {
33+
let clusterID = "bd5f5959-5e1e-4205-a714-a914373942af";
34+
kubernetes.describeCluster(clusterID).then(
35+
result => {
36+
console.log("Output :", result);
37+
},
38+
error => {
39+
console.error("Error :", error);
40+
}
41+
);
42+
}
43+
44+
function getAllClusters() {
45+
/* The nextToken value returned from a previous ListClusters request where maxResults was used and the results
46+
exceeded the value of that parameter. Pagination continues from the end of the previous results that returned the
47+
nextToken value. The maximum number of clusters you can get through this request is 100, use the nextToken parameter
48+
to get the rest clusters using a another request*/
49+
const limitation = {
50+
maxResults: 20
51+
// nextToken: 'STRING_VALUE' -- optional
52+
};
53+
54+
// Limitation can be a empty empty object as well, where it will give 100 clusters max
55+
56+
kubernetes.listClusters(limitation).then(
57+
result => {
58+
console.log("Output :", result);
59+
},
60+
error => {
61+
console.error("Error :", error);
62+
}
63+
);
64+
}
65+
66+
function deleteCluster() {
67+
let clusterID = "bd5f5959-5e1e-4205-a714-a914373942af";
68+
kubernetes.deleteCluster(clusterID).then(
69+
result => {
70+
console.log("Output :", result);
71+
},
72+
error => {
73+
console.error("Error :", error);
74+
}
75+
);
76+
}
77+
78+
function createNodeGroup() {
79+
let groupDetails = {
80+
size: "s-1vcpu-2gb",
81+
count: 3,
82+
name: "new-pool",
83+
tags: ["frontend"],
84+
auto_scale: true,
85+
min_nodes: 3,
86+
max_nodes: 6
87+
};
88+
89+
kubernetes.createNodeGroup(clusterID, groupDetails).then(
90+
result => {
91+
console.log("Output :", result);
92+
},
93+
error => {
94+
console.error("Error :", error);
95+
}
96+
);
97+
}
98+
99+
function deleteNodeGroup() {
100+
let nodePoolID = "bd5f5959-5e1e-4205-a714-a914373942af";
101+
let clusterID = "bd5f5959-5e1e-4205-a714-a914373942af";
102+
kubernetes.deleteNodegroup(clusterID, nodePoolID).then(
103+
result => {
104+
console.log("Output :", result);
105+
},
106+
error => {
107+
console.error("Error :", error);
108+
}
109+
);
110+
}
111+
112+
function describeNodeGroup() {
113+
let nodePoolID = "bd5f5959-5e1e-4205-a714-a914373942af";
114+
let clusterID = "bd5f5959-5e1e-4205-a714-a914373942af";
115+
kubernetes.describeNodeGroup(clusterID, nodePoolID).then(
116+
result => {
117+
console.log("Output :", result);
118+
},
119+
error => {
120+
console.error("Error :", error);
121+
}
122+
);
123+
}
124+
125+
function listNodeGroups() {
126+
let clusterID = "bd5f5959-5e1e-4205-a714-a914373942af";
127+
kubernetes.listNodegroups(clusterID).then(
128+
result => {
129+
console.log("Output :", result);
130+
},
131+
error => {
132+
console.error("Error :", error);
133+
}
134+
);
135+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const nodeCloud = require("../../lib/");
2+
const optionsProvider = {
3+
overrideProviders: false
4+
};
5+
const ncProviders = nodeCloud.getProviders(optionsProvider);
6+
const keyManagement = ncProviders.do.keyManagement();
7+
8+
function createKey() {
9+
let options = {
10+
public_key:
11+
"ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
12+
name: "My SSH Public Key"
13+
};
14+
keyManagement
15+
.createKey(options)
16+
.then(res => {
17+
console.log("Output is" + res);
18+
})
19+
.catch(err => {
20+
console.log(`Oops something happened ${err}`);
21+
});
22+
}
23+
24+
function deleteKey() {
25+
let keyIdentifier = "512189";
26+
keyManagement
27+
.deleteKey(keyIdentifier)
28+
.then(res => {
29+
console.log("Output is" + res);
30+
})
31+
.catch(err => {
32+
console.log(`Oops something happened ${err}`);
33+
});
34+
}
35+
36+
function getKey() {
37+
let keyIdentifier = "512189";
38+
keyManagement
39+
.describeKey(keyIdentifier)
40+
.then(res => {
41+
console.log("Output is" + res);
42+
})
43+
.catch(err => {
44+
console.log(`Oops something happened ${err}`);
45+
});
46+
}
47+
48+
function getAllKeys() {
49+
keyManagement
50+
.list()
51+
.then(res => {
52+
console.log("Output is" + res);
53+
})
54+
.catch(err => {
55+
console.log(`Oops something happened ${err}`);
56+
});
57+
}

examples/network/do-dns.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
const nodeCloud = require("../../lib/");
2+
const optionsProvider = {
3+
overrideProviders: false
4+
};
5+
const ncProviders = nodeCloud.getProviders(optionsProvider);
6+
7+
const dns = ncProviders.do.dns();
8+
9+
const domainCreateOptions = {
10+
type: "A",
11+
name: "www",
12+
data: "162.10.66.0",
13+
priority: null,
14+
port: null,
15+
ttl: 1800,
16+
weight: null,
17+
flags: null,
18+
tag: null
19+
};
20+
21+
const domainName = "example.com";
22+
23+
function createRecord() {
24+
dns
25+
.createRecord(domainName, domainCreateOptions)
26+
.then(result => {
27+
console.log("Output is: ", result);
28+
})
29+
.catch(err => {
30+
console.log("Error is: ", err);
31+
});
32+
}
33+
34+
function getAllRecords() {
35+
dns
36+
.getRecords(domainName)
37+
.then(records => {
38+
console.log("Records are: ", records);
39+
})
40+
.catch(err => {
41+
console.log("Error is: ", err);
42+
});
43+
}
44+
45+
function getRecord() {
46+
let recordID = "3352896";
47+
dns
48+
.getRecord(domainName, recordID)
49+
.then(result => {
50+
console.log("Record are: ", result);
51+
})
52+
.catch(err => {
53+
console.log("Error is: ", err);
54+
});
55+
}
56+
57+
function deleteRecord() {
58+
let recordID = "3352896";
59+
dns
60+
.deleteRecord(domainName, recordID)
61+
.then(result => {
62+
console.log("Output is: ", result);
63+
})
64+
.catch(err => {
65+
console.log("Error is: ", err);
66+
});
67+
}
68+
69+
function changeRecord() {
70+
let recordID = "3352896";
71+
let options = {
72+
name: "blog",
73+
type: "CNAME"
74+
};
75+
changeRecordSets(domainName, recordID, options)
76+
.then(result => {
77+
console.log("Output is: ", result);
78+
})
79+
.catch(err => {
80+
console.log("Error is: ", err);
81+
});
82+
}

0 commit comments

Comments
 (0)