Skip to content

Commit

Permalink
update daytona to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Tpuljak committed Feb 20, 2024
1 parent 8f98feb commit 0425331
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 44 deletions.
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module provisioner_plugin
go 1.21.6

require (
github.com/daytonaio/daytona v0.0.1-alpha.14
github.com/daytonaio/daytona v0.0.1-alpha.15
github.com/docker/docker v24.0.7+incompatible
github.com/golang/protobuf v1.5.3
github.com/hashicorp/go-plugin v1.6.0
github.com/mitchellh/mapstructure v1.5.0
github.com/sirupsen/logrus v1.9.3
gopkg.in/ini.v1 v1.67.0
)
Expand All @@ -20,6 +20,7 @@ require (
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand Down
6 changes: 4 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.14 h1:00yRXEoPsc3xDiYMVGTf7fypCFwEqw68sV+gEdHXlfE=
github.com/daytonaio/daytona v0.0.1-alpha.14/go.mod h1:8ufXzdJWYoQnTo5ahJMDScVQ0x7pcaXq1//Ta1wXhX4=
github.com/daytonaio/daytona v0.0.1-alpha.15 h1:9Owu0WOroIH3iOMENFQmvYpokL0Rc4Luux+tzs2Eudk=
github.com/daytonaio/daytona v0.0.1-alpha.15/go.mod h1:+z68fyt91Zq59Z1lkxGitX3UC6/HViIJZJ3ivVy228w=
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 Expand Up @@ -52,6 +52,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg=
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ func main() {
Plugins: map[string]plugin.Plugin{
"docker-provisioner": &provisioner.ProvisionerPlugin{Impl: &provisioner_plugin.DockerProvisioner{}},
},
GRPCServer: plugin.DefaultGRPCServer,
})
}
57 changes: 26 additions & 31 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (

"provisioner_plugin/plugin/util"

"github.com/daytonaio/daytona/common/grpc/proto/types"
"github.com/daytonaio/daytona/common/grpc/utils"
"github.com/daytonaio/daytona/plugins/provisioner/grpc/proto"
"github.com/daytonaio/daytona/common/types"
"github.com/daytonaio/daytona/plugins/provisioner"
"github.com/docker/docker/client"
structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/mitchellh/mapstructure"
log "github.com/sirupsen/logrus"
)

Expand All @@ -27,7 +26,7 @@ type workspaceMetadata struct {
NetworkId string
}

func (p *DockerProvisioner) Initialize(req *proto.InitializeProvisionerRequest) error {
func (p *DockerProvisioner) Initialize(req provisioner.InitializeProvisionerRequest) error {
p.BasePath = &req.BasePath
p.ServerDownloadUrl = &req.ServerDownloadUrl
p.ServerVersion = &req.ServerVersion
Expand All @@ -36,8 +35,8 @@ func (p *DockerProvisioner) Initialize(req *proto.InitializeProvisionerRequest)
return nil
}

func (p DockerProvisioner) GetInfo() (*proto.ProvisionerInfo, error) {
return &proto.ProvisionerInfo{
func (p DockerProvisioner) GetInfo() (provisioner.ProvisionerInfo, error) {
return provisioner.ProvisionerInfo{
Name: "docker-provisioner",
Version: "0.0.1",
}, nil
Expand Down Expand Up @@ -88,7 +87,7 @@ func (p DockerProvisioner) GetWorkspaceInfo(workspace *types.Workspace) (*types.

workspaceInfo := &types.WorkspaceInfo{
Name: workspace.Name,
ProvisionerMetadata: provisionerMetadata,
ProvisionerMetadata: &provisionerMetadata,
}

projectInfos := []*types.ProjectInfo{}
Expand Down Expand Up @@ -197,35 +196,31 @@ func (p DockerProvisioner) GetProjectInfo(project *types.Project) (*types.Projec
}
}

var provisionerMetadata *structpb.Struct = nil
if info != nil || info.State == nil {
return nil, errors.New("could not get container state")
}

if info != nil && info.Config != nil && info.Config.Labels != nil {
provisionerMetadata, err = utils.StructToProtobufStruct(info.Config.Labels)
if err != nil {
return nil, err
}
projectInfo := &types.ProjectInfo{
Name: project.Name,
IsRunning: isRunning,
Created: info.Created,
Started: info.State.StartedAt,
Finished: info.State.FinishedAt,
}

if info.Config != nil && info.Config.Labels != nil {
var metadata *interface{}
mapstructure.Decode(info.Config.Labels, &metadata)
projectInfo.ProvisionerMetadata = metadata
} else {
log.Warn("Could not get container labels for project: ", project.Name)
}

return &types.ProjectInfo{
Name: project.Name,
IsRunning: isRunning,
Created: info.Created,
Started: info.State.StartedAt,
Finished: info.State.FinishedAt,
ProvisionerMetadata: provisionerMetadata,
}, nil
return projectInfo, nil
}

func (p DockerProvisioner) getWorkspaceMetadata(workspace *types.Workspace) (*structpb.Struct, error) {
metadata := workspaceMetadata{
func (p DockerProvisioner) getWorkspaceMetadata(workspace *types.Workspace) (interface{}, error) {
return workspaceMetadata{
NetworkId: workspace.Id,
}

protoMetadata, err := utils.StructToProtobufStruct(metadata)
if err != nil {
return nil, err
}
return protoMetadata, nil
}, nil
}
3 changes: 1 addition & 2 deletions plugin/util/clone_repository.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package util

import (
"github.com/daytonaio/daytona/common/grpc/proto/types"

"github.com/daytonaio/daytona/common/types"
docker_types "github.com/docker/docker/api/types"
log "github.com/sirupsen/logrus"
)
Expand Down
2 changes: 1 addition & 1 deletion plugin/util/git_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"path"

"github.com/daytonaio/daytona/common/grpc/proto/types"
"github.com/daytonaio/daytona/common/types"
"gopkg.in/ini.v1"
)

Expand Down
2 changes: 1 addition & 1 deletion plugin/util/init_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"strings"

"github.com/daytonaio/daytona/common/grpc/proto/types"
"github.com/daytonaio/daytona/common/types"
docker_types "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
Expand Down
2 changes: 1 addition & 1 deletion plugin/util/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package util
import (
"context"

"github.com/daytonaio/daytona/common/grpc/proto/types"
"github.com/daytonaio/daytona/common/types"
docker_types "github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
Expand Down
2 changes: 1 addition & 1 deletion plugin/util/remove_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package util
import (
"context"

"github.com/daytonaio/daytona/common/grpc/proto/types"
"github.com/daytonaio/daytona/common/types"

docker_types "github.com/docker/docker/api/types"
"github.com/docker/docker/client"
Expand Down
2 changes: 1 addition & 1 deletion plugin/util/start_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/daytonaio/daytona/common/grpc/proto/types"
"github.com/daytonaio/daytona/common/types"
docker_types "github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
Expand Down
2 changes: 1 addition & 1 deletion plugin/util/stop_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/daytonaio/daytona/common/grpc/proto/types"
"github.com/daytonaio/daytona/common/types"

"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
Expand Down

0 comments on commit 0425331

Please sign in to comment.