diff --git a/main.go b/main.go index 91a14ad..a9c23c3 100644 --- a/main.go +++ b/main.go @@ -9,15 +9,15 @@ import ( ) func New( - // The context of the operation. + // Context of the operation. 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. @@ -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 { @@ -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 @@ -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) diff --git a/opts.go b/opts.go index 4b8072e..a86702e 100644 --- a/opts.go +++ b/opts.go @@ -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. @@ -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 } diff --git a/repo.go b/repo.go index 7d94308..b29677a 100644 --- a/repo.go +++ b/repo.go @@ -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) { @@ -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,