diff --git a/.chloggen/semconv_add_only_flag.yaml b/.chloggen/semconv_add_only_flag.yaml new file mode 100755 index 00000000..b569aeb9 --- /dev/null +++ b/.chloggen/semconv_add_only_flag.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. crosslink) +component: semconvgen + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: add only flag to proccess only a specified type + +# One or more tracking issues related to the change +issues: [216] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/semconvgen/generator.go b/semconvgen/generator.go index 568210b0..8b6bb987 100644 --- a/semconvgen/generator.go +++ b/semconvgen/generator.go @@ -41,6 +41,7 @@ func main() { cfg := config{} flag.StringVarP(&cfg.inputPath, "input", "i", "", "Path to semantic convention definition YAML. Should be a directory in the specification git repository.") + flag.StringVarP(&cfg.onlyType, "only", "", "", "Process only semantic conventions of the specified type. {span,resource,event,metric,units,scope}") flag.StringVarP(&cfg.specVersion, "specver", "s", "", "Version of semantic convention to generate. Must be an existing version tag in the specification git repository.") flag.StringVarP(&cfg.outputPath, "output", "o", "", "Path to output target. Must be either an absolute path or relative to the repository root. If unspecified will output to a sub-directory with the name matching the version number specified via --specver flag.") flag.StringVarP(&cfg.containerImage, "container", "c", "otel/semconvgen", "Container image ID") @@ -78,6 +79,7 @@ type config struct { outputFilename string templateFilename string templateParameters string + onlyType string containerImage string specVersion string } @@ -165,10 +167,17 @@ func render(cfg config) error { "-v", fmt.Sprintf("%s:/data", tmpDir), cfg.containerImage, "--yaml-root", path.Join("/data/input/semantic_conventions/", path.Base(cfg.inputPath)), + "--only", cfg.onlyType, + } + if cfg.onlyType != "" { + args = append(args, "--only", cfg.onlyType) + } + + args = append(args, "code", "--template", path.Join("/data", path.Base(cfg.templateFilename)), "--output", path.Join("/data/output", path.Base(cfg.outputFilename)), - } + ) if cfg.templateParameters != "" { args = append(args, "--parameters", cfg.templateParameters) }