Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update provider documentation #1611

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions docs/addnewprovider.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# :memo: Adding support for a new provider

### Step 1: Initialize and register the cloud provider manager
### Step 1: Initialize and register the cloud provider manager

The provider-specific cloud manager should be placed under `pkg/adaptor/cloud/cloudmgr/`.
The provider-specific cloud manager should be placed under `pkg/adaptor/cloud/<provider>/`.

:information_source:[Example code](https://github.com/confidential-containers/cloud-api-adaptor/blob/main/pkg/adaptor/cloud/cloudmgr/aws.go)
:information_source:[Example code](https://github.com/confidential-containers/cloud-api-adaptor/blob/main/pkg/adaptor/cloud/aws)

### Step 2: Add provider specific code
### Step 2: Add provider specific code

Under `pkg/adaptor/cloud/<provider>`, start by adding a new file called `types.go`. This file defines a configuration struct that contains the required parameters for a cloud provider.

Expand All @@ -20,6 +20,14 @@ Create a provider-specific manager file called `manager.go`, which implements th
- LoadEnv
- NewProvider

Create an `init` function to add your manager to the cloud provider table.

```go
func init() {
cloud.AddCloud("aws", &Manager{})
}
```

:information_source:[Example code](https://github.com/confidential-containers/cloud-api-adaptor/blob/main/pkg/adaptor/cloud/aws/manager.go)

#### Step 2.2: Implement the Provider interface
Expand All @@ -34,6 +42,17 @@ The Provider interface defines a set of methods that need to be implemented by t

Also, consider adding additional files to modularize the code. You can refer to existing providers such as `aws`, `azure`, `ibmcloud`, and `libvirt` for guidance. Adding unit tests wherever necessary is good practice.

#### Step 2.3: Include Provider package from main

To include your provider you need reference it from the main package. Go build tags are used to selectively include different providers.

:information_source:[Example code](https://github.com/confidential-containers/cloud-api-adaptor/blob/main/cmd/cloud-api-adaptor/aws.go)

```go
//go:build aws
```
Note the comment at the top of the file, when building ensure `-tags=` is set to include your new provider. See the [Makefile](https://github.com/confidential-containers/cloud-api-adaptor/blob/main/Makefile#L26) for more context and usage.

#### Step 3: Add documentation on how to build a Pod VM image

For using the provider, a pod VM image needs to be created in order to create the peer pod instances. Add the instructions for building the peer pod VM image at the root directory similar to the other providers.
Expand Down
Loading