mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
#### 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]>
24 lines
573 B
Go
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)
|
|
}
|