From 4014b97ef7b2eb6808843111b6f349b18457af6d Mon Sep 17 00:00:00 2001 From: Eric Wennerberg Date: Tue, 9 Aug 2022 14:14:48 +0200 Subject: [PATCH] fix: rename exclude resource definitions flag Aligns with aip-go. --- README.md | 4 ++-- internal/plugin/generate.go | 2 +- internal/plugin/options.go | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 66b0483..75cd41f 100644 --- a/README.md +++ b/README.md @@ -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. ``` --- diff --git a/internal/plugin/generate.go b/internal/plugin/generate.go index 9eb253c..35a45c8 100644 --- a/internal/plugin/generate.go +++ b/internal/plugin/generate.go @@ -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) diff --git a/internal/plugin/options.go b/internal/plugin/options.go index 91bcea9..69ad671 100644 --- a/internal/plugin/options.go +++ b/internal/plugin/options.go @@ -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 { @@ -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) }