### Setting Up Environment for Examples - Bash/Just Source: https://github.com/castai/pulumi-castai/blob/main/README.md This `just` command cleans the build artifacts and sets up the development environment for running the examples provided in the repository. It ensures necessary dependencies are built and installed. ```Bash just clean && just dev ``` -------------------------------- ### Run Pulumi Program - Resource Deployment - Bash Source: https://github.com/castai/pulumi-castai/blob/main/examples/go/README.md This command executes the Pulumi program defined in the Go code. `pulumi up` previews and deploys the infrastructure resources defined by the program to your cloud provider. It requires the Pulumi CLI to be installed and configured. ```bash pulumi up ``` -------------------------------- ### Run GCP Example - Go Program Execution - Bash Source: https://github.com/castai/pulumi-castai/blob/main/examples/go/README.md This command runs the main Go program and passes `gcp` as a command-line argument. This tells the program to specifically execute the code path related to the GCP GKE example configuration. ```bash go run . gcp ``` -------------------------------- ### Installing Published Go SDK - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command uses `go get` to install a specific published version (v0.1.62 in this example) of the Pulumi CASTAI Go SDK. Use this when you want to consume a released version of the provider in your Go project. ```Bash go get github.com/castai/pulumi-castai@v0.1.62 ``` -------------------------------- ### Initialize Go Modules - Go Project Setup - Bash Source: https://github.com/castai/pulumi-castai/blob/main/examples/go/README.md This command initializes the Go modules for the project. It is a standard step in Go development to manage dependencies. It should be run in the project directory containing the `go.mod` file. ```bash go mod tidy ``` -------------------------------- ### Quickly Installing Provider Plugin Binary - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command installs the Pulumi CASTAI provider plugin binary directly using the Pulumi CLI. It's a quick method to get the provider installed locally for testing without building the SDKs. ```Bash pulumi plugin install resource castai v$(cat version.txt) -f /path/to/pulumi-castai/bin/pulumi-resource-castai ``` -------------------------------- ### Run Azure Example - Go Program Execution - Bash Source: https://github.com/castai/pulumi-castai/blob/main/examples/go/README.md This command runs the main Go program and passes `azure` as a command-line argument. This tells the program to specifically execute the code path related to the Azure AKS example configuration. ```bash go run . azure ``` -------------------------------- ### Building and Installing Pulumi CASTAI Provider - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md These commands build the Pulumi CASTAI provider binary and all language SDKs from source, then install the provider locally. Running `make provider` compiles the binary, `make build_sdks` generates SDKs, and `make install_provider` integrates the provider with your local Pulumi setup using `PulumiPlugin.yaml`. ```Bash make provider # Build the provider binary make build_sdks # Build all SDKs make install_provider # Install the provider locally with PulumiPlugin.yaml ``` -------------------------------- ### Installing Python Dependencies with pip (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/examples/python/README.md Installs the necessary Python packages required by the examples, such as the CAST AI Pulumi provider and Pydantic, from the `requirements.txt` file. This command should be run after cloning the repository. ```bash pip install -r requirements.txt ``` -------------------------------- ### Run AWS Example - Go Program Execution - Bash Source: https://github.com/castai/pulumi-castai/blob/main/examples/go/README.md This command runs the main Go program and passes `aws` as a command-line argument. This tells the program to specifically execute the code path related to the AWS EKS example configuration. ```bash go run . aws ``` -------------------------------- ### Running Example Deployment with just - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md These commands utilize the `just` command runner to set up the environment and execute Pulumi examples for different cloud providers and languages. `just clean && just dev` prepares the local build, and subsequent `just run-*` commands deploy specific examples. ```Bash # Set up your environment just clean && just dev # Run TypeScript examples just run-typescript-gcp-example just run-typescript-aws-example just run-typescript-azure-example # Run Python examples just run-python-gcp-example just run-python-aws-example just run-python-azure-example # Run Go examples just run-go-gcp-example just run-go-aws-example just run-go-azure-example # Run all examples for a specific language just run-typescript-examples just run-python-examples just run-go-examples # Run all examples just run-all-language-examples ``` -------------------------------- ### Creating PulumiPlugin.yaml for Quick Install - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md These commands create the necessary directory structure and `PulumiPlugin.yaml` file required by Pulumi to recognize the manually installed provider plugin binary. This completes the quick installation process. ```Bash mkdir -p ~/.pulumi/plugins/resource-castai-v$(cat version.txt)/ cat > ~/.pulumi/plugins/resource-castai-v$(cat version.txt)/PulumiPlugin.yaml << EOF resource: true name: castai version: $(cat version.txt) server: pulumi-resource-castai EOF ``` -------------------------------- ### Install Dependencies npm Source: https://github.com/castai/pulumi-castai/blob/main/examples/typescript/README.md Installs the necessary Node.js dependencies for the Pulumi TypeScript examples using npm. This command must be run before using the examples to ensure all required packages are available. ```bash npm install ``` -------------------------------- ### Installing Go SDK Package (Go) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Uses the Go module system's `go get` command to download and install the published Go SDK for the specified new version from its Git repository. This command verifies that the Go module is available and installable after publication. ```go go get github.com/castai/pulumi-castai/sdk/go/castai@v ``` -------------------------------- ### Installing CAST AI Pulumi Go SDK with Go Get Source: https://github.com/castai/pulumi-castai/blob/main/sdk/go/castai/README.md This snippet provides the command to install the CAST AI Pulumi Go SDK using the Go module system. It specifies the exact version `v0.1.71` to fetch. This command adds the SDK as a dependency to your Go project, requiring the Go toolchain to be installed. ```Bash go get github.com/castai/pulumi-castai/sdk/go/castai@v0.1.71 ``` -------------------------------- ### Installing CAST AI Pulumi Provider Locally (Pulumi CLI) Source: https://github.com/castai/pulumi-castai/blob/main/MULTI_ARCH_SUPPORT.md Command using the Pulumi CLI to install the CAST AI Pulumi resource provider plugin from a locally built binary file. The example installs version 0.1.13 located at `./bin/pulumi-resource-castai`. ```bash pulumi plugin install resource castai 0.1.13 --file ./bin/pulumi-resource-castai ``` -------------------------------- ### Running All Language Examples - Bash/Just Source: https://github.com/castai/pulumi-castai/blob/main/README.md This `just` command executes all provided examples across all supported programming languages (TypeScript, Python, Go). It's a convenient way to test the provider functionality comprehensively. ```Bash just run-all-language-examples ``` -------------------------------- ### Installing CAST AI Pulumi Provider for Specific Architecture (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/MULTI_ARCH_SUPPORT.md Command using the `just` tool to install the CAST AI Pulumi provider binary for a specific GOOS (operating system) and GOARCH (architecture) using definitions in the project's justfile. The example installs for darwin (macOS) arm64. ```bash just install-provider-arch darwin arm64 ``` -------------------------------- ### Installing CAST AI Pulumi Go SDK - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/go/README.md Execute this command in your terminal to download and install the specific version (v0.1.71) of the CAST AI Pulumi Provider Go SDK using the `go get` tool. This makes the package available in your local Go modules cache for use in Pulumi programs written in Go. ```bash go get github.com/castai/pulumi-castai/sdk/go/castai@v0.1.71 ``` -------------------------------- ### Building & Installing Provider/SDKs from Source - Bash/Makefile Source: https://github.com/castai/pulumi-castai/blob/main/README.md These commands build the Pulumi CASTAI provider binary, build all language SDKs, and install the provider locally for use with the Pulumi CLI. This process requires Go 1.18+ and Node.js 14+ or Python 3.7+ depending on which SDKs you intend to use. ```Bash make provider # Build the provider binary ``` ```Bash make build_sdks # Build all SDKs ``` ```Bash make install_provider # Install the provider locally with PulumiPlugin.yaml ``` -------------------------------- ### Executing Pulumi Go Azure Example using Just Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command utilizes the `just` command runner to execute a predefined script for running a Pulumi example targeting Azure resources using the Go language. It requires the `just` tool and a correctly configured Pulumi environment for the Go Azure example. ```Bash just run-go-azure-example ``` -------------------------------- ### Running Go Examples (Shell) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Uses the 'just' command runner to execute the integration tests and examples written in Go. This command verifies that the Go SDK works correctly against a real or simulated environment. ```shell just run-go-examples ``` -------------------------------- ### Running Examples for Specific Languages - Bash/Just Source: https://github.com/castai/pulumi-castai/blob/main/README.md These `just` commands execute the provided examples for connecting different cloud provider clusters (GCP, AWS, Azure) using a specific programming language SDK (TypeScript, Python, or Go). Requires appropriate cloud credentials and the CAST AI provider configured. ```Bash just run-typescript-examples ``` ```Bash just run-python-examples ``` ```Bash just run-go-examples ``` -------------------------------- ### Installing CAST AI Pulumi Provider from GitHub Releases (Pulumi CLI) Source: https://github.com/castai/pulumi-castai/blob/main/MULTI_ARCH_SUPPORT.md Command using the Pulumi CLI to install the CAST AI Pulumi resource provider plugin directly from a GitHub repository's releases. The example installs version 0.1.13 from the specified CAST AI pulumi-castai repository. ```bash pulumi plugin install resource castai 0.1.13 --server github://api.github.com/castai/pulumi-castai ``` -------------------------------- ### Installing Published Go SDK - Bash Source: https://github.com/castai/pulumi-castai/blob/main/README.md This command installs a specific published version of the Go SDK using the Go module system. Use this method if you are not building the provider from source. ```Bash go get github.com/castai/pulumi-castai@v0.1.71 ``` -------------------------------- ### Quickly Installing Pulumi Plugin - Bash/YAML Source: https://github.com/castai/pulumi-castai/blob/main/README.md These commands provide a quick way to install only the Pulumi plugin binary for testing. They copy the binary to the correct Pulumi plugins directory and create the necessary PulumiPlugin.yaml metadata file. ```Bash pulumi plugin install resource castai v$(cat version.txt) -f /path/to/pulumi-castai/bin/pulumi-resource-castai ``` ```Bash mkdir -p ~/.pulumi/plugins/resource-castai-v$(cat version.txt)/ ``` ```Bash cat > ~/.pulumi/plugins/resource-castai-v$(cat version.txt)/PulumiPlugin.yaml << EOF resource: true name: castai version: $(cat version.txt) server: pulumi-resource-castai EOF ``` -------------------------------- ### Set CAST AI API Token - Environment Variable - Bash Source: https://github.com/castai/pulumi-castai/blob/main/examples/go/README.md This command sets the `CASTAI_API_TOKEN` environment variable, which is required for the Pulumi CAST AI provider to authenticate with the CAST AI API. Replace `your-api-token` with your actual token obtained from the CAST AI documentation. ```bash export CASTAI_API_TOKEN=your-api-token ``` -------------------------------- ### Installing Python SDK from Source - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command installs the Python SDK for the Pulumi CASTAI provider directly from the local source directory using `pip`. The `-e` flag installs it in 'editable' mode, which is useful for development as changes in the source are reflected without reinstallation. ```Bash pip install -e ./sdk/python/ ``` -------------------------------- ### Installing Node.js SDK from Source - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md These commands demonstrate two ways to install the Node.js (TypeScript/JavaScript) SDK from a local source directory. `yarn link` creates a symlink for development, while `npm install` directly installs the package from the specified local path. ```Bash yarn link ./sdk/nodejs/ # OR in your project: npm install ../path/to/pulumi-castai/sdk/nodejs ``` -------------------------------- ### Publishing NPM Package from Node.js SDK Directory (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/NPM_PUBLISHING.md These commands navigate to the 'sdk/nodejs' directory containing the package files and then execute 'npm publish'. This command uploads the current version of the package to the configured npm registry, making it available for others to install. Authentication with npm is required. ```Bash cd sdk/nodejs npm publish ``` -------------------------------- ### Running Python Examples (Shell) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Uses the 'just' command runner to execute the integration tests and examples written in Python. This command verifies that the Python SDK works correctly against a real or simulated environment. ```shell just run-python-examples ``` -------------------------------- ### Running TypeScript Examples (Shell) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Uses the 'just' command runner to execute the integration tests and examples written in TypeScript. This verifies that the TypeScript SDK works correctly against a real or simulated environment. ```shell just run-typescript-examples ``` -------------------------------- ### Deploying Default Pulumi Stack (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/examples/python/README.md Executes the Pulumi program in the current directory, typically the basic example in `__main__.py`, to preview and provision the infrastructure resources defined within it. This command initiates the Pulumi deployment process. ```bash pulumi up ``` -------------------------------- ### Installing npm Package (npm) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Uses the Node.js package manager (`npm install`) to download and install the published @pulumi/castai package from the npm registry. This command verifies successful publication and installability for TypeScript/JavaScript projects. ```npm npm install @pulumi/castai ``` -------------------------------- ### Installing PyPI Package (pip) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Uses the Python package manager (`pip install`) to download and install the published pulumi-castai package from the Python Package Index (PyPI). This command verifies successful publication and installability for Python projects. ```pip pip install pulumi-castai ``` -------------------------------- ### Installing Python SDK Locally - Bash Source: https://github.com/castai/pulumi-castai/blob/main/README.md This command installs the Python SDK locally from the source directory using pip. This is necessary if you plan to use the Pulumi CASTAI provider with Python and have built the SDKs from source. ```Bash pip install -e ./sdk/python/ ``` -------------------------------- ### Running End-to-End Tests Setup - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md These commands use the `just` command runner to prepare the environment for running end-to-end tests. `just clean && just dev` ensures the latest provider and SDKs are built and ready. ```Bash # Set up your environment just clean && just dev ``` -------------------------------- ### Installing CAST AI Agent Manually with Helm (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md Provides shell commands to install the CAST AI agent using its Helm chart. This involves adding the CAST AI Helm repository, updating it, and installing the chart while specifying necessary parameters like the API key, cluster ID, namespace, and optionally setting read-only mode. This is an alternative to the Pulumi provider's agent installation. ```Bash helm repo add castai-helm https://castai.github.io/helm-charts helm repo update helm install castai-agent castai-helm/castai-agent \ --namespace castai-agent \ --create-namespace \ --set apiKey= \ --set clusterID= \ --set readOnlyMode=true # for read-only mode ``` -------------------------------- ### Installing CAST AI Pulumi Provider for Current Architecture (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/MULTI_ARCH_SUPPORT.md Command using the `just` tool to install the CAST AI Pulumi provider binary for the current system's detected GOOS (operating system) and GOARCH (architecture) using definitions in the project's justfile. ```bash just install-provider-current-arch ``` -------------------------------- ### Deploying Azure Pulumi Example Stack (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/examples/python/README.md Runs the specific Pulumi program located in the `azure_example.py` file to deploy the infrastructure for connecting an Azure AKS cluster to CAST AI. The `-C` flag directs Pulumi to use this specific file. ```bash pulumi up -C azure_example.py ``` -------------------------------- ### Installing Node.js SDK Locally - Bash/Yarn/npm Source: https://github.com/castai/pulumi-castai/blob/main/README.md These commands show how to install the Node.js (TypeScript/JavaScript) SDK locally from the source directory using yarn or npm. This is required if you plan to use the provider with Node.js and have built the SDKs from source. ```Bash yarn link ./sdk/nodejs/ ``` ```Bash npm install ../path/to/pulumi-castai/sdk/nodejs ``` -------------------------------- ### Publishing Python SDK (PyPI) Source: https://github.com/castai/pulumi-castai/blob/main/PUBLISHING.md Changes directory to the Python SDK source (`cd sdk/python`), installs necessary build and upload tools (`pip install build twine`), builds the Python distribution packages (`python -m build`), and finally uploads the packages from the `dist/` directory to PyPI using `twine`. Requires the Python SDK to be built, Python and pip installed, and `twine` configured with PyPI authentication (typically via `PYPI_PASSWORD`). ```Bash cd sdk/python pip install build twine python -m build twine upload dist/* ``` -------------------------------- ### Deploying GCP Pulumi Example Stack (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/examples/python/README.md Runs the specific Pulumi program located in the `gcp_example.py` file to deploy the infrastructure for connecting a GCP GKE cluster to CAST AI. The `-C` flag directs Pulumi to use this specific file. ```bash pulumi up -C gcp_example.py ``` -------------------------------- ### Installing Pulumi Provider Locally - Bash Source: https://github.com/castai/pulumi-castai/blob/main/CONTRIBUTING.md This command executes the `make install_provider` target, which installs the newly built provider binary and generated SDKs into the local Pulumi plugin directory. This makes the updated provider available for testing in local Pulumi projects. Requires the provider binary and generated SDKs. ```bash make install_provider ``` -------------------------------- ### Installing CAST AI Agent with Helm for Missing Namespace (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command block provides the necessary steps to install the CAST AI agent using Helm, specifically to address a missing agent namespace after the cluster has been registered with CAST AI via Pulumi. It includes adding the Helm repo, updating it, and installing the agent chart with critical configuration like API key and cluster ID. ```Bash # Add the CAST AI Helm repository helm repo add castai-helm https://castai.github.io/helm-charts helm repo update # Install the CAST AI agent helm install castai-agent castai-helm/castai-agent \ --namespace castai-agent \ --create-namespace \ --set apiKey= \ --set clusterID= ``` -------------------------------- ### Installing CAST AI Agent Manually (Default Mode) (Bash/Helm) Source: https://github.com/castai/pulumi-castai/blob/main/README.md This snippet provides Helm commands to manually install the CAST AI agent in the default mode (full access). This is necessary after connecting a cluster via Pulumi as the provider only registers the cluster, not installs the agent. It requires Helm and cluster access. ```bash # Add the CAST AI Helm repository helm repo add castai-helm https://castai.github.io/helm-charts helm repo update # Install the CAST AI agent helm install castai-agent castai-helm/castai-agent \ --namespace castai-agent \ --create-namespace \ --set apiKey= \ --set clusterID= ``` -------------------------------- ### Installing CAST AI Agent Manually (Read-Only Mode) (Bash/Helm) Source: https://github.com/castai/pulumi-castai/blob/main/README.md This snippet provides Helm commands to manually install the CAST AI agent in read-only mode. This is useful if the Pulumi provider fails to install the agent. It requires Helm to be installed and configured to access the target Kubernetes cluster. ```bash helm repo add castai-helm https://castai.github.io/helm-charts helm repo update helm install castai-agent castai-helm/castai-agent \ --namespace castai-agent \ --create-namespace \ --set apiKey= \ --set clusterID= \ --set readOnlyMode=true # for read-only mode ``` -------------------------------- ### Deploying AWS Pulumi Example Stack (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/examples/python/README.md Runs the specific Pulumi program located in the `aws_example.py` file to deploy the infrastructure for connecting an AWS EKS cluster to CAST AI. The `-C` flag directs Pulumi to use this specific file. ```bash pulumi up -C aws_example.py ``` -------------------------------- ### Configuring CAST AI Agent Installation Mode (TypeScript) Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This TypeScript code snippet demonstrates how to configure the CAST AI agent's installation mode when defining a `castai.GkeCluster` resource within a Pulumi program. It shows how to set `agentMode` to 'read-only' or 'full-access' and optionally disable agent installation entirely using `installAgent: false`. Requires the `@pulumi/castai` SDK. ```TypeScript const gkeCluster = new castai.GkeCluster("gke-cluster-connection", { // ... other properties agentMode: "read-only", // or "full-access" installAgent: true, // set to false to skip agent installation }); ``` -------------------------------- ### Set Pulumi Entrypoint YAML Source: https://github.com/castai/pulumi-castai/blob/main/examples/typescript/README.md Configures the main entry point file for the Pulumi program within the `Pulumi.yaml` project file. This tells Pulumi which TypeScript file contains the infrastructure code to be deployed for a specific example. ```yaml # In Pulumi.yaml main: aws-example.ts ``` -------------------------------- ### Building Provider and SDKs (Make) Source: https://github.com/castai/pulumi-castai/blob/main/PUBLISHING.md Executes Make targets to build the Pulumi provider executable (`make provider`) and then build the SDKs for all supported languages (`make build_sdks`). This command requires Make to be installed and a `Makefile` with defined targets. It compiles the necessary components for publishing. ```Make make provider make build_sdks ``` -------------------------------- ### Updating Pulumi CAST AI SDK with go get (Go) Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command updates the Go module for the Pulumi CAST AI provider using `go get`. It is used to ensure the Pulumi CAST AI SDK for Go is up to date, which can resolve namespace or module not found errors. ```Bash go get -u github.com/castai/pulumi-castai@latest ``` -------------------------------- ### Deploy Pulumi Stack bash Source: https://github.com/castai/pulumi-castai/blob/main/examples/typescript/README.md Executes the Pulumi program defined in the project's main file, provisioning or updating the resources (like connecting a cluster to CAST AI and setting up autoscaling) according to the configuration and code. ```bash pulumi up ``` -------------------------------- ### Publishing .NET SDK (NuGet) Source: https://github.com/castai/pulumi-castai/blob/main/PUBLISHING.md Changes directory to the .NET SDK source (`cd sdk/dotnet`), packs the project into a NuGet package (`dotnet pack -c Release`), and then pushes the generated `.nupkg` file from the `bin/Release/` directory to the NuGet gallery using the `dotnet nuget push` command. Requires the .NET SDK to be built, the .NET SDK CLI tools installed, and a NuGet API key for authentication. Input includes the API key. ```Bash cd sdk/dotnet dotnet pack -c Release dotnet nuget push bin/Release/*.nupkg --api-key --source https://api.nuget.org/v3/index.json ``` -------------------------------- ### Cloning Pulumi CASTAI Provider Repository - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command clones the Pulumi CASTAI provider source code repository from GitHub. It's the first step required for building the provider or its SDKs from source. Execute this in your terminal to get the local copy of the project. ```Bash git clone https://github.com/castai/pulumi-castai.git cd pulumi-castai ``` -------------------------------- ### Building CAST AI Pulumi Provider for Specific Architecture (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/MULTI_ARCH_SUPPORT.md Command using a provided script to build the CAST AI Pulumi provider binary for a specific version, GOOS (operating system), and GOARCH (architecture). The example builds version 0.1.13 for darwin (macOS) arm64. ```bash ./scripts/build-provider-binary.sh 0.1.13 darwin arm64 ``` -------------------------------- ### Adding NuGet Package (.NET) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Uses the .NET CLI (`dotnet add package`) to add the published Pulumi.CastAI package from NuGet to a .NET project. This command verifies successful publication and installability for .NET projects. ```dotnet dotnet add package Pulumi.CastAI ``` -------------------------------- ### Ensuring package.json Version Match (JSON) Source: https://github.com/castai/pulumi-castai/blob/main/NPM_PUBLISHING.md This JSON snippet illustrates the 'version' field in package.json. It's crucial that the version specified here matches the version recorded in the project's version.txt file to maintain consistency across the project and the published package. ```JSON "version": "0.1.15" ``` -------------------------------- ### Defining CAST AI EKS Cluster Config with Pydantic (Python) Source: https://github.com/castai/pulumi-castai/blob/main/examples/python/README.md Demonstrates the use of Pydantic models for strongly typing resource configurations. An `EksClusterConfig` object is created with validation, and its validated dictionary representation is used as keyword arguments for the Pulumi `castai.EksCluster` resource. ```python from models import EksClusterConfig # Create a typed configuration config = EksClusterConfig( account_id="123456789012", region="us-west-2", eks_cluster_name="my-cluster", delete_nodes_on_disconnect=True ) # Convert to keyword arguments for Pulumi resource args = config.dict(exclude_none=True) cluster = castai.EksCluster("my-cluster", **args) ``` -------------------------------- ### Updating Pulumi CAST AI SDK with pip (Python) Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command updates the `pulumi_castai` package using the Python package installer (pip). It is used to ensure the Pulumi CAST AI SDK for Python is up to date, which can resolve namespace or module not found errors. ```Bash pip install --upgrade pulumi_castai ``` -------------------------------- ### Committing and Pushing Version Changes (Git Bash) Source: https://github.com/castai/pulumi-castai/blob/main/PUBLISHING.md Stages all local changes (`git add .`), commits them with a standardized message including the new version (`git commit -m "..."`), and pushes the commit to the `main` branch of the remote repository (`git push origin main`). Requires Git to be installed and configured for the repository. Input is the new version number used in the commit message. ```Bash git add . git commit -m "Prepare release v" git push origin main ``` -------------------------------- ### Publishing Node.js SDK (npm) Source: https://github.com/castai/pulumi-castai/blob/main/PUBLISHING.md Changes directory to the Node.js SDK source (`cd sdk/nodejs`) and then executes the `npm publish` command with the `--access public` flag to publish the package to the public npm registry. Requires the Node.js SDK to be built, `npm` installed and configured with authentication (typically via `NPM_TOKEN`), and access to the npm registry. ```Bash cd sdk/nodejs npm publish --access public ``` -------------------------------- ### Setting CAST AI API Token Environment Variable (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/examples/python/README.md Configures the CAST AI API token as an environment variable named `CASTAI_API_TOKEN`. The Pulumi CAST AI provider uses this variable for authentication. Replace `your-api-token` with your actual token obtained from the CAST AI console. ```bash export CASTAI_API_TOKEN=your-api-token ``` -------------------------------- ### Configure CAST AI API Token bash Source: https://github.com/castai/pulumi-castai/blob/main/examples/typescript/README.md Sets the CAST AI API token as an environment variable, which is required for the Pulumi provider to authenticate with the CAST AI API. Replace 'your-api-token' with your actual token obtained from CAST AI documentation. ```bash export CASTAI_API_TOKEN=your-api-token ``` -------------------------------- ### Configuring GKE Cluster Connection with Agent Mode (TypeScript) Source: https://github.com/castai/pulumi-castai/blob/main/README.md This TypeScript snippet demonstrates how to configure a GKE cluster connection resource using the Pulumi CAST AI provider, specifying the `agentMode` (e.g., 'read-only') and whether to attempt agent installation (`installAgent`). It requires the `@pulumi/castai` SDK. ```typescript const gkeCluster = new castai.GkeCluster("gke-cluster-connection", { // ... other properties agentMode: "read-only", // or "full-access" installAgent: true // set to false to skip agent installation }); ``` -------------------------------- ### Correcting package.json Repository Field (JSON) Source: https://github.com/castai/pulumi-castai/blob/main/NPM_PUBLISHING.md This JSON snippet shows the correct structure for the 'repository' field in package.json. npm expects this field to be an object with 'type' and 'url' properties, rather than a simple string, which helps resolve publishing warnings. ```JSON "repository": { "type": "git", "url": "https://github.com/castai/pulumi-castai.git" } ``` -------------------------------- ### Fixing NPM Package using Just Command (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/NPM_PUBLISHING.md This command uses the 'just' command runner to execute a predefined task named 'fix-npm-package'. Without arguments, it automatically corrects the repository field in package.json and syncs the package version with the content of version.txt. ```Bash just fix-npm-package ``` -------------------------------- ### Setting NPM Package Version using Just Command (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/NPM_PUBLISHING.md This command uses the 'just' runner to execute 'fix-npm-package' with a specific version number as an argument. This updates both version.txt and the package.json version field to the specified value (e.g., 0.2.0), in addition to performing other fixes. ```Bash just fix-npm-package 0.2.0 ``` -------------------------------- ### Running npm pkg fix in Node.js SDK Directory (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/NPM_PUBLISHING.md This sequence of commands first changes the current directory to the 'sdk/nodejs' folder where the package.json resides. It then runs 'npm pkg fix', an npm command that attempts to automatically correct various inconsistencies and issues within the package.json file. ```Bash cd sdk/nodejs npm pkg fix ``` -------------------------------- ### Removing Pulumi Stack Lock Files (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command chain finds and removes any stack lock files (`.json` files) within the `~/.pulumi/locks` directory. These locks can prevent new Pulumi operations from starting if a previous run terminated unexpectedly. Use with caution as it bypasses Pulumi's built-in locking. ```Bash find ~/.pulumi/locks -name "*.json" | xargs rm -f ``` -------------------------------- ### Creating Release Archives (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/PUBLISHING.md Reads the version from `version.txt`, creates a `release/` directory, and then iterates through architectures (`amd64`, `arm64`) and operating systems (`darwin`, `linux`, `windows`). It packages the appropriate provider executable (`pulumi-resource-castai` or `pulumi-resource-castai.exe`) from the `bin/` directory into a gzipped tar archive within the `release/` directory, naming the file according to a standard convention. Requires a `version.txt` file, the built provider binaries in `bin/`, and standard Unix tools. ```Bash VERSION=$(cat version.txt) mkdir -p release/ for ARCH in amd64 arm64; do for OS in darwin linux windows; do FILENAME=pulumi-resource-castai-v${VERSION}-${OS}-${ARCH}.tar.gz if [ "$OS" = "windows" ]; then tar -czf release/${FILENAME} -C bin pulumi-resource-castai.exe else tar -czf release/${FILENAME} -C bin pulumi-resource-castai fi done done ``` -------------------------------- ### Setting Up Environment for End-to-End Tests - Bash/Just Source: https://github.com/castai/pulumi-castai/blob/main/README.md This command cleans the project and sets up the development environment, including building the provider and SDKs. It's a prerequisite for running the end-to-end tests that interact with real cloud resources. ```Bash just clean && just dev ``` -------------------------------- ### Creating PulumiPlugin.yaml Manually (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/README.md This snippet provides a Bash script to manually create the `PulumiPlugin.yaml` file and copy the provider binary, resolving the `failed to load plugin: loading PulumiPlugin.yaml: no such file or directory` error. It requires the provider binary and the `version.txt` file to exist at specified paths. ```bash # Get the version from version.txt VERSION=$(cat version.txt) # Create the file for the current version mkdir -p ~/.pulumi/plugins/resource-castai-v${VERSION} echo "resource: true" > ~/.pulumi/plugins/resource-castai-v${VERSION}/PulumiPlugin.yaml echo "name: castai" >> ~/.pulumi/plugins/resource-castai-v${VERSION}/PulumiPlugin.yaml echo "version: ${VERSION}" >> ~/.pulumi/plugins/resource-castai-v${VERSION}/PulumiPlugin.yaml echo "server: pulumi-resource-castai" >> ~/.pulumi/plugins/resource-castai-v${VERSION}/PulumiPlugin.yaml # Copy the provider binary cp /path/to/pulumi-castai/bin/pulumi-resource-castai ~/.pulumi/plugins/resource-castai-v${VERSION}/ ``` -------------------------------- ### Preparing Release using Script - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This command runs the `./scripts/prepare_release.sh` script, which automates the steps required to prepare a new version for release. Options like `--dry-run` and `--skip-build` are available for testing and troubleshooting. ```Bash # For a real release: ./scripts/prepare_release.sh # To test the script without making any changes (dry run): ./scripts/prepare_release.sh --dry-run # To skip build steps (useful if you're having build issues): ./scripts/prepare_release.sh --skip-build # You can combine options: ./scripts/prepare_release.sh --dry-run --skip-build ``` -------------------------------- ### Preparing Pulumi CAST AI Provider Release (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/scripts/README.md This snippet demonstrates how to use the `prepare_release.sh` script to automate pre-release steps for the Pulumi CAST AI provider, including version updates, dependency management, building the provider and SDKs, and committing changes. It shows options for a standard run, dry run testing, and skipping build steps. ```bash # For a real release: ./scripts/prepare_release.sh # To test the script without making any changes (dry run): ./scripts/prepare_release.sh --dry-run # To skip build steps (useful if you're having build issues): ./scripts/prepare_release.sh --skip-build # You can combine options: ./scripts/prepare_release.sh --dry-run --skip-build ``` -------------------------------- ### Preparing Provider Release - Bash Source: https://github.com/castai/pulumi-castai/blob/main/README.md These commands use a helper script to prepare a new provider version for release. The script handles committing changes, creating tags, and optionally pushing to trigger the CI/CD pipeline for publishing. ```Bash ./scripts/prepare_release.sh ``` ```Bash ./scripts/prepare_release.sh --dry-run ``` ```Bash ./scripts/prepare_release.sh --skip-build ``` ```Bash ./scripts/prepare_release.sh --dry-run --skip-build ``` -------------------------------- ### Building CAST AI Pulumi Provider for All Architectures (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/MULTI_ARCH_SUPPORT.md Command using the `just` tool to build the CAST AI Pulumi provider binary for all supported architectures defined in the project's justfile. This process generates binaries and packages them as release assets. ```bash just build-provider-all-archs ``` -------------------------------- ### Manually Triggering Go Package Indexing (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/scripts/README.md This snippet shows how to manually trigger the indexing of the Pulumi CAST AI provider's Go SDK on pkg.go.dev using the `trigger_pkggodev_indexing.sh` script. It accepts an optional version argument; if omitted, it uses the version from `version.txt`. ```bash ./scripts/trigger_pkggodev_indexing.sh [VERSION] ``` -------------------------------- ### Building Provider Binary (Make) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Runs the 'provider' make target to compile the main Pulumi provider executable for CAST AI. This command uses the Makefile to orchestrate the build process, producing the binary required for packaging the provider. ```make make provider ``` -------------------------------- ### Building All SDKs (Make) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Executes the 'build_sdks' make target to generate language-specific SDKs for TypeScript, Python, Go, and .NET. This command prepares the language-specific packages for distribution to respective package managers. ```make make build_sdks ``` -------------------------------- ### Generating Pulumi Provider SDKs - Bash Source: https://github.com/castai/pulumi-castai/blob/main/CONTRIBUTING.md This command runs the `make build_sdks` target to generate the SDKs for the supported Pulumi languages (TypeScript, Python, Go, C#) based on the provider schema. This step follows building the provider binary. Requires the provider binary and a `Makefile`. ```bash make build_sdks ``` -------------------------------- ### Publishing Go Package (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/scripts/README.md This snippet illustrates the usage of the `publish_go_package.sh` script, which is responsible for preparing and publishing the Go SDK package for the Pulumi CAST AI provider. It requires the specific version number as a mandatory argument. ```bash ./scripts/publish_go_package.sh VERSION ``` -------------------------------- ### Building Pulumi Provider Binary - Bash Source: https://github.com/castai/pulumi-castai/blob/main/CONTRIBUTING.md This command executes the `make provider` target, which is responsible for compiling and building the Pulumi provider binary for the CAST AI service. This is typically the first step in the development workflow after cloning the repository. Requires a `Makefile` in the project root. ```bash make provider ``` -------------------------------- ### Committing Release Preparation (Git/Shell) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Stages all modified or new files (`git add .`) and creates a commit (`git commit -m "..."`) with a standardized message indicating the prepared release version. This saves the state of the repository before tagging. ```shell git add . && git commit -m "Prepare release v" ``` -------------------------------- ### Tagging and Pushing Release (Git/Shell) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Creates a lightweight Git tag corresponding to the new release version (`git tag v`) and immediately pushes this tag to the remote `origin` repository. This action typically triggers release workflows on platforms like GitHub. ```shell git tag v && git push origin v ``` -------------------------------- ### Creating and Pushing Git Tag (Git Bash) Source: https://github.com/castai/pulumi-castai/blob/main/PUBLISHING.md Creates an annotated Git tag locally with the format `v` at the current commit (`git tag v`), and then pushes this specific tag to the remote `origin` (`git push origin v`). This action typically triggers the GitHub Actions workflow for publishing. Requires Git. Input is the new version number. ```Bash git tag v git push origin v ``` -------------------------------- ### Manually Fixing Missing Pulumi Plugin YAML (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md Provides a series of manual shell commands to create the required directory structure, generate the `PulumiPlugin.yaml` file with the correct metadata (name, version, server), and copy the Pulumi CAST AI provider binary into the designated plugins directory. This serves as an alternative to running the automated fix script. ```Bash # Get the version from version.txt VERSION=$(cat version.txt) # Create the file for the current version mkdir -p ~/.pulumi/plugins/resource-castai-v${VERSION} echo "resource: true" > ~/.pulumi/plugins/resource-castai-v${VERSION}/PulumiPlugin.yaml echo "name: castai" >> ~/.pulumi/plugins/resource-castai-v${VERSION}/PulumiPlugin.yaml echo "version: ${VERSION}" >> ~/.pulumi/plugins/resource-castai-v${VERSION}/PulumiPlugin.yaml echo "server: pulumi-resource-castai" >> ~/.pulumi/plugins/resource-castai-v${VERSION}/PulumiPlugin.yaml # Copy the provider binary cp /path/to/pulumi-castai/bin/pulumi-resource-castai ~/.pulumi/plugins/resource-castai-v${VERSION}/ ``` -------------------------------- ### Using Local Go SDK in go.mod - Go Source: https://github.com/castai/pulumi-castai/blob/main/README.md These lines show how to modify your Go project's go.mod file to use the local Go SDK built from source. The `require` statement declares the dependency, and the `replace` directive points it to the local path. ```Go require github.com/castai/pulumi-castai v0.0.0 replace github.com/castai/pulumi-castai => /path/to/pulumi-castai ``` -------------------------------- ### Cloning Pulumi CASTAI Repository - Bash Source: https://github.com/castai/pulumi-castai/blob/main/README.md These commands clone the Pulumi CASTAI provider repository from GitHub and change the current directory to the newly cloned repository. This is the first step when building the provider or SDKs from source. ```Bash git clone https://github.com/castai/pulumi-castai.git ``` ```Bash cd pulumi-castai ``` -------------------------------- ### Connecting GKE Cluster with Pulumi - Go Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This Go Pulumi program demonstrates connecting an existing GKE cluster to CAST AI. It initializes the provider, reads configuration like project ID and cluster name from environment variables, creates a `GkeCluster` resource, and exports the resulting cluster ID. ```Go package main import ( "os" "github.com/castai/pulumi-castai/sdk/go/castai" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) func main() { pulumi.Run(func(ctx *pulumi.Context) error { // Initialize the provider provider, err := castai.NewProvider(ctx, "castai-provider", &castai.ProviderArgs{ ApiToken: pulumi.String(os.Getenv("CASTAI_API_TOKEN")), }) if err != nil { return err } // Get GCP project ID from environment variable or use a default value projectID := os.Getenv("GCP_PROJECT_ID") if projectID == "" { projectID = "my-gcp-project-id" } // Get GKE cluster name from environment variable or use a default value clusterName := os.Getenv("GKE_CLUSTER_NAME") if clusterName == "" { clusterName = "cast_ai_test_cluster" } // Create a connection to a GKE cluster gkeArgs := &castai.GkeClusterArgs{ ProjectId: pulumi.String(projectID), Location: pulumi.String("us-central1"), Name: pulumi.String(clusterName), DeleteNodesOnDisconnect: pulumi.Bool(true), } gkeCluster, err := castai.NewGkeCluster(ctx, "gke-cluster-connection", gkeArgs, pulumi.Provider(provider)) if err != nil { return err } // Export the cluster ID ctx.Export("clusterId", gkeCluster.ID()) return nil }) } ``` -------------------------------- ### Rebuilding After Version Update - Bash Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md These `make` commands are used to clean the build environment and then rebuild the provider binary and SDKs after the version has been updated. This ensures that all generated artifacts reflect the new version number. ```Bash make clean && make dev ``` -------------------------------- ### Rebuilding After Version Update - Bash/Makefile Source: https://github.com/castai/pulumi-castai/blob/main/README.md These commands are run after updating the version using the script. They clean the build artifacts and then rebuild the provider binary and SDKs with the new version information embedded. ```Bash make clean && make dev ``` -------------------------------- ### Adding Local Go SDK Replacement - Go Source: https://github.com/castai/pulumi-castai/blob/main/sdk/python/README.md This code snippet shows how to modify your Go module file (`go.mod`) to use the locally built Pulumi CASTAI Go SDK instead of fetching it from a remote repository. This is essential when developing or testing the SDK from source. ```Go require github.com/castai/pulumi-castai v0.0.0 replace github.com/castai/pulumi-castai => /path/to/pulumi-castai # Then import the SDK in your code: # import "github.com/castai/pulumi-castai/sdk/go/castai" ``` -------------------------------- ### Connecting GKE Cluster to CAST AI - Go Source: https://github.com/castai/pulumi-castai/blob/main/README.md This Go Pulumi program shows how to initialize the CAST AI provider and create a resource representing a connection to a Google Kubernetes Engine (GKE) cluster. It retrieves configuration like project ID and cluster name from environment variables and exports the resulting CAST AI cluster ID. ```Go package main import ( "os" "github.com/castai/pulumi-castai" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) func main() { pulumi.Run(func(ctx *pulumi.Context) error { // Initialize the provider provider, err := castai.NewProvider(ctx, "castai-provider", &castai.ProviderArgs{ ApiToken: pulumi.String(os.Getenv("CASTAI_API_TOKEN")), }) if err != nil { return err } // Get GCP project ID from environment variable or use a default value projectID := os.Getenv("GCP_PROJECT_ID") if projectID == "" { projectID = "my-gcp-project-id" } // Get GKE cluster name from environment variable or use a default value clusterName := os.Getenv("GKE_CLUSTER_NAME") if clusterName == "" { clusterName = "cast_ai_test_cluster" } // Create a connection to a GKE cluster gkeArgs := &castai.GkeClusterArgs{ ProjectId: pulumi.String(projectID), Location: pulumi.String("us-central1"), Name: pulumi.String(clusterName), DeleteNodesOnDisconnect: pulumi.Bool(true), } gkeCluster, err := castai.NewGkeCluster(ctx, "gke-cluster-connection", gkeArgs, pulumi.Provider(provider)) if err != nil { return err } // Export the cluster ID ctx.Export("clusterId", gkeCluster.ID()) return nil }) } ``` -------------------------------- ### Pushing Main Branch (Git/Shell) Source: https://github.com/castai/pulumi-castai/blob/main/RELEASE_CHECKLIST.md Pushes the latest committed changes on the `main` branch to the remote `origin` repository. This step ensures the commit is available remotely before a tag referencing it is pushed. ```shell git push origin main ``` -------------------------------- ### Connecting GKE Cluster to CAST AI - Python Source: https://github.com/castai/pulumi-castai/blob/main/README.md This Python Pulumi program demonstrates how to initialize the CAST AI provider and create a connection resource for a Google Kubernetes Engine (GKE) cluster. It reads configuration from environment variables and exports the resulting CAST AI cluster ID. ```Python import pulumi import os from pulumi_castai import Provider, GkeCluster # Initialize the CAST AI provider api_token = os.environ.get("CASTAI_API_TOKEN", "your-api-token-here") provider = Provider("castai-provider", api_token=api_token) # Get GCP values from environment variables or use defaults project_id = os.environ.get("GCP_PROJECT_ID", "my-gcp-project-id") cluster_name = os.environ.get("GKE_CLUSTER_NAME", "cast_ai_test_cluster") # Create a connection to a GKE cluster gke_cluster = GkeCluster("gke-cluster-connection", project_id=project_id, # GCP project ID location="us-central1", # GCP location name=cluster_name, # GKE cluster name delete_nodes_on_disconnect=True, # Remove nodes on disconnect opts=pulumi.ResourceOptions(provider=provider) ) # Export the cluster ID pulumi.export("cluster_id", gke_cluster.id) ``` -------------------------------- ### Running TypeScript GCP End-to-End Test - Bash/Just Source: https://github.com/castai/pulumi-castai/blob/main/README.md This command executes the end-to-end test specifically for the TypeScript SDK connecting to a GCP (GKE) cluster. It requires the environment to be set up (`just clean && just dev`) and appropriate GCP and CAST AI credentials. ```Bash just run-typescript-gcp-example ``` -------------------------------- ### Running Version Update Script (Bash) Source: https://github.com/castai/pulumi-castai/blob/main/PUBLISHING.md Executes the project's version update script, taking the new version string as an argument. This script typically modifies various project files to reflect the new release version before committing. Requires the `update-version.sh` script to be present and executable. Input is the new version number. ```Bash ./update-version.sh ```