Files
Israel BlancasandGitHub c6c09b4fe6 [chore] [schemagen] Move reusable modules to internal module (#15202)
#### Description
Move some reusable modules to an internal package. Those modules can be
used by `schemagen` and `ocb` to generate a big schema that users can
use to validate OpenTelemetry Collector configuations.

<!-- Issue number if applicable -->
#### Link to tracking issue
Updates #15010

---------

Signed-off-by: Israel Blancas <[email protected]>
2026-05-06 19:01:56 +00:00

24 lines
573 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package schemagen // import "go.opentelemetry.io/collector/internal/schemagen"
import (
"os"
"path/filepath"
)
const fileName = "config.schema.json"
// WriteJSONSchema writes the given ConfigMetadata as a JSON Schema file
// named "config.schema.json" in the specified directory.
func WriteJSONSchema(dir string, md *ConfigMetadata) error {
filePath := filepath.Join(dir, fileName)
data, err := md.ToJSON()
if err != nil {
return err
}
return os.WriteFile(filePath, data, 0o600)
}