Skip to content

Commit

Permalink
feat: template replacements
Browse files Browse the repository at this point in the history
Signed-off-by: Toma Puljak <[email protected]>
  • Loading branch information
Tpuljak committed May 15, 2024
1 parent fbac245 commit 5eab071
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Daytona Provider Sample",
"name": "Daytona Fly Provider",
"image": "ghcr.io/daytonaio/go-devcontainer:main",
"containerEnv": {
"LOG_LEVEL": "debug"
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ The team at Daytona welcomes contributions from the community. There are many wa

## Provide Feedback

You might find things that can be improved while you are using the Daytona Provider Sample. You can help by [submitting an issue](https://github.com/daytonaio/daytona-provider-sample/issues/new) when:
You might find things that can be improved while you are using the Daytona Fly Provider. You can help by [submitting an issue](https://github.com/daytonaio/daytona-provider-fly/issues/new) when:

* When the Provider Sample crashes or you encounter a bug that can only be resolved by restarting Daytona.
* When the Fly Provider crashes or you encounter a bug that can only be resolved by restarting Daytona.
* An error occurs that is unrecoverable, causes workspace integrity problems or loss, or generally prevents you from using a workspace.
* A new feature or an enhancement to an existing feature will improve the utility or usability of the Daytona Provider Sample.
* A new feature or an enhancement to an existing feature will improve the utility or usability of the Daytona Fly Provider.

Before creating a new issue, please confirm that an existing issue doesn't already exist.

Expand All @@ -22,15 +22,15 @@ You can engage with our community by:
* Authoring new dev containers and sharing examples

## Contributing Code
You can contribute to the Daytona Provider Sample by:
You can contribute to the Daytona Fly Provider by:

* Enhancing current functionality
* Fixing bugs
* Adding new features and capabilities

Before starting your contribution, especially for core features, we encourage you to reach out to us on [Slack](https://join.slack.com/t/daytonacommunity/shared_invite/zt-273yohksh-Q5YSB5V7tnQzX2RoTARr7Q). This allows us to ensure that your proposed feature aligns with the project's roadmap and goals. Developers are the key to making Daytona the best tool it can be, and we value input from the community.

We look forward to working with you to improve Daytona and the Provider Sample, and make development environments as easy as possible for developers everywhere.
We look forward to working with you to improve Daytona and the Fly Provider, and make development environments as easy as possible for developers everywhere.

### Steps to Contribute Code

Expand All @@ -39,7 +39,7 @@ Follow the following steps to ensure your contribution goes smoothly.
1. Read and follow the steps outlined in the [Daytona Contributing Policy](README.md#contributing).
2. Configure your development environment by either following the guide below.
3. [Fork](https://help.github.com/articles/working-with-forks/) the GitHub Repository allowing you to make the changes in your own copy of the repository.
4. Create a [GitHub issue](https://github.com/daytonaio/daytona-provider-sample/issues) if one doesn't exist already.
4. Create a [GitHub issue](https://github.com/daytonaio/daytona-provider-fly/issues) if one doesn't exist already.
5. [Prepare your changes](/PREPARING_YOUR_CHANGES.md) and ensure your commits are descriptive. The document contains an optional commit template, if desired.
6. Ensure that you sign off on all your commits to comply with the DCO v1.1. We have more details in [Prepare your changes](/PREPARING_YOUR_CHANGES.md).
7. Create a pull request on GitHub. If you're new to GitHub, read about [pull requests](https://help.github.com/articles/about-pull-requests/). You are welcome to submit your pull request for commentary or review before it is complete by creating a [draft pull request](https://help.github.com/en/articles/about-pull-requests#draft-pull-requests). Please include specific questions or items you'd like feedback on.
Expand Down
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
<div align="center">

[![License](https://img.shields.io/badge/License-MIT-blue)](#license)
[![Go Report Card](https://goreportcard.com/badge/github.com/daytonaio/daytona-provider-sample)](https://goreportcard.com/report/github.com/daytonaio/daytona-provider-sample)
[![Issues - daytona](https://img.shields.io/github/issues/daytonaio/daytona-provider-sample)](https://github.com/daytonaio/daytona-provider-sample/issues)
![GitHub Release](https://img.shields.io/github/v/release/daytonaio/daytona-provider-sample)
[![Go Report Card](https://goreportcard.com/badge/github.com/daytonaio/daytona-provider-fly)](https://goreportcard.com/report/github.com/daytonaio/daytona-provider-fly)
[![Issues - daytona](https://img.shields.io/github/issues/daytonaio/daytona-fly-provider)](https://github.com/daytonaio/daytona-provider-fly/issues)
![GitHub Release](https://img.shields.io/github/v/release/daytonaio/daytona-fly-provider)

</div>


<h1 align="center">Daytona Provider Sample</h1>
<h1 align="center">Daytona Fly Provider</h1>
<div align="center">
This repository is the home of the <a href="https://github.com/daytonaio/daytona">Daytona</a> Provider Sample.
This repository is the home of the <a href="https://github.com/daytonaio/daytona">Daytona</a> Fly Provider.
</div>
</br>

> [!NOTE]
> After you create a repository, you can run `./hack/replace-name.sh` to easily configure the repo based on the name of your provider. Feel free to remove the `hack` folder after that.
<p align="center">
<a href="https://github.com/daytonaio/daytona-provider-sample/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=%F0%9F%90%9B+Bug+Report%3A+">Report Bug</a>
<a href="https://github.com/daytonaio/daytona-provider-fly/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=%F0%9F%90%9B+Bug+Report%3A+">Report Bug</a>
·
<a href="https://github.com/daytonaio/daytona-provider-sample/issues/new?assignees=&labels=enhancement&projects=&template=feature_request.md&title=%F0%9F%9A%80+Feature%3A+">Request Feature</a>
<a href="https://github.com/daytonaio/daytona-provider-fly/issues/new?assignees=&labels=enhancement&projects=&template=feature_request.md&title=%F0%9F%9A%80+Feature%3A+">Request Feature</a>
·
<a href="https://join.slack.com/t/daytonacommunity/shared_invite/zt-273yohksh-Q5YSB5V7tnQzX2RoTARr7Q">Join Our Slack</a>
·
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/daytonaio/daytona-provider-sample
module github.com/daytonaio/daytona-provider-fly

go 1.22.2

Expand Down
51 changes: 0 additions & 51 deletions hack/replace-name.sh

This file was deleted.

4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/go-hclog"
hc_plugin "github.com/hashicorp/go-plugin"

p "github.com/daytonaio/daytona-provider-sample/pkg/provider"
p "github.com/daytonaio/daytona-provider-fly/pkg/provider"
)

func main() {
Expand All @@ -20,7 +20,7 @@ func main() {
hc_plugin.Serve(&hc_plugin.ServeConfig{
HandshakeConfig: manager.ProviderHandshakeConfig,
Plugins: map[string]hc_plugin.Plugin{
"provider-sample": &provider.ProviderPlugin{Impl: &p.SampleProvider{}},
"fly-provider": &provider.ProviderPlugin{Impl: &p.FlyProvider{}},
},
Logger: logger,
})
Expand Down
40 changes: 20 additions & 20 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import (
"encoding/json"
"io"

internal "github.com/daytonaio/daytona-provider-sample/internal"
log_writers "github.com/daytonaio/daytona-provider-sample/internal/log"
provider_types "github.com/daytonaio/daytona-provider-sample/pkg/types"
internal "github.com/daytonaio/daytona-provider-fly/internal"
log_writers "github.com/daytonaio/daytona-provider-fly/internal/log"
provider_types "github.com/daytonaio/daytona-provider-fly/pkg/types"

"github.com/daytonaio/daytona/pkg/logger"
"github.com/daytonaio/daytona/pkg/provider"
"github.com/daytonaio/daytona/pkg/provider/util"
"github.com/daytonaio/daytona/pkg/workspace"
)

type SampleProvider struct {
type FlyProvider struct {
BasePath *string
ServerDownloadUrl *string
ServerVersion *string
Expand All @@ -25,7 +25,7 @@ type SampleProvider struct {
OwnProperty string
}

func (p *SampleProvider) Initialize(req provider.InitializeProviderRequest) (*util.Empty, error) {
func (p *FlyProvider) Initialize(req provider.InitializeProviderRequest) (*util.Empty, error) {
p.OwnProperty = "my-own-property"

p.BasePath = &req.BasePath
Expand All @@ -39,18 +39,18 @@ func (p *SampleProvider) Initialize(req provider.InitializeProviderRequest) (*ut
return new(util.Empty), nil
}

func (p SampleProvider) GetInfo() (provider.ProviderInfo, error) {
func (p FlyProvider) GetInfo() (provider.ProviderInfo, error) {
return provider.ProviderInfo{
Name: "provider-sample",
Name: "fly-provider",
Version: internal.Version,
}, nil
}

func (p SampleProvider) GetTargetManifest() (*provider.ProviderTargetManifest, error) {
func (p FlyProvider) GetTargetManifest() (*provider.ProviderTargetManifest, error) {
return provider_types.GetTargetManifest(), nil
}

func (p SampleProvider) GetDefaultTargets() (*[]provider.ProviderTarget, error) {
func (p FlyProvider) GetDefaultTargets() (*[]provider.ProviderTarget, error) {
info, err := p.GetInfo()
if err != nil {
return nil, err
Expand All @@ -66,7 +66,7 @@ func (p SampleProvider) GetDefaultTargets() (*[]provider.ProviderTarget, error)
return &defaultTargets, nil
}

func (p SampleProvider) CreateWorkspace(workspaceReq *provider.WorkspaceRequest) (*util.Empty, error) {
func (p FlyProvider) CreateWorkspace(workspaceReq *provider.WorkspaceRequest) (*util.Empty, error) {
logWriter := io.MultiWriter(&log_writers.InfoLogWriter{})
if p.LogsDir != nil {
loggerFactory := logger.NewLoggerFactory(*p.LogsDir)
Expand All @@ -80,19 +80,19 @@ func (p SampleProvider) CreateWorkspace(workspaceReq *provider.WorkspaceRequest)
return new(util.Empty), nil
}

func (p SampleProvider) StartWorkspace(workspaceReq *provider.WorkspaceRequest) (*util.Empty, error) {
func (p FlyProvider) StartWorkspace(workspaceReq *provider.WorkspaceRequest) (*util.Empty, error) {
return new(util.Empty), nil
}

func (p SampleProvider) StopWorkspace(workspaceReq *provider.WorkspaceRequest) (*util.Empty, error) {
func (p FlyProvider) StopWorkspace(workspaceReq *provider.WorkspaceRequest) (*util.Empty, error) {
return new(util.Empty), nil
}

func (p SampleProvider) DestroyWorkspace(workspaceReq *provider.WorkspaceRequest) (*util.Empty, error) {
func (p FlyProvider) DestroyWorkspace(workspaceReq *provider.WorkspaceRequest) (*util.Empty, error) {
return new(util.Empty), nil
}

func (p SampleProvider) GetWorkspaceInfo(workspaceReq *provider.WorkspaceRequest) (*workspace.WorkspaceInfo, error) {
func (p FlyProvider) GetWorkspaceInfo(workspaceReq *provider.WorkspaceRequest) (*workspace.WorkspaceInfo, error) {
providerMetadata, err := p.getWorkspaceMetadata(workspaceReq)
if err != nil {
return nil, err
Expand All @@ -119,7 +119,7 @@ func (p SampleProvider) GetWorkspaceInfo(workspaceReq *provider.WorkspaceRequest
return workspaceInfo, nil
}

func (p SampleProvider) CreateProject(projectReq *provider.ProjectRequest) (*util.Empty, error) {
func (p FlyProvider) CreateProject(projectReq *provider.ProjectRequest) (*util.Empty, error) {
logWriter := io.MultiWriter(&log_writers.InfoLogWriter{})
if p.LogsDir != nil {
loggerFactory := logger.NewLoggerFactory(*p.LogsDir)
Expand All @@ -133,19 +133,19 @@ func (p SampleProvider) CreateProject(projectReq *provider.ProjectRequest) (*uti
return new(util.Empty), nil
}

func (p SampleProvider) StartProject(projectReq *provider.ProjectRequest) (*util.Empty, error) {
func (p FlyProvider) StartProject(projectReq *provider.ProjectRequest) (*util.Empty, error) {
return new(util.Empty), nil
}

func (p SampleProvider) StopProject(projectReq *provider.ProjectRequest) (*util.Empty, error) {
func (p FlyProvider) StopProject(projectReq *provider.ProjectRequest) (*util.Empty, error) {
return new(util.Empty), nil
}

func (p SampleProvider) DestroyProject(projectReq *provider.ProjectRequest) (*util.Empty, error) {
func (p FlyProvider) DestroyProject(projectReq *provider.ProjectRequest) (*util.Empty, error) {
return new(util.Empty), nil
}

func (p SampleProvider) GetProjectInfo(projectReq *provider.ProjectRequest) (*workspace.ProjectInfo, error) {
func (p FlyProvider) GetProjectInfo(projectReq *provider.ProjectRequest) (*workspace.ProjectInfo, error) {
providerMetadata := provider_types.ProjectMetadata{
Property: projectReq.Project.Name,
}
Expand All @@ -165,7 +165,7 @@ func (p SampleProvider) GetProjectInfo(projectReq *provider.ProjectRequest) (*wo
return projectInfo, nil
}

func (p SampleProvider) getWorkspaceMetadata(workspaceReq *provider.WorkspaceRequest) (string, error) {
func (p FlyProvider) getWorkspaceMetadata(workspaceReq *provider.WorkspaceRequest) (string, error) {
metadata := provider_types.WorkspaceMetadata{
Property: workspaceReq.Workspace.Id,
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
daytona_provider "github.com/daytonaio/daytona/pkg/provider"
"github.com/daytonaio/daytona/pkg/workspace"

"github.com/daytonaio/daytona-provider-sample/pkg/provider"
provider_types "github.com/daytonaio/daytona-provider-sample/pkg/types"
"github.com/daytonaio/daytona-provider-fly/pkg/provider"
provider_types "github.com/daytonaio/daytona-provider-fly/pkg/types"
)

var sampleProvider = &provider.SampleProvider{}
var sampleProvider = &provider.FlyProvider{}
var targetOptions = &provider_types.TargetOptions{
RequiredString: "default-required-string",
}
Expand Down

0 comments on commit 5eab071

Please sign in to comment.