Skip to content

Commit be52505

Browse files
mvicknrclaude
andauthored
chore: Make schema file optional for now (#9)
Co-authored-by: Claude <[email protected]>
1 parent 8b16277 commit be52505

File tree

5 files changed

+38
-23
lines changed

5 files changed

+38
-23
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Agent Metadata Action
44

5-
A GitHub Action that reads agent configuration metadata from the calling repository. This action parses the `.fleetControl/configurationDefinitions.yml` file and makes the configuration data available for downstream workflow steps.
5+
A GitHub Action that reads agent configuration metadata from the calling repository. This action parses the `.fleetControl/configurationDefinitions.yml` file and makes the configuration data available in New Relic.
66

77
## Installation
88

@@ -62,17 +62,17 @@ For the agent scenario, the action expects a YAML file at `.fleetControl/configu
6262

6363
```yaml
6464
configurationDefinitions:
65-
- platform: "kubernetes" # or "host"
65+
- platform: "kubernetes" # or "host" or "all" if there is no distinction
6666
description: "Description of the configuration"
6767
type: "config-type"
68-
version: "1.0.0"
69-
format: "json"
68+
version: "1.0.0" -- config schema version
69+
format: "json" -- format of the agent config file
7070
schema: "./schemas/config-schema.json"
7171
```
7272

7373
**All fields are required.** The action validates each configuration entry and will fail with a clear error message if any required field is missing (version, platform, description, type, format, schema).
74-
75-
**Schema files** are automatically base64-encoded and embedded in the output. Schema paths must be relative to the `.fleetControl` directory and cannot use directory traversal (`..`) for security.
74+
**Dec 2025 - schema temporarily optional until full functionality is ready
75+
**Schema paths must be relative to the `.fleetControl` directory and cannot use directory traversal (`..`) for security.
7676

7777
## Building
7878

internal/config/definitions.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ func ReadConfigurationDefinitions(workspacePath string) ([]models.ConfigurationD
3636
return nil, fmt.Errorf("configurationDefinitions cannot be empty")
3737
}
3838

39-
// Load and encode schema files (schema is required by validation)
39+
// Load and encode schema files (schema is optional for now but will be required in the future)
4040
for i := range configFile.Configs {
41+
// Skip if no schema path is provided
42+
if configFile.Configs[i].Schema == "" {
43+
continue
44+
}
45+
4146
// @todo at some point, we may want to do this concurrently if there are any agents with a large number of files
4247
encoded, err := loadAndEncodeSchema(workspacePath, configFile.Configs[i].Schema)
4348
if err != nil {

internal/config/definitions_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func TestReadConfigurationDefinitions_ValidationIntegration(t *testing.T) {
256256
err := os.MkdirAll(configDir, 0755)
257257
require.NoError(t, err)
258258

259-
// Test one example to verify validation works end-to-end
259+
// Test that schema is optional (will be required in the future)
260260
configFile := filepath.Join(configDir, "configurationDefinitions.yml")
261261
yamlContent := `configurationDefinitions:
262262
- version: 1.2.3
@@ -269,9 +269,9 @@ func TestReadConfigurationDefinitions_ValidationIntegration(t *testing.T) {
269269
require.NoError(t, err)
270270

271271
configs, err := ReadConfigurationDefinitions(tmpDir)
272-
assert.Error(t, err)
273-
assert.Nil(t, configs)
274-
assert.Contains(t, err.Error(), "schema is required")
272+
require.NoError(t, err)
273+
assert.Len(t, configs, 1)
274+
assert.Equal(t, "", configs[0].Schema) // Schema is empty when not provided
275275
}
276276

277277
func TestReadConfigurationDefinitions_EmptyArray(t *testing.T) {

internal/models/models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func (c *ConfigurationDefinition) UnmarshalYAML(node *yaml.Node) error {
4040
}
4141

4242
// Validate all required fields
43+
// Note: schema is currently optional but will be required in the future
4344
for _, check := range []struct {
4445
value string
4546
field string
@@ -49,7 +50,6 @@ func (c *ConfigurationDefinition) UnmarshalYAML(node *yaml.Node) error {
4950
{raw.Description, "description"},
5051
{raw.Type, "type"},
5152
{raw.Format, "format"},
52-
{raw.Schema, "schema"},
5353
} {
5454
if err := requireField(check.value, check.field, context); err != nil {
5555
return err

internal/models/models_test.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,6 @@ schema: ./schema.json
9191
`,
9292
expectedError: "format is required",
9393
},
94-
{
95-
name: "missing schema",
96-
yamlData: `
97-
version: 1.0.0
98-
platform: kubernetes
99-
description: A test configuration
100-
type: test-type
101-
format: json
102-
`,
103-
expectedError: "schema is required",
104-
},
10594
}
10695

10796
for _, tt := range tests {
@@ -130,6 +119,27 @@ schema: ./schema.json
130119
assert.Contains(t, err.Error(), "platform is required for config with type 'mytype' and version '1.0.0'")
131120
}
132121

122+
func TestConfigurationDefinition_UnmarshalYAML_OptionalSchema(t *testing.T) {
123+
// Schema is optional (for now, but will be required in the future)
124+
yamlData := `
125+
version: 1.0.0
126+
platform: kubernetes
127+
description: A test configuration
128+
type: test-type
129+
format: json
130+
`
131+
var config ConfigurationDefinition
132+
err := yaml.Unmarshal([]byte(yamlData), &config)
133+
134+
require.NoError(t, err)
135+
assert.Equal(t, "1.0.0", config.Version)
136+
assert.Equal(t, "kubernetes", config.Platform)
137+
assert.Equal(t, "A test configuration", config.Description)
138+
assert.Equal(t, "test-type", config.Type)
139+
assert.Equal(t, "json", config.Format)
140+
assert.Equal(t, "", config.Schema) // Schema is empty when not provided
141+
}
142+
133143
func TestRequireField_ValidValue(t *testing.T) {
134144
err := requireField("some-value", "fieldName", "")
135145
assert.NoError(t, err)

0 commit comments

Comments
 (0)