Skip to content

Commit

Permalink
remove dagger-cli in favor of dagger publisher
Browse files Browse the repository at this point in the history
Signed-off-by: Vasek - Tom C <[email protected]>
  • Loading branch information
TomChv committed Feb 15, 2024
1 parent 24a9219 commit 7b19d13
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 49 deletions.
21 changes: 0 additions & 21 deletions dagger-cli/README.md

This file was deleted.

File renamed without changes.
15 changes: 15 additions & 0 deletions dagger-publisher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Dagger Publisher module

A module to publish other Dagger module

💡 This module is useful to integrate Dagger inside more complex CI.

## Usage

### Publish a module

```shell
dagger call -m github.com/quartz-technology/daggerverse/dagger-publisher --repository=. --module=<module-path> call publish
```

Made with ❤️ by Quartz.
File renamed without changes.
2 changes: 1 addition & 1 deletion dagger-cli/dagger.json → dagger-publisher/dagger.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "dagger-cli",
"name": "dagger-publisher",
"sdk": "go",
"engineVersion": "v0.9.9"
}
File renamed without changes.
File renamed without changes.
44 changes: 17 additions & 27 deletions dagger-cli/main.go → dagger-publisher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@ package main
import (
"context"
"fmt"
"path/filepath"
)

type DaggerCli struct {
type DaggerPublisher struct {
Container *Container
}

const DefaultVersion = "v0.9.10"
const DefaultDaggerVersion = "0.9.10"

func New(
// The module to use the Dagger CLI with
module *Directory,

// +optional
version string,
) *DaggerCli {
) *DaggerPublisher {
if version == "" {
version = DefaultVersion
version = DefaultDaggerVersion
}

return &DaggerCli{
return &DaggerPublisher{
Container: dag.
Container().
From("alpine:3.19.1").
Expand All @@ -31,37 +29,29 @@ func New(
"sh", "-c",
fmt.Sprintf("curl -L https://dl.dagger.io/dagger/install.sh | %s sh", fmt.Sprintf("DAGGER_VERSION=%s", version)),
}).
WithWorkdir("/module").
WithDirectory("/module", module).
WithEntrypoint([]string{"/bin/dagger"}),
}
}

// Publish executes the publish command to upload the module
// to the Daggerverse.
func (d *DaggerCli) Publish(
func (d *DaggerPublisher) Publish(
ctx context.Context,

// The repository to use the Dagger CLI on
repository *Directory,

// The path to the module to publish
// +optional
path string,
) (string, error) {
return d.
Container.
WithWorkdir("/module").
WithDirectory("/module", repository).
WithWorkdir(filepath.Join("/module", path)).
WithExec([]string{"publish"},
ContainerWithExecOpts{ExperimentalPrivilegedNesting: true},
).
Stdout(ctx)
}

// Call executes the call command and returns its result.
func (d *DaggerCli) Call(
ctx context.Context,

args ...string,
) (string, error) {
args = append([]string{"call"}, args...)

return d.
Container.
WithExec(
args,
ContainerWithExecOpts{ExperimentalPrivilegedNesting: true}).
Stdout(ctx)
}
File renamed without changes.
File renamed without changes.

0 comments on commit 7b19d13

Please sign in to comment.