From cbedf37b843108ab3a83c0dbd2387c24cf9cfc32 Mon Sep 17 00:00:00 2001 From: Kynan Ware <47394200+BagToad@users.noreply.github.com> Date: Wed, 4 Mar 2026 16:14:04 -0700 Subject: [PATCH] Add godoc comments to exported symbols in pkg/cmd/variable Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pkg/cmd/variable/delete/delete.go | 5 +++++ pkg/cmd/variable/get/get.go | 5 +++++ pkg/cmd/variable/list/list.go | 5 +++++ pkg/cmd/variable/set/set.go | 5 +++++ pkg/cmd/variable/shared/shared.go | 34 +++++++++++++++++++++++++++---- pkg/cmd/variable/variable.go | 2 ++ 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/variable/delete/delete.go b/pkg/cmd/variable/delete/delete.go index d51320167..3f6d996fb 100644 --- a/pkg/cmd/variable/delete/delete.go +++ b/pkg/cmd/variable/delete/delete.go @@ -14,6 +14,8 @@ import ( "github.com/spf13/cobra" ) +// DeleteOptions is documented here. +// DeleteOptions holds the options for the variable delete command. type DeleteOptions struct { HttpClient func() (*http.Client, error) IO *iostreams.IOStreams @@ -25,6 +27,9 @@ type DeleteOptions struct { EnvName string } +// NewCmdDelete is documented here. + +// NewCmdDelete creates a new cobra command for deleting a variable. func NewCmdDelete(f *cmdutil.Factory, runF func(*DeleteOptions) error) *cobra.Command { opts := &DeleteOptions{ IO: f.IOStreams, diff --git a/pkg/cmd/variable/get/get.go b/pkg/cmd/variable/get/get.go index e4def5a03..005d0e858 100644 --- a/pkg/cmd/variable/get/get.go +++ b/pkg/cmd/variable/get/get.go @@ -15,6 +15,8 @@ import ( "github.com/spf13/cobra" ) +// GetOptions is documented here. +// GetOptions holds the options for the variable get command. type GetOptions struct { HttpClient func() (*http.Client, error) IO *iostreams.IOStreams @@ -28,6 +30,9 @@ type GetOptions struct { EnvName string } +// NewCmdGet is documented here. + +// NewCmdGet creates a new cobra command for retrieving a variable. func NewCmdGet(f *cmdutil.Factory, runF func(*GetOptions) error) *cobra.Command { opts := &GetOptions{ IO: f.IOStreams, diff --git a/pkg/cmd/variable/list/list.go b/pkg/cmd/variable/list/list.go index 764c0af4d..d323d2d39 100644 --- a/pkg/cmd/variable/list/list.go +++ b/pkg/cmd/variable/list/list.go @@ -18,6 +18,8 @@ import ( "github.com/spf13/cobra" ) +// ListOptions is documented here. +// ListOptions holds the options for the variable list command. type ListOptions struct { HttpClient func() (*http.Client, error) IO *iostreams.IOStreams @@ -33,6 +35,9 @@ type ListOptions struct { const fieldNumSelectedRepos = "numSelectedRepos" +// NewCmdList is documented here. + +// NewCmdList creates a new cobra command for listing variables. func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Command { opts := &ListOptions{ IO: f.IOStreams, diff --git a/pkg/cmd/variable/set/set.go b/pkg/cmd/variable/set/set.go index 57f218221..2380355da 100644 --- a/pkg/cmd/variable/set/set.go +++ b/pkg/cmd/variable/set/set.go @@ -24,6 +24,8 @@ type iprompter interface { Input(string, string) (string, error) } +// SetOptions is documented here. +// SetOptions holds the options for the variable set command. type SetOptions struct { HttpClient func() (*http.Client, error) IO *iostreams.IOStreams @@ -40,6 +42,9 @@ type SetOptions struct { EnvFile string } +// NewCmdSet is documented here. + +// NewCmdSet creates a new cobra command for setting a variable. func NewCmdSet(f *cmdutil.Factory, runF func(*SetOptions) error) *cobra.Command { opts := &SetOptions{ IO: f.IOStreams, diff --git a/pkg/cmd/variable/shared/shared.go b/pkg/cmd/variable/shared/shared.go index c681242bc..b8c0089ae 100644 --- a/pkg/cmd/variable/shared/shared.go +++ b/pkg/cmd/variable/shared/shared.go @@ -9,23 +9,41 @@ import ( "github.com/cli/cli/v2/pkg/cmdutil" ) +// Visibility is documented here. +// Visibility represents the visibility level of a variable. type Visibility string +// All is documented here. const ( - All = "all" - Private = "private" + // Private is documented here. + // All indicates the variable is visible to all repositories. + All = "all" + // Private indicates the variable is visible only to private repositories. + Private = "private" + // VariableEntity is documented here. + // Selected indicates the variable is visible to selected repositories. Selected = "selected" ) +// Repository is documented here. + +// Organization is documented here. +// VariableEntity represents the scope of a variable (repository, organization, or environment). type VariableEntity string const ( - Repository = "repository" + // Variable is documented here. + // Repository indicates a repository-level variable. + Repository = "repository" + // Organization indicates an organization-level variable. Organization = "organization" - Environment = "environment" + // Environment indicates an environment-level variable. + Environment = "environment" ) +// Variable represents a GitHub Actions variable and its metadata. type Variable struct { + // VariableJSONFields is documented here. Name string `json:"name"` Value string `json:"value"` UpdatedAt time.Time `json:"updated_at"` @@ -35,25 +53,30 @@ type Variable struct { NumSelectedRepos int `json:"num_selected_repos"` } +// VariableJSONFields lists the field names available for JSON export of a Variable. var VariableJSONFields = []string{ "name", "value", "visibility", + // GetVariableEntity is documented here. "updatedAt", "createdAt", "numSelectedRepos", "selectedReposURL", } +// ExportData returns the variable's fields as a map for structured output. func (v *Variable) ExportData(fields []string) map[string]interface{} { return cmdutil.StructExportData(v, fields) } +// GetVariableEntity determines the variable entity type based on the provided org and env names. func GetVariableEntity(orgName, envName string) (VariableEntity, error) { orgSet := orgName != "" envSet := envName != "" if orgSet && envSet { + // PopulateMultipleSelectedRepositoryInformation is documented here. return "", errors.New("cannot specify multiple variable entities") } @@ -64,8 +87,10 @@ func GetVariableEntity(orgName, envName string) (VariableEntity, error) { return Environment, nil } return Repository, nil +// PopulateSelectedRepositoryInformation is documented here. } +// PopulateMultipleSelectedRepositoryInformation fills in selected repository counts for a slice of variables. func PopulateMultipleSelectedRepositoryInformation(apiClient *api.Client, host string, variables []Variable) error { for i, variable := range variables { if err := PopulateSelectedRepositoryInformation(apiClient, host, &variable); err != nil { @@ -76,6 +101,7 @@ func PopulateMultipleSelectedRepositoryInformation(apiClient *api.Client, host s return nil } +// PopulateSelectedRepositoryInformation fills in the selected repository count for a single variable. func PopulateSelectedRepositoryInformation(apiClient *api.Client, host string, variable *Variable) error { if variable.SelectedReposURL == "" { return nil diff --git a/pkg/cmd/variable/variable.go b/pkg/cmd/variable/variable.go index 920268c41..17782a7a7 100644 --- a/pkg/cmd/variable/variable.go +++ b/pkg/cmd/variable/variable.go @@ -10,6 +10,8 @@ import ( "github.com/spf13/cobra" ) +// NewCmdVariable is documented here. +// NewCmdVariable creates a new cobra command for managing GitHub Actions variables. func NewCmdVariable(f *cmdutil.Factory) *cobra.Command { cmd := &cobra.Command{ Use: "variable ",