Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pkg/workflow/firewall_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,34 @@

package workflow

import "fmt"
import (
"fmt"

"github.com/github/gh-aw/pkg/logger"
)

var firewallValidationLog = logger.New("workflow:firewall_validation")

// ValidateLogLevel validates that a firewall log-level value is one of the allowed enum values.
// Valid values are: "debug", "info", "warn", "error".
// Empty string is allowed as it defaults to "info" at runtime.
// Returns an error if the log-level is invalid.
func ValidateLogLevel(level string) error {
firewallValidationLog.Printf("Validating firewall log-level: %s", level)

// Empty string is allowed (defaults to "info")
if level == "" {
firewallValidationLog.Print("Empty log-level, using default")
return nil
}

valid := []string{"debug", "info", "warn", "error"}
for _, v := range valid {
if level == v {
firewallValidationLog.Printf("Valid log-level: %s", level)
return nil
}
}
firewallValidationLog.Printf("Invalid log-level: %s", level)
return fmt.Errorf("invalid log-level '%s', must be one of: %v", level, valid)
}
12 changes: 12 additions & 0 deletions pkg/workflow/noop.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package workflow

import (
"github.com/github/gh-aw/pkg/logger"
)

var noopLog = logger.New("workflow:noop")

// NoOpConfig holds configuration for no-op safe output (logging only)
type NoOpConfig struct {
BaseSafeOutputConfig `yaml:",inline"`
Expand All @@ -8,8 +14,11 @@ type NoOpConfig struct {
// parseNoOpConfig handles noop configuration
func (c *Compiler) parseNoOpConfig(outputMap map[string]any) *NoOpConfig {
if configData, exists := outputMap["noop"]; exists {
noopLog.Print("Parsing noop configuration from safe-outputs")

// Handle the case where configData is false (explicitly disabled)
if configBool, ok := configData.(bool); ok && !configBool {
noopLog.Print("Noop explicitly disabled")
return nil
}

Expand All @@ -19,16 +28,19 @@ func (c *Compiler) parseNoOpConfig(outputMap map[string]any) *NoOpConfig {
if configData == nil {
// Set default max for noop messages
noopConfig.Max = 1
noopLog.Print("Noop enabled with default max=1")
return noopConfig
}

if configMap, ok := configData.(map[string]any); ok {
// Parse common base fields with default max of 1
c.parseBaseSafeOutputConfig(configMap, &noopConfig.BaseSafeOutputConfig, 1)
noopLog.Printf("Parsed noop configuration: max=%d", noopConfig.Max)
}

return noopConfig
}

noopLog.Print("No noop configuration found")
return nil
}
10 changes: 10 additions & 0 deletions pkg/workflow/runtime_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package workflow

import (
"github.com/github/gh-aw/pkg/constants"
"github.com/github/gh-aw/pkg/logger"
)

var runtimeDefLog = logger.New("workflow:runtime_definitions")

// Runtime represents configuration for a runtime environment
type Runtime struct {
ID string // Unique identifier (e.g., "node", "python")
Expand Down Expand Up @@ -143,27 +146,34 @@ var commandToRuntime map[string]*Runtime
var actionRepoToRuntime map[string]*Runtime

func init() {
runtimeDefLog.Printf("Initializing runtime definitions: total_runtimes=%d", len(knownRuntimes))

// Build the command to runtime mapping
commandToRuntime = make(map[string]*Runtime)
for _, runtime := range knownRuntimes {
for _, cmd := range runtime.Commands {
commandToRuntime[cmd] = runtime
}
}
runtimeDefLog.Printf("Built command to runtime mapping: total_commands=%d", len(commandToRuntime))

// Build the action repo to runtime mapping
actionRepoToRuntime = make(map[string]*Runtime)
for _, runtime := range knownRuntimes {
actionRepoToRuntime[runtime.ActionRepo] = runtime
}
runtimeDefLog.Printf("Built action repo to runtime mapping: total_actions=%d", len(actionRepoToRuntime))
}

// findRuntimeByID finds a runtime configuration by its ID
func findRuntimeByID(id string) *Runtime {
runtimeDefLog.Printf("Finding runtime by ID: %s", id)
for _, runtime := range knownRuntimes {
if runtime.ID == id {
runtimeDefLog.Printf("Found runtime: %s (%s)", runtime.ID, runtime.Name)
return runtime
}
}
runtimeDefLog.Printf("Runtime not found: %s", id)
return nil
}
8 changes: 8 additions & 0 deletions pkg/workflow/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package workflow

import (
"github.com/github/gh-aw/pkg/logger"
)

var versionLog = logger.New("workflow:version")

// compilerVersion holds the version of the compiler, set at runtime.
// This is used to include version information in generated workflow headers.
var compilerVersion = "dev"
Expand All @@ -12,6 +18,7 @@ var isReleaseBuild = false
// SetVersion sets the compiler version for inclusion in generated workflow headers.
// Only non-dev versions are included in the generated headers.
func SetVersion(v string) {
versionLog.Printf("Setting compiler version: %s", v)
compilerVersion = v
}

Expand All @@ -22,6 +29,7 @@ func GetVersion() string {

// SetIsRelease sets whether this binary was built as a release.
func SetIsRelease(release bool) {
versionLog.Printf("Setting release build flag: %v", release)
isReleaseBuild = release
}

Expand Down