Skip to content

Commit

Permalink
feat: add integration description
Browse files Browse the repository at this point in the history
Signed-off-by: Vasek - Tom C <[email protected]>
  • Loading branch information
TomChv committed Dec 20, 2024
1 parent a4436a6 commit 81e9ee4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 1 addition & 3 deletions magic_sdk_test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ FROM golang:1.23.2-alpine

WORKDIR /app

COPY go.mod go.mod
COPY go.sum go.sum
COPY main.go main.go
COPY . .

RUN go mod download

Expand Down
2 changes: 1 addition & 1 deletion magic_sdk_test/dagger.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test",
"engineVersion": "v0.15.1",
"sdk": "../magicsdk"
"sdk": "github.com/quartz-technology/daggerverse/magicsdk"
}
4 changes: 4 additions & 0 deletions magicsdk/magic_sdk/integration/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func DockerIntegration(code *codebase.Codebase) (Integration, error) {
}, nil
}

func (d *Docker) Description() string {
return "Access docker functions"
}

func (d *Docker) Exist() bool {
return d.supported
}
Expand Down
2 changes: 2 additions & 0 deletions magicsdk/magic_sdk/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type Integrations map[string]Integration
type Integration interface {
Exist() bool

Description() string

New(invocation *invocation.Invocation) Integration

TypeDef() *dagger.TypeDef
Expand Down
11 changes: 6 additions & 5 deletions magicsdk/magic_sdk/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
)

type Module struct {
name string
codebase *codebase.Codebase
name string
codebase *codebase.Codebase
integrations integration.Integrations
}

Expand All @@ -32,8 +32,8 @@ func Build(name string, path string) (*Module, error) {
}

return &Module{
name: name,
codebase: codebase,
name: name,
codebase: codebase,
integrations: integrations,
}, nil
}
Expand All @@ -45,6 +45,7 @@ func (m *Module) TypeDef() *dagger.Module {
for name, integration := range m.integrations {
mainObject = mainObject.WithFunction(
dag.Function(name, dag.TypeDef().WithObject(name)).
WithDescription(integration.Description()).
WithArg("dir", dag.TypeDef().WithObject("Directory").WithOptional(true), dagger.FunctionWithArgOpts{
DefaultPath: "/",
}),
Expand Down Expand Up @@ -150,4 +151,4 @@ func (m *Module) Invoke(ctx context.Context, invocation *invocation.Invocation)
}

return integration.Invoke(ctx, invocation)
}
}

0 comments on commit 81e9ee4

Please sign in to comment.