Skip to content

Commit

Permalink
semconvgen: add only flag to proccess only a specified type
Browse files Browse the repository at this point in the history
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
  • Loading branch information
frzifus committed Jan 6, 2023
1 parent 197f254 commit f894f78
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .chloggen/semconv_add_only_flag.yaml
Original file line number Diff line number Diff line change
@@ -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:
11 changes: 10 additions & 1 deletion semconvgen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -78,6 +79,7 @@ type config struct {
outputFilename string
templateFilename string
templateParameters string
onlyType string
containerImage string
specVersion string
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit f894f78

Please sign in to comment.