Provider Development
This outline covers the development of Daytona’s provider model, enabling support for new platforms.
Provider Target Definition
The ProviderTarget
struct defines the configuration for a specific platform, often referred to as a “target”. It’s located in pkg/apiclient/docs/ProviderTarget.md
.
Here’s an example of a Provider Target struct:
type ProviderTarget struct {
Name *string `json:"name,omitempty"`
Options *string `json:"options,omitempty"`
ProviderInfo *ProviderProviderInfo `json:"providerInfo,omitempty"`
}
Key Properties:
- Name: A unique identifier for the target platform. (Optional)
- Options: A JSON encoded map of platform-specific options. (Optional)
- ProviderInfo: Contains details about the associated provider, including name and version. (Optional)
Provider API
The ProviderAPI
struct provides functionality for managing providers. It exposes a set of endpoints, outlined in pkg/apiclient/docs/ProviderAPI.md
.
Available Endpoints:
- GetTargetManifest: Retrieves the manifest for a given provider target, describing the available properties and their types. (
ProviderProviderTargetProperty
struct) - InstallProvider: Installs a provider.
- ListProviders: Retrieves a list of installed providers. (
Provider
struct) - UninstallProvider: Uninstalls a provider.
Provider Manifest
The ProviderProviderTargetProperty
struct defines properties associated with a provider target. It’s documented in pkg/apiclient/docs/ProviderProviderTargetProperty.md
.
Key Properties:
- DefaultValue: The default value for a property, converted to the appropriate type.
- Description: A brief description of the property.
- DisabledPredicate: A regular expression used to determine if a property should be disabled for specific targets.
- InputMasked: Indicates if input for this property should be masked.
- Options: A list of options, used when the property type is
ProviderTargetPropertyTypeOption
. - Type: The type of the property, defined by the
ProviderProviderTargetPropertyType
enum. (pkg/apiclient/docs/ProviderProviderTargetPropertyType.md
)
Provider and Provider Info
The Provider
struct represents a provider, while the ProviderProviderInfo
struct provides information about a specific provider. These are documented in pkg/apiclient/docs/Provider.md
and pkg/apiclient/docs/ProviderProviderInfo.md
respectively.
Key Properties:
- Provider Name: Unique identifier for the provider.
- Provider Version: The version of the provider.
Example: Provider Development for Local Development
This example shows how to use the GetTargetManifest
endpoint to retrieve properties for a local development target:
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID/apiclient"
)
func main() {
provider := "local" // Provider name
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.ProviderAPI.GetTargetManifest(context.Background(), provider).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ProviderAPI.GetTargetManifest``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetTargetManifest`: map[string]ProviderProviderTargetProperty
fmt.Fprintf(os.Stdout, "Response from `ProviderAPI.GetTargetManifest`: %v\n", resp)
}
This retrieves the manifest for the local
provider target, providing a list of properties with their types and descriptions. This information can then be used to define and implement the provider for local development within Daytona.
Top-Level Directory Explanations
hack/ - Directory for Go development, including build scripts and dependencies.
internal/ - Private package directory for the project’s internal modules.
internal/testing/ - Subdirectory for testing-related modules.
internal/testing/docker/ - Subdirectory for Docker-related testing configurations.
internal/testing/provider/ - Subdirectory for testing providers.
internal/testing/server/ - Subdirectory for testing server configurations.
pkg/ - Go packages directory.
pkg/api/ - Subdirectory for API-related packages.
pkg/api/controllers/ - Subdirectory for API controller handlers.
pkg/apiclient/ - Subdirectory for API client package.
pkg/cmd/ - Subdirectory for command-line interface tools.
pkg/cmd/provider/ - Subdirectory for provider command-line tools.
pkg/db/ - Subdirectory for database-related packages and scripts.
pkg/db/dto/ - Subdirectory for database data transfer objects.
pkg/gitprovider/ - Subdirectory for Git provider package.
pkg/provider/ - Subdirectory for provider packages and scripts.
pkg/provider/manager/ - Subdirectory for provider manager.
pkg/provider/util/ - Subdirectory for provider utilities.
pkg/provisioner/ - Subdirectory for provisioner packages and scripts.
pkg/server/ - Subdirectory for server-related packages and scripts.
pkg/server/headscale/ - Subdirectory for Headscale server-side.
pkg/server/providertargets/ - Subdirectory for provider targets server-side.
pkg/views/ - Subdirectory for view templates.
pkg/views/containerregistry/ - Subdirectory for container registry view templates.
pkg/views/env/ - Subdirectory for environment variable view templates.