Skip to content

Commit cfb6efd

Browse files
committed
Fix linting
1 parent d26e5a2 commit cfb6efd

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

src/internal/packager/template/template.go

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const (
2323
depMarkerNew = "DATA_INJECTION_MARKER"
2424
)
2525

26+
// GetZarfVariableConfig gets a variable configuration specific to Zarf
2627
func GetZarfVariableConfig() *variables.VariableConfig {
2728
return variables.New(
2829
"zarf",

src/pkg/actions/actions.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func (ac *ActionRunner) ConvertWaitToCmd(wait ActionWait, timeout *int) (string,
212212
}
213213

214214
// actionCmdMutation performs some basic string mutations to make commands more useful.
215-
func (ac *ActionRunner) actionCmdMutation(cmd string, shellPref exec.ExecShell) (string, error) {
215+
func (ac *ActionRunner) actionCmdMutation(cmd string, shellPref exec.Shell) (string, error) {
216216
// Try to patch the zarf binary path in case the name isn't exactly "./zarf".
217217
cmd = strings.ReplaceAll(cmd, fmt.Sprintf("./%s ", ac.commandName), ac.commandPath+" ")
218218

@@ -278,7 +278,7 @@ func (ac *ActionRunner) actionMergeDefaults(def ActionDefaults, a Action, vars m
278278
}
279279

280280
// execAction executes the built command in a shell
281-
func (ac *ActionRunner) execAction(ctx context.Context, cfg ActionDefaults, cmd string, shellPref exec.ExecShell, spinner Spinner) (string, error) {
281+
func (ac *ActionRunner) execAction(ctx context.Context, cfg ActionDefaults, cmd string, shellPref exec.Shell, spinner Spinner) (string, error) {
282282
shell, shellArgs := exec.GetOSShell(shellPref)
283283

284284
ac.logger(fmt.Sprintf("Running command in %s: %s", shell, cmd))

src/pkg/actions/types.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ type ActionSet struct {
2323

2424
// ActionDefaults sets the default configs for child actions
2525
type ActionDefaults struct {
26-
Mute bool `json:"mute,omitempty" jsonschema:"description=Hide the output of commands during execution (default false)"`
27-
MaxTotalSeconds int `json:"maxTotalSeconds,omitempty" jsonschema:"description=Default timeout in seconds for commands (default to 0, no timeout)"`
28-
MaxRetries int `json:"maxRetries,omitempty" jsonschema:"description=Retry commands given number of times if they fail (default 0)"`
29-
Dir string `json:"dir,omitempty" jsonschema:"description=Working directory for commands (default CWD)"`
30-
Env []string `json:"env,omitempty" jsonschema:"description=Additional environment variables for commands"`
31-
Shell exec.ExecShell `json:"shell,omitempty" jsonschema:"description=(cmd only) Indicates a preference for a shell for the provided cmd to be executed in on supported operating systems"`
26+
Mute bool `json:"mute,omitempty" jsonschema:"description=Hide the output of commands during execution (default false)"`
27+
MaxTotalSeconds int `json:"maxTotalSeconds,omitempty" jsonschema:"description=Default timeout in seconds for commands (default to 0, no timeout)"`
28+
MaxRetries int `json:"maxRetries,omitempty" jsonschema:"description=Retry commands given number of times if they fail (default 0)"`
29+
Dir string `json:"dir,omitempty" jsonschema:"description=Working directory for commands (default CWD)"`
30+
Env []string `json:"env,omitempty" jsonschema:"description=Additional environment variables for commands"`
31+
Shell exec.Shell `json:"shell,omitempty" jsonschema:"description=(cmd only) Indicates a preference for a shell for the provided cmd to be executed in on supported operating systems"`
3232
}
3333

3434
// Action represents a single action to run
@@ -39,7 +39,7 @@ type Action struct {
3939
Dir *string `json:"dir,omitempty" jsonschema:"description=The working directory to run the command in (default is CWD)"`
4040
Env []string `json:"env,omitempty" jsonschema:"description=Additional environment variables to set for the command"`
4141
Cmd string `json:"cmd,omitempty" jsonschema:"description=The command to run. Must specify either cmd or wait for the action to do anything."`
42-
Shell *exec.ExecShell `json:"shell,omitempty" jsonschema:"description=(cmd only) Indicates a preference for a shell for the provided cmd to be executed in on supported operating systems"`
42+
Shell *exec.Shell `json:"shell,omitempty" jsonschema:"description=(cmd only) Indicates a preference for a shell for the provided cmd to be executed in on supported operating systems"`
4343
DeprecatedSetVariable string `json:"setVariable,omitempty" jsonschema:"description=[Deprecated] (replaced by setVariables) (onDeploy/cmd only) The name of a variable to update with the output of the command. This variable will be available to all remaining actions and components in the package. This will be removed in Zarf v1.0.0,pattern=^[A-Z0-9_]+$"`
4444
SetVariables []variables.Variable `json:"setVariables,omitempty" jsonschema:"description=(onDeploy/cmd only) An array of variables to update with the output of the command. These variables will be available to all remaining actions and components in the package."`
4545
Description string `json:"description,omitempty" jsonschema:"description=Description of the action to be displayed during package execution instead of the command"`
@@ -67,6 +67,7 @@ type ActionWaitNetwork struct {
6767
Code int `json:"code,omitempty" jsonschema:"description=The HTTP status code to wait for if using http or https,example=200,example=404"`
6868
}
6969

70+
// Validate validates an Action struct instantiation
7071
func (action Action) Validate() error {
7172
// Validate SetVariable
7273
for _, variable := range action.SetVariables {

src/pkg/cluster/data.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (c *Cluster) HandleDataInjection(wg *sync.WaitGroup, data types.ZarfDataInj
4747
}
4848

4949
// Get the OS shell to execute commands in
50-
shell, shellArgs := exec.GetOSShell(exec.ExecShell{Windows: "cmd"})
50+
shell, shellArgs := exec.GetOSShell(exec.Shell{Windows: "cmd"})
5151

5252
if _, _, err := exec.Cmd(shell, append(shellArgs, "tar --version")...); err != nil {
5353
message.WarnErr(err, "Unable to execute tar on this system. Please ensure it is installed and on your $PATH.")

src/pkg/utils/exec/exec.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ type Config struct {
2727
Stderr io.Writer
2828
}
2929

30-
// ExecShell represents the desired shell to use for a given command
31-
type ExecShell struct {
30+
// Shell represents the desired shell to use for a given command
31+
type Shell struct {
3232
Windows string `json:"windows,omitempty" jsonschema:"description=(default 'powershell') Indicates a preference for the shell to use on Windows systems (note that choosing 'cmd' will turn off migrations like touch -> New-Item),example=powershell,example=cmd,example=pwsh,example=sh,example=bash,example=gsh"`
3333
Linux string `json:"linux,omitempty" jsonschema:"description=(default 'sh') Indicates a preference for the shell to use on Linux systems,example=sh,example=bash,example=fish,example=zsh,example=pwsh"`
3434
Darwin string `json:"darwin,omitempty" jsonschema:"description=(default 'sh') Indicates a preference for the shell to use on macOS systems,example=sh,example=bash,example=fish,example=zsh,example=pwsh"`
@@ -153,7 +153,7 @@ func LaunchURL(url string) error {
153153
}
154154

155155
// GetOSShell returns the shell and shellArgs based on the current OS
156-
func GetOSShell(shellPref ExecShell) (string, []string) {
156+
func GetOSShell(shellPref Shell) (string, []string) {
157157
var shell string
158158
var shellArgs []string
159159
powershellShellArgs := []string{"-Command", "$ErrorActionPreference = 'Stop';"}

src/pkg/utils/wait.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func ExecuteWait(waitTimeout, waitNamespace, condition, kind, identifier string,
7878
spinner := message.NewProgressSpinner(existMsg)
7979

8080
// Get the OS shell to execute commands in
81-
shell, shellArgs := exec.GetOSShell(exec.ExecShell{Windows: "cmd"})
81+
shell, shellArgs := exec.GetOSShell(exec.Shell{Windows: "cmd"})
8282

8383
defer spinner.Stop()
8484

0 commit comments

Comments
 (0)