Skip to content

Commit

Permalink
docs: update inline docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aweris committed Dec 11, 2023
1 parent 2803aec commit 5316ae4
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 34 deletions.
30 changes: 16 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
)

func New(
// The context of the operation.
// Context of the operation.

Check failure on line 12 in main.go

View workflow job for this annotation

GitHub Actions / golangci-lint (ghx)

undefined: Container
ctx context.Context,
// The directory containing the repository source. If source is provided, rest of the options are ignored.
// Directory containing the repository source. If source is provided, rest of the options are ignored.
// +optional=true
source *Directory,
// The name of the repository. Format: owner/name.
// Name of the repository. Format: owner/name.
// +optional=true
repo string,
// Tag name to check out. Only one of branch or tag can be used. Precedence is as follows: tag, branch.
// Name to check out. Only one of branch or tag can be used. Precedence is as follows: tag, branch.
// +optional=true
tag string,
// Branch name to check out. Only one of branch or tag can be used. Precedence is as follows: tag, branch.
Expand All @@ -33,21 +33,18 @@ func New(
return nil, err
}

return &Gale{
Repo: info,
Workflows: info.workflows(workflowsDir),
}, nil
return &Gale{Repo: info, Workflows: info.workflows(workflowsDir)}, nil
}

type Gale struct {
// The repository information
// Repository information
Repo *RepoInfo

// The workflows in the repository
// Workflows in the repository
Workflows *Workflows
}

// List returns a list of workflows and their jobs with the given options.
// List returns a list of workflows and their jobs.
func (g *Gale) List(ctx context.Context) (string, error) {
workflows, err := g.Workflows.List(ctx)
if err != nil {
Expand Down Expand Up @@ -87,7 +84,7 @@ func (g *Gale) List(ctx context.Context) (string, error) {
}

func (g *Gale) Run(
// context to use for the operation
// Context to use for the operation
ctx context.Context,
// External workflow file to run.
// +optional=true
Expand Down Expand Up @@ -160,8 +157,13 @@ func (g *Gale) Run(
DockerHost: dockerHost,
UseDind: useDind,
},
&EventOpts{Name: event, File: eventFile},
&SecretOpts{Token: token},
&EventOpts{
Name: event,
File: eventFile,
},
&SecretOpts{
Token: token,
},
)

executor, err := planner.Plan(ctx)
Expand Down
18 changes: 9 additions & 9 deletions opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ package main
// refactor this code when dagger supports Opt struct types as type parameters.

type WorkflowRunOpts struct {
// external workflow file to run against the repository.
// External workflow file to run against the repository.
WorkflowFile *File

// name or path of the workflow to run.
// Name or path of the workflow to run.
Workflow string

// job name to run. If not specified, all jobs in the workflow will be run.
// Job name to run. If not specified, all jobs in the workflow will be run.
Job string
}

type EventOpts struct {
// event name.
// Event name.
Name string

// file containing the event data in JSON format.
// File containing the event data in JSON format.
File *File
}

type RunnerOpts struct {
// base container for the runner.
// Base container for the runner.
Ctr *Container

// debug flag for the runner.
// Debug flag for the runner.
Debug bool

// Enables native docker support to able to run docker commands directly in the workflow.
UseNativeDocker bool

// docker host to use for the runner.
// Docker host to use for the runner.
DockerHost string

// Enables docker-in-dagger support to be able to run docker commands isolated from the host.
Expand All @@ -41,6 +41,6 @@ type RunnerOpts struct {
}

type SecretOpts struct {
// gitHub token to use for the runner.
// GitHub token to use for the runner.
Token *Secret
}
44 changes: 33 additions & 11 deletions repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,38 @@ import (

// RepoInfo represents a repository information.
type RepoInfo struct {
Owner string // Owner of the repository.
Name string // Name of the repository.
NameWithOwner string // NameWithOwner combined version of owner and name. Format: owner/name.
URL string // URL of the repository.
Ref string // Ref is the branch or tag ref that triggered the workflow
RefName string // RefName is the short name (without refs/heads/ prefix) of the branch or tag ref that triggered the workflow.
RefType string // RefType is the type of ref that triggered the workflow. Possible values are branch, tag, or empty, if neither
SHA string // SHA is the commit SHA that triggered the workflow. The value of this commit SHA depends on the event that
ShortSHA string // ShortSHA is the short commit SHA that triggered the workflow. The value of this commit SHA depends on the event that
IsRemote bool // IsRemote is true if the ref is a remote ref.
Source *Directory // Source is the directory containing the repository source.
// Owner of the repository.
Owner string

// Name of the repository.
Name string

// NameWithOwner combined version of owner and name. Format: owner/name.
NameWithOwner string

// URL of the repository.
URL string

// Ref is the branch or tag ref that triggered the workflow
Ref string

// RefName is the short name (without refs/heads/ prefix) of the branch or tag ref that triggered the workflow.
RefName string

// RefType is the type of ref that triggered the workflow. Possible values are branch, tag, or empty, if neither
RefType string

// SHA is the commit SHA that triggered the workflow. The value of this commit SHA depends on the event that
SHA string

// ShortSHA is the short commit SHA that triggered the workflow. The value of this commit SHA depends on the event that
ShortSHA string

// IsRemote is true if the ref is a remote ref.
IsRemote bool

// Source is the directory containing the repository source.
Source *Directory
}

func NewRepoInfo(ctx context.Context, source *Directory, repo, tag, branch string) (*RepoInfo, error) {
Expand Down Expand Up @@ -76,6 +97,7 @@ func NewRepoInfo(ctx context.Context, source *Directory, repo, tag, branch strin
}, nil
}

// workflows returns the workflows endpoint for the repository.
func (info *RepoInfo) workflows(dir string) *Workflows {
return &Workflows{
Repo: info,
Expand Down

0 comments on commit 5316ae4

Please sign in to comment.