Skip to content

Commit

Permalink
refactor: rename source module as ghx
Browse files Browse the repository at this point in the history
  • Loading branch information
aweris committed Nov 20, 2023
1 parent c4c8aa7 commit b5827ab
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion daggerverse/gale/dagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"../actions/artifacts",
"../actions/artifactcache",
"../repo",
"../source",
"../ghx",
"github.com/aweris/daggerverse/docker@969bc30a84b48f76a28afab3986144d2e47469df"
]
}
2 changes: 1 addition & 1 deletion daggerverse/gale/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (r *Runner) Container(
)

// configure internal components
ctr = ctr.With(dag.Source().Ghx().Binary)
ctr = ctr.With(dag.Ghx().Source().Binary)
ctr = ctr.With(dag.ActionsArtifactService().BindAsService)
ctr = ctr.With(dag.ActionsArtifactcacheService().BindAsService)

Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions daggerverse/ghx/dagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "ghx",
"sdk": "go"
}
26 changes: 10 additions & 16 deletions daggerverse/source/source.go → daggerverse/ghx/ghx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@ import (
"fmt"
)

// Source is a Dagger module for managing source code of the project.
type Source struct{}

// Repo returns the source code of the repository.
func (m *Source) Repo() *Directory {
return dag.Host().Directory(root())
}
type Ghx struct{}

func (m *Source) Ghx() *GhxSource {
return &GhxSource{}
func (m *Ghx) Source() *Source {
return &Source{}
}

// GhxSource represents the source code of the ghx module.
type GhxSource struct{}
// Source represents the source code of the ghx module.
type Source struct{}

// Code returns the source code of the ghx module.
func (m *GhxSource) Code() *Directory {
func (m *Source) Code() *Directory {
return dag.Host().Directory(root(), HostDirectoryOpts{
Include: []string{
"common/**/*.go",
Expand All @@ -33,23 +27,23 @@ func (m *GhxSource) Code() *Directory {
}

// GoMod returns the go.mod file of the ghx module.
func (m *GhxSource) GoMod() *File {
func (m *Source) GoMod() *File {
return m.Code().Directory("ghx").File("go.mod")
}

// GoVersion returns the Go version of the ghx module.
func (m *GhxSource) GoVersion(ctx context.Context) (string, error) {
func (m *Source) GoVersion(ctx context.Context) (string, error) {
return GoVersion(ctx, m.GoMod())
}

// MountedCode returns the source code of the ghx module mounted in a container at /src and sets the working directory
// to /src/ghx.
func (m *GhxSource) MountedCode(c *Container) *Container {
func (m *Source) MountedCode(c *Container) *Container {
return c.WithMountedDirectory("/src", m.Code()).WithWorkdir("/src/ghx")
}

// Binary adds the ghx binary to the given container and adds binary to the PATH environment variable.
func (m *GhxSource) Binary(ctx context.Context, container *Container) (*Container, error) {
func (m *Source) Binary(ctx context.Context, container *Container) (*Container, error) {
version, err := m.GoVersion(ctx)
if err != nil {
return nil, err
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions daggerverse/source/dagger.json

This file was deleted.

2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use (
daggerverse/gha/actions/hello-world-javascript-action
daggerverse/gha/aquasecurity/trivy-action
daggerverse/gha/trufflesecurity/trufflehog
daggerverse/ghx
daggerverse/repo
daggerverse/source
ghx
)

0 comments on commit b5827ab

Please sign in to comment.