Skip to content

Commit

Permalink
fix: update daytona to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Tpuljak committed Feb 21, 2024
1 parent 8f9642f commit 1a307c9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module provisioner_plugin
go 1.21.6

require (
github.com/daytonaio/daytona v0.0.1-alpha.18
github.com/daytonaio/daytona v0.0.1-alpha.19
github.com/docker/docker v24.0.7+incompatible
github.com/hashicorp/go-hclog v1.5.0
github.com/hashicorp/go-plugin v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/daytonaio/daytona v0.0.1-alpha.18 h1:ZA5ZS4v7rdQQlJIlEKP1yODaZ+jsVMad/krfTNSBtzw=
github.com/daytonaio/daytona v0.0.1-alpha.18/go.mod h1:M8xXK5gqr2KOBEc0cLrVcnIkeRAyrjOWlOJDnfyr4P4=
github.com/daytonaio/daytona v0.0.1-alpha.19 h1:FBgULTT4ixXEqJlHKVfZyGRgv0inV6G/0AP9heVO5Kk=
github.com/daytonaio/daytona v0.0.1-alpha.19/go.mod h1:M8xXK5gqr2KOBEc0cLrVcnIkeRAyrjOWlOJDnfyr4P4=
github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
Expand Down
67 changes: 33 additions & 34 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,34 @@ func (p DockerProvisioner) Configure() (interface{}, error) {
return nil, errors.New("not implemented")
}

func (p DockerProvisioner) SetConfig(config interface{}) error {
return errors.New("not implemented")
}

func (p DockerProvisioner) getProjectPath(basePath string, project *types.Project) string {
return path.Join(basePath, "workspaces", project.WorkspaceId, "projects", project.Name)
}

func (p DockerProvisioner) CreateWorkspace(workspace *types.Workspace) error {
return util.CreateNetwork(workspace.Id)
func (p DockerProvisioner) CreateWorkspace(workspace *types.Workspace) (types.Empty, error) {
err := util.CreateNetwork(workspace.Id)
return types.Empty{}, err
}

func (p DockerProvisioner) StartWorkspace(workspace *types.Workspace) error {
return nil
func (p DockerProvisioner) StartWorkspace(workspace *types.Workspace) (types.Empty, error) {
return types.Empty{}, nil
}

func (p DockerProvisioner) StopWorkspace(workspace *types.Workspace) error {
return nil
func (p DockerProvisioner) StopWorkspace(workspace *types.Workspace) (types.Empty, error) {
return types.Empty{}, nil
}

func (p DockerProvisioner) DestroyWorkspace(workspace *types.Workspace) error {
func (p DockerProvisioner) DestroyWorkspace(workspace *types.Workspace) (types.Empty, error) {
if p.BasePath == nil {
return errors.New("BasePath not set. Did you forget to call Initialize?")
return types.Empty{}, errors.New("BasePath not set. Did you forget to call Initialize?")
}

err := os.RemoveAll(path.Join(*p.BasePath, "workspaces", workspace.Id))
if err != nil {
return err
return types.Empty{}, err
}

return util.RemoveNetwork(workspace.Id)
return types.Empty{}, util.RemoveNetwork(workspace.Id)
}

func (p DockerProvisioner) GetWorkspaceInfo(workspace *types.Workspace) (*types.WorkspaceInfo, error) {
Expand All @@ -103,23 +100,23 @@ func (p DockerProvisioner) GetWorkspaceInfo(workspace *types.Workspace) (*types.
return workspaceInfo, nil
}

func (p DockerProvisioner) CreateProject(project *types.Project) error {
func (p DockerProvisioner) CreateProject(project *types.Project) (types.Empty, error) {
log.Info("Initializing project: ", project.Name)

if p.ServerDownloadUrl == nil {
return errors.New("ServerDownloadUrl not set. Did you forget to call Initialize?")
return types.Empty{}, errors.New("ServerDownloadUrl not set. Did you forget to call Initialize?")
}

if p.BasePath == nil {
return errors.New("BasePath not set. Did you forget to call Initialize?")
return types.Empty{}, errors.New("BasePath not set. Did you forget to call Initialize?")
}

if p.ServerUrl == nil {
return errors.New("ServerUrl not set. Did you forget to call Initialize?")
return types.Empty{}, errors.New("ServerUrl not set. Did you forget to call Initialize?")
}

if p.ServerApiUrl == nil {
return errors.New("ServerApiUrl not set. Did you forget to call Initialize?")
return types.Empty{}, errors.New("ServerApiUrl not set. Did you forget to call Initialize?")
}

serverVersion := "latest"
Expand All @@ -131,57 +128,59 @@ func (p DockerProvisioner) CreateProject(project *types.Project) error {

err := os.MkdirAll(clonePath, 0755)
if err != nil {
return err
return types.Empty{}, err
}

// TODO: Project image from config
err = util.InitContainer(project, clonePath, "daytonaio/workspace-project", *p.ServerDownloadUrl, serverVersion, *p.ServerUrl, *p.ServerApiUrl)
if err != nil {
return err
return types.Empty{}, err
}

err = util.StartContainer(project)
if err != nil {
return err
return types.Empty{}, err
}

err = util.SetGitConfig(project, "daytona")
if err != nil {
return err
return types.Empty{}, err
}

err = util.CloneRepository(project, path.Join("/workspaces", project.Name))
if err != nil {
return err
return types.Empty{}, err
}

return nil
return types.Empty{}, nil
}

func (p DockerProvisioner) StartProject(project *types.Project) error {
return util.StartContainer(project)
func (p DockerProvisioner) StartProject(project *types.Project) (types.Empty, error) {
err := util.StartContainer(project)
return types.Empty{}, err
}

func (p DockerProvisioner) StopProject(project *types.Project) error {
return util.StopContainer(project)
func (p DockerProvisioner) StopProject(project *types.Project) (types.Empty, error) {
err := util.StopContainer(project)
return types.Empty{}, err
}

func (p DockerProvisioner) DestroyProject(project *types.Project) error {
func (p DockerProvisioner) DestroyProject(project *types.Project) (types.Empty, error) {
err := util.RemoveContainer(project)
if err != nil {
return err
return types.Empty{}, err
}

if p.BasePath == nil {
return errors.New("BasePath not set. Did you forget to call Initialize?")
return types.Empty{}, errors.New("BasePath not set. Did you forget to call Initialize?")
}

err = os.RemoveAll(p.getProjectPath(*p.BasePath, project))
if err != nil {
return err
return types.Empty{}, err
}

return nil
return types.Empty{}, nil
}

func (p DockerProvisioner) GetProjectInfo(project *types.Project) (*types.ProjectInfo, error) {
Expand Down

0 comments on commit 1a307c9

Please sign in to comment.