Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add validation for deployer test system configuration
  • Loading branch information
mrodm committed Jun 6, 2025
commit 1264d69c1c4713596be82ac9da2b0c106467da97
11 changes: 10 additions & 1 deletion internal/testrunner/runners/system/test_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path/filepath"
"regexp"
"slices"
"strings"
"time"

Expand All @@ -24,7 +25,10 @@ import (
"github.com/elastic/elastic-package/internal/testrunner"
)

var systemTestConfigFilePattern = regexp.MustCompile(`^test-([a-z0-9_.-]+)-config.yml$`)
var (
systemTestConfigFilePattern = regexp.MustCompile(`^test-([a-z0-9_.-]+)-config.yml$`)
allowedDeployerNames = []string{"docker", "k8s", "tf"}
)

type testConfig struct {
testrunner.SkippableConfig `config:",inline"`
Expand Down Expand Up @@ -131,6 +135,11 @@ func newConfig(configFilePath string, svcInfo servicedeployer.ServiceInfo, servi
c.Agent.PreStartScript.Language = agentdeployer.DefaultAgentProgrammingLanguage
}

// Not included in package-spec validation for deployer name
if c.Deployer != "" && !slices.Contains(allowedDeployerNames, c.Deployer) {
return nil, fmt.Errorf("invalid deployer name %q in system test configuration file %q, allowed values are: %s", c.Deployer, configFilePath, strings.Join(allowedDeployerNames, ", "))
}
Comment on lines +138 to +141
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added validation here instead of package-spec. In package-spec this file has additionalProperties: true


return &c, nil
}

Expand Down