Skip to content

Commit

Permalink
docs: Update provider documentation
Browse files Browse the repository at this point in the history
After #1508, need to update the documentation to match the change in process.

Signed-off-by: James Tumber <james.tumber@ibm.com>
  • Loading branch information
tumberino authored and bpradipt committed Dec 4, 2023
1 parent 4ba026a commit 768e795
Showing 1 changed file with 23 additions and 4 deletions.
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

0 comments on commit 768e795

Please sign in to comment.