Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semconvgen: add only flag to proccess only a specified type #217

Merged
merged 2 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
10 changes: 9 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,16 @@ 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)),
}
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