Skip to content

Commit b6eae0f

Browse files
authored
Merge pull request #107 from mbcse/do_documentation
Updated Documentation for Nodecloud and Generator
2 parents 2ded345 + d4d2d06 commit b6eae0f

File tree

6 files changed

+50
-7
lines changed

6 files changed

+50
-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

generator/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ GCP:
8282

8383
For the class-based SDKs there is a minor change in the `node-cloud.yml` to record the main class of an SDK. For the above scenario, it’s the DNS class.
8484

85+
* Digital Ocean
86+
87+
```
88+
DO:
89+
describeCluster: kubernetes.d.ts getById
90+
```
91+
92+
<p align="center">
93+
<img src="../assets/generator/high_level_diagrams/do.png" style="width:60%" />
94+
<img src="../assets/generator/high_level_diagrams/do_diagram.png" />
95+
</p>
96+
97+
8598
## Code parsers
8699

87100
This is the simplest part of the code generation tool. The SDK files are read from the relevant SDKs as specified in the `node-cloud.yml` file. Afterwards, it is converted to an **Abstract Syntax Tree**. Finally, the class declaration Node of that **Abstract Syntax Tree** is returned. This retured Node is another **Abstract Syntax Tree** since a class declaration itself is another **Abstract Syntax Tree**.
@@ -99,3 +112,27 @@ This is the most important part of the code generator tool. Currently, there are
99112
* `addIdentifiers`: In this transformation all the Identifier nodes are updated. After this transformation the code is logically compelete. All the neccessary code parts are added and finalized such as parameter names, parameter types, client names, class name, package names, SDK function names etc.
100113

101114
* `addComments`: This transformation aims to auto-generate the API documentation. All the comments are added to the structure required by `JSDoc`. The `@category` is used to categorize the generated classes depending on the cloud provider. This tag is from the `better-docs` template used with `JSDoc`.
115+
116+
## Understanding the directory structure of generator
117+
118+
The code generation component of nodecloud is present in generator folder. It is a separate workspace/module managed using lerna.
119+
120+
<p align="center">
121+
<img src="../assets/generator/high_level_diagrams/directory_structure_diagram.png" />
122+
</p>
123+
124+
## Understanding the code generator tool
125+
126+
The code generation tool is using typescript compiler api to extract and analyse cloud SDK's and then making the classes for nodelcloud out of it.
127+
The tool works in this flow:
128+
<p align="center">
129+
<img src="../assets/generator/high_level_diagrams/toolflow_diagram.png" />
130+
</p>
131+
132+
The entry point of nodecloud is the main.ts file which you provide to typescript to generate the js file and then run the same. Inside the main file we fetch services from YML file and one by one pass the SDK file path and service name to generator function.
133+
134+
Inside generator we first call the parser to get the needed class and extract functions, parameters,etc needed for building Nodecloud classes. All this data is then passed onto the
135+
transformer which transforms the dummy class into an working Nodecloud class for that specific service. All these classes are then written into the Js file.
136+
137+
## Running the code generation tool
138+
- To build classes run `tsc main && node main` or 'yarn run tool' if inside generator directory and `yarn run generator` if inside nodecloud directory.

0 commit comments

Comments
 (0)