Skip to content

Commit

Permalink
fix: rename exclude resource definitions flag
Browse files Browse the repository at this point in the history
Aligns with aip-go.
  • Loading branch information
ericwenn committed Aug 9, 2022
1 parent dfba348 commit 4014b97
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ insertion_point If non-empty, indicates that the named file should alrea
and the content here is to be inserted into that file at a defined
insertion point.

skip_file_resource_definitions
exclude_resource_definitions
If set to true, resource names will not be generated for resource definitions
in the file scope. Default: false.
in the file scope, only on messages. Default: false.
```
---
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Generate(request *pluginpb.CodeGeneratorRequest) (*pluginpb.CodeGeneratorRe
if _, ok := generate[descriptor.ParentFile]; !ok {
return true
}
if opts.SkipFileResourceDefinitions && !isMessageResourceDescriptor(descriptor) {
if opts.ExcludeResourceDefinitions && !isMessageResourceDescriptor(descriptor) {
return true
}
dir := path.Dir(descriptor.ParentFile)
Expand Down
12 changes: 6 additions & 6 deletions internal/plugin/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type Options struct {
// Defaults to `""` (ie. no insertion point)
InsertionPoint string

// SkipFileResourceDefinitions disables generation of resource names
// declared in the file scope.
// ExcludeResourceDefinitions disables generation of resource names
// based on resource definitions in the file.
// Defaults to false.
SkipFileResourceDefinitions bool
ExcludeResourceDefinitions bool
}

func defaultOptions() Options {
Expand Down Expand Up @@ -51,12 +51,12 @@ func (o *Options) Unmarshal(s *string) error {
o.InsertionPoint = value
case "filename":
o.Filename = value
case "skip_file_resource_definitions":
case "":
b, err := unmarshalBool(value)
if err != nil {
return fmt.Errorf("unmarshal skip_file_resource_definitions: %w", err)
return fmt.Errorf("unmarshal exclude_resource_definitions: %w", err)
}
o.SkipFileResourceDefinitions = b
o.ExcludeResourceDefinitions = b
default:
return fmt.Errorf("unknown option [%s]", opt)
}
Expand Down

0 comments on commit 4014b97

Please sign in to comment.