Skip to content

Commit

Permalink
Merge pull request #118 from PierreBeucher/az-disk
Browse files Browse the repository at this point in the history
move provider Pulumi clients and stack in their own folders
  • Loading branch information
PierreBeucher authored Jan 17, 2025
2 parents 6879980 + b9f49c2 commit 360f811
Show file tree
Hide file tree
Showing 15 changed files with 3,461 additions and 3,278 deletions.
16 changes: 16 additions & 0 deletions docs/src/contributing/development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Unit tests](#unit-tests)
- [Integration tests](#integration-tests)
- [Development](#development)
- [Local Pulumi stack manipulation](#local-pulumi-stack-manipulation)
- [Scripts](#scripts)
- [Adding a new provider](#adding-a-new-provider)
- [Provider components](#provider-components)
Expand Down Expand Up @@ -83,6 +84,21 @@ ansible-playbook -i /tmp/nix-shell.fD63LM/cloudypad-BX2kYb/inventory.yml ansible

Will eventually add an easier way to pass custom Ansible options such as `--ansible-additional-flag` option or environment variable.

### Local Pulumi stack manipulation

Nix development shell automatically set `PULUMI_BACKEND_URL` and `PULUMI_CONFIG_PASSPHRASE` environment variables, allowing to manipulate Pulumi stacks locally.

```sh
# List stacks
pulumi stack ls -a

# Show stack resources
pulumi stack -s <organization/CloudyPad-XXX/STACK> --show-ids

# Destroy stack
pulumi destroy -s <organization/CloudyPad-XXX/STACK>
```

### Scripts

## Adding a new provider
Expand Down
6,659 changes: 3,412 additions & 3,247 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@eslint/js": "^9.8.0",
"@eslint/js": "^9.18.0",
"@types/dockerode": "^3.3.30",
"@types/eslint__js": "^8.42.3",
"@types/inquirer": "^9.0.7",
Expand All @@ -26,11 +26,11 @@
"@types/sshpk": "^1.17.4",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^8.57.0",
"eslint": "^9.18.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"mocha": "^10.6.0",
"sinon": "^18.0.0",
"mocha": "^11.0.0",
"sinon": "^19.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.4",
"typescript-eslint": "^8.0.0"
Expand All @@ -40,24 +40,25 @@
"@aws-sdk/client-ec2": "^3.614.0",
"@aws-sdk/client-s3": "^3.614.0",
"@aws-sdk/client-service-quotas": "^3.726.0",
"@aws-sdk/client-sts": "^3.730.0",
"@aws-sdk/credential-providers": "^3.616.0",
"@aws-sdk/s3-request-presigner": "^3.614.0",
"@azure/arm-compute": "^22.0.0",
"@azure/arm-network": "^33.3.0",
"@azure/arm-quota": "^1.0.0",
"@azure/arm-subscriptions": "^5.1.0",
"@azure/identity": "^4.4.1",
"@commander-js/extra-typings": "^12.1.0",
"@commander-js/extra-typings": "^13.0.0",
"@google-cloud/compute": "^4.7.0",
"@google-cloud/resource-manager": "^5.3.0",
"@pulumi/aws": "^6.45.0",
"@pulumi/azure-native": "^2.52.0",
"@pulumi/gcp": "^7.34.0",
"@pulumi/gcp": "^8.0.0",
"@pulumi/pulumi": "^3.125.0",
"axios": "^1.7.2",
"commander": "^12.1.0",
"dockerode": "^3.3.0",
"inquirer": "^10.0.3",
"commander": "^13.0.0",
"dockerode": "^4.0.0",
"inquirer": "^12.0.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"node-ssh": "^13.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function buildProgram(){
program
.name('cloudypad')
.description('Cloudy Pad CLI to manage your own gaming instance in the Cloud.')
.option("--verbose, -v",
.option("-v, --verbose",
"Verbosity level (0: silly, 1: trace, 2: debug, 3: info, 4: warn, 5: error, 6: fatal). Alternatively, use CLOUDYPAD_LOG_LEVEL environment variable.",
(v) => { setLogVerbosity(Number.parseInt(v)) })
.configureHelp({ showGlobalOptions: true})
Expand Down
2 changes: 1 addition & 1 deletion src/providers/aws/provisioner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SshKeyLoader } from '../../tools/ssh';
import { confirm } from '@inquirer/prompts';
import { AwsPulumiClient, PulumiStackConfigAws } from '../../tools/pulumi/aws';
import { AwsPulumiClient, PulumiStackConfigAws } from './pulumi';
import { AbstractInstanceProvisioner, InstanceProvisionerArgs, InstanceProvisionOptions } from '../../core/provisioner';
import { AwsClient } from '../../tools/aws';
import { AwsProvisionInputV1, AwsProvisionOutputV1 } from './state';
Expand Down
2 changes: 1 addition & 1 deletion src/tools/pulumi/aws.ts → src/providers/aws/pulumi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";
import { OutputMap } from "@pulumi/pulumi/automation";
import { InstancePulumiClient } from "./client";
import { InstancePulumiClient } from "../../tools/pulumi/client";
import { PUBLIC_IP_TYPE, PUBLIC_IP_TYPE_DYNAMIC, PUBLIC_IP_TYPE_STATIC } from "../../core/const";

interface PortDefinition {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/azure/provisioner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SshKeyLoader } from '../../tools/ssh'
import { confirm } from '@inquirer/prompts'
import { AzurePulumiClient, PulumiStackConfigAzure } from '../../tools/pulumi/azure'
import { AzurePulumiClient, PulumiStackConfigAzure } from './pulumi'
import { AbstractInstanceProvisioner, InstanceProvisionerArgs, InstanceProvisionOptions } from '../../core/provisioner'
import { AzureClient } from '../../tools/azure'
import { AzureProvisionInputV1, AzureProvisionOutputV1 } from './state'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as az from "@pulumi/azure-native"
import * as pulumi from "@pulumi/pulumi"
import { InstancePulumiClient } from "./client"
import { InstancePulumiClient } from "../../tools/pulumi/client"
import { OutputMap } from "@pulumi/pulumi/automation"
import { PUBLIC_IP_TYPE, PUBLIC_IP_TYPE_STATIC } from "../../core/const"
import { CostAlertOptions } from "../../core/provisioner"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/pulumi/gcp.ts → src/providers/gcp/gcp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as gcp from "@pulumi/gcp"
import * as pulumi from "@pulumi/pulumi"
import { OutputMap } from "@pulumi/pulumi/automation"
import { InstancePulumiClient } from "./client"
import { InstancePulumiClient } from "../../tools/pulumi/client"
import { PUBLIC_IP_TYPE_DYNAMIC, PUBLIC_IP_TYPE_STATIC } from "../../core/const"
import { CostAlertOptions } from "../../core/provisioner"

Expand Down
2 changes: 1 addition & 1 deletion src/providers/gcp/provisioner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SshKeyLoader } from '../../tools/ssh';
import { confirm } from '@inquirer/prompts';
import { AbstractInstanceProvisioner, InstanceProvisionerArgs, InstanceProvisionOptions } from '../../core/provisioner';
import { GcpPulumiClient, PulumiStackConfigGcp } from '../../tools/pulumi/gcp';
import { GcpPulumiClient, PulumiStackConfigGcp } from './gcp';
import { GcpClient } from '../../tools/gcp';
import { GcpProvisionInputV1, GcpProvisionOutputV1} from './state';

Expand Down
6 changes: 3 additions & 3 deletions test/integ/pulumi/preview.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AwsPulumiClient } from "../../../src/tools/pulumi/aws"
import { AzurePulumiClient } from "../../../src/tools/pulumi/azure";
import { AwsPulumiClient } from "../../../src/providers/aws/pulumi"
import { AzurePulumiClient } from "../../../src/providers/azure/pulumi";
import { InstancePulumiClient } from "../../../src/tools/pulumi/client";
import { GcpPulumiClient } from "../../../src/tools/pulumi/gcp";
import { GcpPulumiClient } from "../../../src/providers/gcp/gcp";
import { awsInput, azureInput, gcpInput } from "./test-config.spec"

describe('Test Pulumi preview', function() {
Expand Down
7 changes: 4 additions & 3 deletions test/integ/pulumi/test-config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PUBLIC_IP_TYPE_STATIC } from "../../../src/core/const";
import { PulumiStackConfigAws } from "../../../src/tools/pulumi/aws"
import { PulumiStackConfigAzure } from "../../../src/tools/pulumi/azure";
import { PulumiStackConfigGcp } from "../../../src/tools/pulumi/gcp";
import { PulumiStackConfigAws } from "../../../src/providers/aws/pulumi"
import { PulumiStackConfigAzure } from "../../../src/providers/azure/pulumi";
import { AZURE_SUPPORTED_DISK_TYPES } from "../../../src/providers/azure/state";
import { PulumiStackConfigGcp } from "../../../src/providers/gcp/gcp";

// Test key, not used anywhere but here
const pubKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC0fvAW244z7LT8sE1g2Zl6mi5LL1V7Otw5ZfzF1Zsh+OufH+AbmkLOmrhtbUE7OmIQduDSXbttCGPocW6Va2vEeq0SIsn7ZjxdsIlwP7xCzDDwA6R29uCrgy4YLdJhz7FOhgI+n1td9JP8444I1+duaoOrOcihxHJZkqjh+GCc6bXrTsJ2fVCqZRGRG7nyMRpIJKfCFkNkSawF2wrX6BWKTkNolMLJUz9FZWPn3mtOWDaVVVrInSwzmqYf5f9gLC17rydH6YnMEIgHvCRJYh4Dpz3A2Sw6fogwWgNGtt4k25HcUX0kMY0KbRFAG4rSJrHScmQ5FA8fKyDcZB25cHd6/hT2435IKXnBT4Jjw96PNQQwI4PjTFBK8IMlUMEUC4B51cSmcLCV0ia69bDEltSjLv92BiZA/W6dFCg9b6DYprAIHeSESRHUwOJg2boFPVdVGyxJc7PNRNY4uBZxVILYdUDPEwfyM1kqW1aHhq5Is8TX69bNU4X9t5l5J53vYhk="
Expand Down
6 changes: 3 additions & 3 deletions test/integ/pulumi/up.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AwsPulumiClient } from "../../../src/tools/pulumi/aws"
import { AzurePulumiClient } from "../../../src/tools/pulumi/azure";
import { AwsPulumiClient } from "../../../src/providers/aws/pulumi"
import { AzurePulumiClient } from "../../../src/providers/azure/pulumi";
import { InstancePulumiClient } from "../../../src/tools/pulumi/client";
import { GcpPulumiClient } from "../../../src/tools/pulumi/gcp";
import { GcpPulumiClient } from "../../../src/providers/gcp/gcp";
import { awsInput, azureInput, gcpInput } from "./test-config.spec"

/**
Expand Down
6 changes: 3 additions & 3 deletions test/unit/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { mkdtempSync } from 'node:fs';
import { tmpdir } from 'node:os';
import sinon from 'sinon';
import path from 'path';
import { AwsPulumiClient } from '../../src/tools/pulumi/aws';
import { AwsPulumiClient } from '../../src/providers/aws/pulumi';
import { AnsibleClient } from '../../src/tools/ansible';
import { InstancePulumiClient } from '../../src/tools/pulumi/client';
import { AbstractInstanceRunner } from '../../src/core/runner';
import { AbstractInstanceProvisioner } from '../../src/core/provisioner';
import { AzurePulumiClient } from '../../src/tools/pulumi/azure';
import { GcpPulumiClient } from '../../src/tools/pulumi/gcp';
import { AzurePulumiClient } from '../../src/providers/azure/pulumi';
import { GcpPulumiClient } from '../../src/providers/gcp/gcp';
import { PaperspaceClient, PaperspaceMachine } from '../../src/providers/paperspace/client/client';
import { DUMMY_AWS_PULUMI_OUTPUT, DUMMY_AZURE_PULUMI_OUTPUT, DUMMY_GCP_PULUMI_OUTPUT, DUMMY_PAPERSPACE_MACHINE } from './utils';
import { DataRootDirManager } from '../../src/core/data-dir';
Expand Down
6 changes: 3 additions & 3 deletions test/unit/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { CommonInstanceInput, InstanceStateV1 } from "../../src/core/state/state
import path from "path"
import fs, { mkdtempSync } from "fs"
import yaml from 'js-yaml'
import { AwsPulumiOutput } from "../../src/tools/pulumi/aws";
import { AzurePulumiOutput } from "../../src/tools/pulumi/azure";
import { GcpPulumiOutput } from "../../src/tools/pulumi/gcp";
import { AwsPulumiOutput } from "../../src/providers/aws/pulumi";
import { AzurePulumiOutput } from "../../src/providers/azure/pulumi";
import { GcpPulumiOutput } from "../../src/providers/gcp/gcp";
import { PaperspaceMachine } from "../../src/providers/paperspace/client/client";
import { PUBLIC_IP_TYPE_STATIC } from "../../src/core/const";
import { tmpdir } from "os";
Expand Down

0 comments on commit 360f811

Please sign in to comment.