From 0122cae7da0a7568cee50f38ba7f3cd31d5375d4 Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Wed, 29 Jan 2025 14:37:58 +0000 Subject: [PATCH 01/10] first draft --- cmd/sqlc-template/main.go | 102 ++ go.mod | 8 + go.sum | 8 + pkg/sqlc/plugin/codegen.pb.go | 1644 +++++++++++++++++++++++++++++++++ pkg/sqlc/plugin/codegen.proto | 130 +++ 5 files changed, 1892 insertions(+) create mode 100644 cmd/sqlc-template/main.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 pkg/sqlc/plugin/codegen.pb.go create mode 100644 pkg/sqlc/plugin/codegen.proto diff --git a/cmd/sqlc-template/main.go b/cmd/sqlc-template/main.go new file mode 100644 index 0000000..260c000 --- /dev/null +++ b/cmd/sqlc-template/main.go @@ -0,0 +1,102 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "os" + "strings" + "text/template" + + "github.com/iancoleman/strcase" + "google.golang.org/protobuf/proto" + + "github.com/NMFR/sqlc-template/pkg/sqlc/plugin" +) + +type PluginOptions struct { + Filename *string `json:"filename,omitempty"` + Template *string `json:"template,omitempty"` +} + +func generate(request *plugin.GenerateRequest) (*plugin.GenerateResponse, error) { + pluginOptions := &PluginOptions{} + if err := json.Unmarshal(request.GetPluginOptions(), pluginOptions); err != nil { + return nil, fmt.Errorf("failed to parse the sqlc 'plugin options' field to JSON, %w", err) + } + + if pluginOptions.Filename == nil { + return nil, fmt.Errorf("missing the 'filename' plugin option") + } + + if pluginOptions.Template == nil { + return nil, fmt.Errorf("missing the 'template' plugin option") + } + + funcMap := template.FuncMap{ + "Replace": strings.Replace, + "ReplaceAll": strings.ReplaceAll, + "ToLower": strings.ToLower, + "ToUpper": strings.ToUpper, + "TrimSpace": strings.TrimSpace, + + "ToSnake": strcase.ToSnake, //(s) any_kind_of_string + "ToSnakeWithIgnore": strcase.ToSnakeWithIgnore, //(s, '.') any_kind.of_string + "ToScreamingSnake": strcase.ToScreamingSnake, //(s) ANY_KIND_OF_STRING + "ToKebab": strcase.ToKebab, //(s) any-kind-of-string + "ToScreamingKebab": strcase.ToScreamingKebab, //(s) ANY-KIND-OF-STRING + "ToDelimited": strcase.ToDelimited, //(s, '.') any.kind.of.string + "ToScreamingDelimited": strcase.ToScreamingDelimited, //(s, '.', ' ', true) ANY.KIND OF.STRING + "ToCamel": strcase.ToCamel, //(s) AnyKindOfString + "ToLowerCamel": strcase.ToLowerCamel, //(s) anyKindOfString + } + + tmpl, err := template.New("template").Funcs(funcMap).Parse(*pluginOptions.Template) + if err != nil { + return nil, fmt.Errorf("failed to parse the provided template, %w", err) + } + + buf := bytes.Buffer{} + if err := tmpl.Execute(&buf, request); err != nil { + return nil, fmt.Errorf("failed to execute the provided template, %w", err) + } + + json, err := json.Marshal(request) + if err != nil { + panic(fmt.Errorf("failed to convert to JSON, %w", err)) + } + + return &plugin.GenerateResponse{ + Files: []*plugin.File{ + {Name: *pluginOptions.Filename, Contents: buf.Bytes()}, + {Name: "input.json", Contents: []byte(json)}, + }, + }, nil +} + +func main() { + stdin, err := io.ReadAll(os.Stdin) + if err != nil { + panic(fmt.Errorf("failed to read from stdin, %w", err)) + } + + request := &plugin.GenerateRequest{} + if err := proto.Unmarshal(stdin, request); err != nil { + panic(fmt.Errorf("failed to parse / unmarshal the sqlc request, %w", err)) + } + + response, err := generate(request) + if err != nil { + panic(fmt.Errorf("failed to generate, %w", err)) + } + + out, err := proto.Marshal(response) + if err != nil { + panic(fmt.Errorf("failed to format / marshal the sqlc response, %w", err)) + } + + if _, err = os.Stdout.Write(out); err != nil { + panic(fmt.Errorf("failed to write to stdout, %w", err)) + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..47ab726 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/NMFR/sqlc-template + +go 1.21.4 + +require ( + github.com/iancoleman/strcase v0.3.0 + google.golang.org/protobuf v1.36.4 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..0f681c8 --- /dev/null +++ b/go.sum @@ -0,0 +1,8 @@ +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= +google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= diff --git a/pkg/sqlc/plugin/codegen.pb.go b/pkg/sqlc/plugin/codegen.pb.go new file mode 100644 index 0000000..29f4143 --- /dev/null +++ b/pkg/sqlc/plugin/codegen.pb.go @@ -0,0 +1,1644 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.1 +// source: pkg/sqlc/plugin/codegen.proto + +package plugin + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type File struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Contents []byte `protobuf:"bytes,2,opt,name=contents,proto3" json:"contents,omitempty"` +} + +func (x *File) Reset() { + *x = File{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *File) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*File) ProtoMessage() {} + +func (x *File) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use File.ProtoReflect.Descriptor instead. +func (*File) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{0} +} + +func (x *File) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *File) GetContents() []byte { + if x != nil { + return x.Contents + } + return nil +} + +type Settings struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Engine string `protobuf:"bytes,2,opt,name=engine,proto3" json:"engine,omitempty"` + Schema []string `protobuf:"bytes,3,rep,name=schema,proto3" json:"schema,omitempty"` + Queries []string `protobuf:"bytes,4,rep,name=queries,proto3" json:"queries,omitempty"` + Codegen *Codegen `protobuf:"bytes,12,opt,name=codegen,proto3" json:"codegen,omitempty"` +} + +func (x *Settings) Reset() { + *x = Settings{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Settings) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Settings) ProtoMessage() {} + +func (x *Settings) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Settings.ProtoReflect.Descriptor instead. +func (*Settings) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{1} +} + +func (x *Settings) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *Settings) GetEngine() string { + if x != nil { + return x.Engine + } + return "" +} + +func (x *Settings) GetSchema() []string { + if x != nil { + return x.Schema + } + return nil +} + +func (x *Settings) GetQueries() []string { + if x != nil { + return x.Queries + } + return nil +} + +func (x *Settings) GetCodegen() *Codegen { + if x != nil { + return x.Codegen + } + return nil +} + +type Codegen struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Out string `protobuf:"bytes,1,opt,name=out,proto3" json:"out,omitempty"` + Plugin string `protobuf:"bytes,2,opt,name=plugin,proto3" json:"plugin,omitempty"` + Options []byte `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` + Env []string `protobuf:"bytes,4,rep,name=env,proto3" json:"env,omitempty"` + Process *Codegen_Process `protobuf:"bytes,5,opt,name=process,proto3" json:"process,omitempty"` + Wasm *Codegen_WASM `protobuf:"bytes,6,opt,name=wasm,proto3" json:"wasm,omitempty"` +} + +func (x *Codegen) Reset() { + *x = Codegen{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Codegen) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Codegen) ProtoMessage() {} + +func (x *Codegen) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Codegen.ProtoReflect.Descriptor instead. +func (*Codegen) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{2} +} + +func (x *Codegen) GetOut() string { + if x != nil { + return x.Out + } + return "" +} + +func (x *Codegen) GetPlugin() string { + if x != nil { + return x.Plugin + } + return "" +} + +func (x *Codegen) GetOptions() []byte { + if x != nil { + return x.Options + } + return nil +} + +func (x *Codegen) GetEnv() []string { + if x != nil { + return x.Env + } + return nil +} + +func (x *Codegen) GetProcess() *Codegen_Process { + if x != nil { + return x.Process + } + return nil +} + +func (x *Codegen) GetWasm() *Codegen_WASM { + if x != nil { + return x.Wasm + } + return nil +} + +type Catalog struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Comment string `protobuf:"bytes,1,opt,name=comment,proto3" json:"comment,omitempty"` + DefaultSchema string `protobuf:"bytes,2,opt,name=default_schema,json=defaultSchema,proto3" json:"default_schema,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Schemas []*Schema `protobuf:"bytes,4,rep,name=schemas,proto3" json:"schemas,omitempty"` +} + +func (x *Catalog) Reset() { + *x = Catalog{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Catalog) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Catalog) ProtoMessage() {} + +func (x *Catalog) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Catalog.ProtoReflect.Descriptor instead. +func (*Catalog) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{3} +} + +func (x *Catalog) GetComment() string { + if x != nil { + return x.Comment + } + return "" +} + +func (x *Catalog) GetDefaultSchema() string { + if x != nil { + return x.DefaultSchema + } + return "" +} + +func (x *Catalog) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Catalog) GetSchemas() []*Schema { + if x != nil { + return x.Schemas + } + return nil +} + +type Schema struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Comment string `protobuf:"bytes,1,opt,name=comment,proto3" json:"comment,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Tables []*Table `protobuf:"bytes,3,rep,name=tables,proto3" json:"tables,omitempty"` + Enums []*Enum `protobuf:"bytes,4,rep,name=enums,proto3" json:"enums,omitempty"` + CompositeTypes []*CompositeType `protobuf:"bytes,5,rep,name=composite_types,json=compositeTypes,proto3" json:"composite_types,omitempty"` +} + +func (x *Schema) Reset() { + *x = Schema{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Schema) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Schema) ProtoMessage() {} + +func (x *Schema) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Schema.ProtoReflect.Descriptor instead. +func (*Schema) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{4} +} + +func (x *Schema) GetComment() string { + if x != nil { + return x.Comment + } + return "" +} + +func (x *Schema) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Schema) GetTables() []*Table { + if x != nil { + return x.Tables + } + return nil +} + +func (x *Schema) GetEnums() []*Enum { + if x != nil { + return x.Enums + } + return nil +} + +func (x *Schema) GetCompositeTypes() []*CompositeType { + if x != nil { + return x.CompositeTypes + } + return nil +} + +type CompositeType struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Comment string `protobuf:"bytes,2,opt,name=comment,proto3" json:"comment,omitempty"` +} + +func (x *CompositeType) Reset() { + *x = CompositeType{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CompositeType) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CompositeType) ProtoMessage() {} + +func (x *CompositeType) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CompositeType.ProtoReflect.Descriptor instead. +func (*CompositeType) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{5} +} + +func (x *CompositeType) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CompositeType) GetComment() string { + if x != nil { + return x.Comment + } + return "" +} + +type Enum struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Vals []string `protobuf:"bytes,2,rep,name=vals,proto3" json:"vals,omitempty"` + Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"` +} + +func (x *Enum) Reset() { + *x = Enum{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Enum) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Enum) ProtoMessage() {} + +func (x *Enum) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Enum.ProtoReflect.Descriptor instead. +func (*Enum) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{6} +} + +func (x *Enum) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Enum) GetVals() []string { + if x != nil { + return x.Vals + } + return nil +} + +func (x *Enum) GetComment() string { + if x != nil { + return x.Comment + } + return "" +} + +type Table struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rel *Identifier `protobuf:"bytes,1,opt,name=rel,proto3" json:"rel,omitempty"` + Columns []*Column `protobuf:"bytes,2,rep,name=columns,proto3" json:"columns,omitempty"` + Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"` +} + +func (x *Table) Reset() { + *x = Table{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Table) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Table) ProtoMessage() {} + +func (x *Table) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Table.ProtoReflect.Descriptor instead. +func (*Table) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{7} +} + +func (x *Table) GetRel() *Identifier { + if x != nil { + return x.Rel + } + return nil +} + +func (x *Table) GetColumns() []*Column { + if x != nil { + return x.Columns + } + return nil +} + +func (x *Table) GetComment() string { + if x != nil { + return x.Comment + } + return "" +} + +type Identifier struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Catalog string `protobuf:"bytes,1,opt,name=catalog,proto3" json:"catalog,omitempty"` + Schema string `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *Identifier) Reset() { + *x = Identifier{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Identifier) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Identifier) ProtoMessage() {} + +func (x *Identifier) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Identifier.ProtoReflect.Descriptor instead. +func (*Identifier) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{8} +} + +func (x *Identifier) GetCatalog() string { + if x != nil { + return x.Catalog + } + return "" +} + +func (x *Identifier) GetSchema() string { + if x != nil { + return x.Schema + } + return "" +} + +func (x *Identifier) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type Column struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + NotNull bool `protobuf:"varint,3,opt,name=not_null,json=notNull,proto3" json:"not_null,omitempty"` + IsArray bool `protobuf:"varint,4,opt,name=is_array,json=isArray,proto3" json:"is_array,omitempty"` + Comment string `protobuf:"bytes,5,opt,name=comment,proto3" json:"comment,omitempty"` + Length int32 `protobuf:"varint,6,opt,name=length,proto3" json:"length,omitempty"` + IsNamedParam bool `protobuf:"varint,7,opt,name=is_named_param,json=isNamedParam,proto3" json:"is_named_param,omitempty"` + IsFuncCall bool `protobuf:"varint,8,opt,name=is_func_call,json=isFuncCall,proto3" json:"is_func_call,omitempty"` + // XXX: Figure out what PostgreSQL calls `foo.id` + Scope string `protobuf:"bytes,9,opt,name=scope,proto3" json:"scope,omitempty"` + Table *Identifier `protobuf:"bytes,10,opt,name=table,proto3" json:"table,omitempty"` + TableAlias string `protobuf:"bytes,11,opt,name=table_alias,json=tableAlias,proto3" json:"table_alias,omitempty"` + Type *Identifier `protobuf:"bytes,12,opt,name=type,proto3" json:"type,omitempty"` + IsSqlcSlice bool `protobuf:"varint,13,opt,name=is_sqlc_slice,json=isSqlcSlice,proto3" json:"is_sqlc_slice,omitempty"` + EmbedTable *Identifier `protobuf:"bytes,14,opt,name=embed_table,json=embedTable,proto3" json:"embed_table,omitempty"` + OriginalName string `protobuf:"bytes,15,opt,name=original_name,json=originalName,proto3" json:"original_name,omitempty"` + Unsigned bool `protobuf:"varint,16,opt,name=unsigned,proto3" json:"unsigned,omitempty"` + ArrayDims int32 `protobuf:"varint,17,opt,name=array_dims,json=arrayDims,proto3" json:"array_dims,omitempty"` +} + +func (x *Column) Reset() { + *x = Column{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Column) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Column) ProtoMessage() {} + +func (x *Column) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Column.ProtoReflect.Descriptor instead. +func (*Column) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{9} +} + +func (x *Column) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Column) GetNotNull() bool { + if x != nil { + return x.NotNull + } + return false +} + +func (x *Column) GetIsArray() bool { + if x != nil { + return x.IsArray + } + return false +} + +func (x *Column) GetComment() string { + if x != nil { + return x.Comment + } + return "" +} + +func (x *Column) GetLength() int32 { + if x != nil { + return x.Length + } + return 0 +} + +func (x *Column) GetIsNamedParam() bool { + if x != nil { + return x.IsNamedParam + } + return false +} + +func (x *Column) GetIsFuncCall() bool { + if x != nil { + return x.IsFuncCall + } + return false +} + +func (x *Column) GetScope() string { + if x != nil { + return x.Scope + } + return "" +} + +func (x *Column) GetTable() *Identifier { + if x != nil { + return x.Table + } + return nil +} + +func (x *Column) GetTableAlias() string { + if x != nil { + return x.TableAlias + } + return "" +} + +func (x *Column) GetType() *Identifier { + if x != nil { + return x.Type + } + return nil +} + +func (x *Column) GetIsSqlcSlice() bool { + if x != nil { + return x.IsSqlcSlice + } + return false +} + +func (x *Column) GetEmbedTable() *Identifier { + if x != nil { + return x.EmbedTable + } + return nil +} + +func (x *Column) GetOriginalName() string { + if x != nil { + return x.OriginalName + } + return "" +} + +func (x *Column) GetUnsigned() bool { + if x != nil { + return x.Unsigned + } + return false +} + +func (x *Column) GetArrayDims() int32 { + if x != nil { + return x.ArrayDims + } + return 0 +} + +type Query struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Cmd string `protobuf:"bytes,3,opt,name=cmd,proto3" json:"cmd,omitempty"` + Columns []*Column `protobuf:"bytes,4,rep,name=columns,proto3" json:"columns,omitempty"` + Params []*Parameter `protobuf:"bytes,5,rep,name=params,json=parameters,proto3" json:"params,omitempty"` + Comments []string `protobuf:"bytes,6,rep,name=comments,proto3" json:"comments,omitempty"` + Filename string `protobuf:"bytes,7,opt,name=filename,proto3" json:"filename,omitempty"` + InsertIntoTable *Identifier `protobuf:"bytes,8,opt,name=insert_into_table,proto3" json:"insert_into_table,omitempty"` +} + +func (x *Query) Reset() { + *x = Query{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Query) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Query) ProtoMessage() {} + +func (x *Query) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Query.ProtoReflect.Descriptor instead. +func (*Query) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{10} +} + +func (x *Query) GetText() string { + if x != nil { + return x.Text + } + return "" +} + +func (x *Query) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Query) GetCmd() string { + if x != nil { + return x.Cmd + } + return "" +} + +func (x *Query) GetColumns() []*Column { + if x != nil { + return x.Columns + } + return nil +} + +func (x *Query) GetParams() []*Parameter { + if x != nil { + return x.Params + } + return nil +} + +func (x *Query) GetComments() []string { + if x != nil { + return x.Comments + } + return nil +} + +func (x *Query) GetFilename() string { + if x != nil { + return x.Filename + } + return "" +} + +func (x *Query) GetInsertIntoTable() *Identifier { + if x != nil { + return x.InsertIntoTable + } + return nil +} + +type Parameter struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` + Column *Column `protobuf:"bytes,2,opt,name=column,proto3" json:"column,omitempty"` +} + +func (x *Parameter) Reset() { + *x = Parameter{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Parameter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Parameter) ProtoMessage() {} + +func (x *Parameter) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Parameter.ProtoReflect.Descriptor instead. +func (*Parameter) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{11} +} + +func (x *Parameter) GetNumber() int32 { + if x != nil { + return x.Number + } + return 0 +} + +func (x *Parameter) GetColumn() *Column { + if x != nil { + return x.Column + } + return nil +} + +type GenerateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Settings *Settings `protobuf:"bytes,1,opt,name=settings,proto3" json:"settings,omitempty"` + Catalog *Catalog `protobuf:"bytes,2,opt,name=catalog,proto3" json:"catalog,omitempty"` + Queries []*Query `protobuf:"bytes,3,rep,name=queries,proto3" json:"queries,omitempty"` + SqlcVersion string `protobuf:"bytes,4,opt,name=sqlc_version,proto3" json:"sqlc_version,omitempty"` + PluginOptions []byte `protobuf:"bytes,5,opt,name=plugin_options,proto3" json:"plugin_options,omitempty"` + GlobalOptions []byte `protobuf:"bytes,6,opt,name=global_options,proto3" json:"global_options,omitempty"` +} + +func (x *GenerateRequest) Reset() { + *x = GenerateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenerateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenerateRequest) ProtoMessage() {} + +func (x *GenerateRequest) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GenerateRequest.ProtoReflect.Descriptor instead. +func (*GenerateRequest) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{12} +} + +func (x *GenerateRequest) GetSettings() *Settings { + if x != nil { + return x.Settings + } + return nil +} + +func (x *GenerateRequest) GetCatalog() *Catalog { + if x != nil { + return x.Catalog + } + return nil +} + +func (x *GenerateRequest) GetQueries() []*Query { + if x != nil { + return x.Queries + } + return nil +} + +func (x *GenerateRequest) GetSqlcVersion() string { + if x != nil { + return x.SqlcVersion + } + return "" +} + +func (x *GenerateRequest) GetPluginOptions() []byte { + if x != nil { + return x.PluginOptions + } + return nil +} + +func (x *GenerateRequest) GetGlobalOptions() []byte { + if x != nil { + return x.GlobalOptions + } + return nil +} + +type GenerateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Files []*File `protobuf:"bytes,1,rep,name=files,proto3" json:"files,omitempty"` +} + +func (x *GenerateResponse) Reset() { + *x = GenerateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenerateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenerateResponse) ProtoMessage() {} + +func (x *GenerateResponse) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GenerateResponse.ProtoReflect.Descriptor instead. +func (*GenerateResponse) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{13} +} + +func (x *GenerateResponse) GetFiles() []*File { + if x != nil { + return x.Files + } + return nil +} + +type Codegen_Process struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Cmd string `protobuf:"bytes,1,opt,name=cmd,proto3" json:"cmd,omitempty"` +} + +func (x *Codegen_Process) Reset() { + *x = Codegen_Process{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Codegen_Process) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Codegen_Process) ProtoMessage() {} + +func (x *Codegen_Process) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Codegen_Process.ProtoReflect.Descriptor instead. +func (*Codegen_Process) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{2, 0} +} + +func (x *Codegen_Process) GetCmd() string { + if x != nil { + return x.Cmd + } + return "" +} + +type Codegen_WASM struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + Sha256 string `protobuf:"bytes,2,opt,name=sha256,proto3" json:"sha256,omitempty"` +} + +func (x *Codegen_WASM) Reset() { + *x = Codegen_WASM{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Codegen_WASM) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Codegen_WASM) ProtoMessage() {} + +func (x *Codegen_WASM) ProtoReflect() protoreflect.Message { + mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Codegen_WASM.ProtoReflect.Descriptor instead. +func (*Codegen_WASM) Descriptor() ([]byte, []int) { + return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{2, 1} +} + +func (x *Codegen_WASM) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *Codegen_WASM) GetSha256() string { + if x != nil { + return x.Sha256 + } + return "" +} + +var File_pkg_sqlc_plugin_codegen_proto protoreflect.FileDescriptor + +var file_pkg_sqlc_plugin_codegen_proto_rawDesc = []byte{ + 0x0a, 0x1d, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, 0x36, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, + 0xb7, 0x01, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, + 0x12, 0x29, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x67, + 0x65, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x4a, 0x04, 0x08, 0x05, 0x10, + 0x06, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, + 0x0a, 0x10, 0x0b, 0x4a, 0x04, 0x08, 0x0b, 0x10, 0x0c, 0x22, 0x8b, 0x02, 0x0a, 0x07, 0x43, 0x6f, + 0x64, 0x65, 0x67, 0x65, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, + 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x76, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x12, 0x31, 0x0a, 0x07, 0x70, + 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x2e, 0x50, 0x72, + 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x28, + 0x0a, 0x04, 0x77, 0x61, 0x73, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x2e, 0x57, 0x41, + 0x53, 0x4d, 0x52, 0x04, 0x77, 0x61, 0x73, 0x6d, 0x1a, 0x1b, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x63, + 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x63, 0x6d, 0x64, 0x1a, 0x30, 0x0a, 0x04, 0x57, 0x41, 0x53, 0x4d, 0x12, 0x10, 0x0a, + 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, + 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x22, 0x88, 0x01, 0x0a, 0x07, 0x43, 0x61, 0x74, 0x61, + 0x6c, 0x6f, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, + 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x63, + 0x68, 0x65, 0x6d, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, + 0x61, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x06, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, + 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x74, + 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x06, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x73, 0x12, 0x22, 0x0a, 0x05, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52, + 0x05, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x12, 0x3e, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x22, 0x3d, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x48, 0x0a, 0x04, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x04, 0x76, 0x61, 0x6c, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, + 0x71, 0x0a, 0x05, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x24, 0x0a, 0x03, 0x72, 0x65, 0x6c, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x03, 0x72, 0x65, 0x6c, 0x12, 0x28, + 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, + 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, + 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x22, 0x52, 0x0a, 0x0a, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, + 0x12, 0x18, 0x0a, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, + 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x8e, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6c, 0x75, 0x6d, + 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x74, 0x5f, 0x6e, 0x75, 0x6c, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6e, 0x6f, 0x74, 0x4e, 0x75, 0x6c, 0x6c, + 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x24, 0x0a, + 0x0e, 0x69, 0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x12, 0x20, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x63, + 0x61, 0x6c, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x46, 0x75, 0x6e, + 0x63, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x05, 0x74, + 0x61, 0x62, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x05, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, + 0x6c, 0x69, 0x61, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x26, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x22, + 0x0a, 0x0d, 0x69, 0x73, 0x5f, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x18, + 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x53, 0x71, 0x6c, 0x63, 0x53, 0x6c, 0x69, + 0x63, 0x65, 0x12, 0x33, 0x0a, 0x0b, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x5f, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x0a, 0x65, 0x6d, 0x62, + 0x65, 0x64, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, + 0x6e, 0x61, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, + 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x72, 0x72, 0x61, + 0x79, 0x5f, 0x64, 0x69, 0x6d, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x44, 0x69, 0x6d, 0x73, 0x22, 0x94, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x6d, 0x64, 0x12, 0x28, 0x0a, 0x07, 0x63, + 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x07, 0x63, 0x6f, + 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x11, + 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x69, 0x6e, 0x73, + 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x4b, + 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, + 0x75, 0x6d, 0x6e, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x22, 0x87, 0x02, 0x0a, 0x0f, + 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x2c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x73, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x29, 0x0a, + 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, + 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, + 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x27, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, + 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, + 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, + 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, + 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x36, 0x0a, 0x10, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, 0x6c, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x32, 0x4f, 0x0a, + 0x0e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x3d, 0x0a, 0x08, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x65, + 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2f, + 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4e, 0x4d, 0x46, + 0x52, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2d, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2f, + 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_pkg_sqlc_plugin_codegen_proto_rawDescOnce sync.Once + file_pkg_sqlc_plugin_codegen_proto_rawDescData = file_pkg_sqlc_plugin_codegen_proto_rawDesc +) + +func file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP() []byte { + file_pkg_sqlc_plugin_codegen_proto_rawDescOnce.Do(func() { + file_pkg_sqlc_plugin_codegen_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_sqlc_plugin_codegen_proto_rawDescData) + }) + return file_pkg_sqlc_plugin_codegen_proto_rawDescData +} + +var file_pkg_sqlc_plugin_codegen_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_pkg_sqlc_plugin_codegen_proto_goTypes = []interface{}{ + (*File)(nil), // 0: plugin.File + (*Settings)(nil), // 1: plugin.Settings + (*Codegen)(nil), // 2: plugin.Codegen + (*Catalog)(nil), // 3: plugin.Catalog + (*Schema)(nil), // 4: plugin.Schema + (*CompositeType)(nil), // 5: plugin.CompositeType + (*Enum)(nil), // 6: plugin.Enum + (*Table)(nil), // 7: plugin.Table + (*Identifier)(nil), // 8: plugin.Identifier + (*Column)(nil), // 9: plugin.Column + (*Query)(nil), // 10: plugin.Query + (*Parameter)(nil), // 11: plugin.Parameter + (*GenerateRequest)(nil), // 12: plugin.GenerateRequest + (*GenerateResponse)(nil), // 13: plugin.GenerateResponse + (*Codegen_Process)(nil), // 14: plugin.Codegen.Process + (*Codegen_WASM)(nil), // 15: plugin.Codegen.WASM +} +var file_pkg_sqlc_plugin_codegen_proto_depIdxs = []int32{ + 2, // 0: plugin.Settings.codegen:type_name -> plugin.Codegen + 14, // 1: plugin.Codegen.process:type_name -> plugin.Codegen.Process + 15, // 2: plugin.Codegen.wasm:type_name -> plugin.Codegen.WASM + 4, // 3: plugin.Catalog.schemas:type_name -> plugin.Schema + 7, // 4: plugin.Schema.tables:type_name -> plugin.Table + 6, // 5: plugin.Schema.enums:type_name -> plugin.Enum + 5, // 6: plugin.Schema.composite_types:type_name -> plugin.CompositeType + 8, // 7: plugin.Table.rel:type_name -> plugin.Identifier + 9, // 8: plugin.Table.columns:type_name -> plugin.Column + 8, // 9: plugin.Column.table:type_name -> plugin.Identifier + 8, // 10: plugin.Column.type:type_name -> plugin.Identifier + 8, // 11: plugin.Column.embed_table:type_name -> plugin.Identifier + 9, // 12: plugin.Query.columns:type_name -> plugin.Column + 11, // 13: plugin.Query.params:type_name -> plugin.Parameter + 8, // 14: plugin.Query.insert_into_table:type_name -> plugin.Identifier + 9, // 15: plugin.Parameter.column:type_name -> plugin.Column + 1, // 16: plugin.GenerateRequest.settings:type_name -> plugin.Settings + 3, // 17: plugin.GenerateRequest.catalog:type_name -> plugin.Catalog + 10, // 18: plugin.GenerateRequest.queries:type_name -> plugin.Query + 0, // 19: plugin.GenerateResponse.files:type_name -> plugin.File + 12, // 20: plugin.CodegenService.Generate:input_type -> plugin.GenerateRequest + 13, // 21: plugin.CodegenService.Generate:output_type -> plugin.GenerateResponse + 21, // [21:22] is the sub-list for method output_type + 20, // [20:21] is the sub-list for method input_type + 20, // [20:20] is the sub-list for extension type_name + 20, // [20:20] is the sub-list for extension extendee + 0, // [0:20] is the sub-list for field type_name +} + +func init() { file_pkg_sqlc_plugin_codegen_proto_init() } +func file_pkg_sqlc_plugin_codegen_proto_init() { + if File_pkg_sqlc_plugin_codegen_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pkg_sqlc_plugin_codegen_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*File); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Settings); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Codegen); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Catalog); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Schema); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CompositeType); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Enum); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Table); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Identifier); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Column); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Query); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Parameter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GenerateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GenerateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Codegen_Process); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_sqlc_plugin_codegen_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Codegen_WASM); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_pkg_sqlc_plugin_codegen_proto_rawDesc, + NumEnums: 0, + NumMessages: 16, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_pkg_sqlc_plugin_codegen_proto_goTypes, + DependencyIndexes: file_pkg_sqlc_plugin_codegen_proto_depIdxs, + MessageInfos: file_pkg_sqlc_plugin_codegen_proto_msgTypes, + }.Build() + File_pkg_sqlc_plugin_codegen_proto = out.File + file_pkg_sqlc_plugin_codegen_proto_rawDesc = nil + file_pkg_sqlc_plugin_codegen_proto_goTypes = nil + file_pkg_sqlc_plugin_codegen_proto_depIdxs = nil +} diff --git a/pkg/sqlc/plugin/codegen.proto b/pkg/sqlc/plugin/codegen.proto new file mode 100644 index 0000000..fbc38e9 --- /dev/null +++ b/pkg/sqlc/plugin/codegen.proto @@ -0,0 +1,130 @@ +syntax = "proto3"; + +option go_package = "github.com/NMFR/sqlc-template/pkg/sqlc/plugin"; + +package plugin; + +service CodegenService { + rpc Generate(GenerateRequest) returns (GenerateResponse); +} + +message File { + string name = 1 [ json_name = "name" ]; + bytes contents = 2 [ json_name = "contents" ]; +} + +message Settings { + // Rename message was field 5 + // Overides message was field 6 + // PythonCode message was field 8 + // KotlinCode message was field 9 + // GoCode message was field 10; + // JSONCode message was field 11; + reserved 5, 8, 9, 10, 11; + + string version = 1 [ json_name = "version" ]; + string engine = 2 [ json_name = "engine" ]; + repeated string schema = 3 [ json_name = "schema" ]; + repeated string queries = 4 [ json_name = "queries" ]; + Codegen codegen = 12 [ json_name = "codegen" ]; +} + +message Codegen { + message Process { string cmd = 1; } + message WASM { + string url = 1; + string sha256 = 2; + } + string out = 1 [ json_name = "out" ]; + string plugin = 2 [ json_name = "plugin" ]; + bytes options = 3 [ json_name = "options" ]; + repeated string env = 4 [ json_name = "env" ]; + Process process = 5 [ json_name = "process" ]; + WASM wasm = 6 [ json_name = "wasm" ]; +} + +message Catalog { + string comment = 1; + string default_schema = 2; + string name = 3; + repeated Schema schemas = 4; +} + +message Schema { + string comment = 1; + string name = 2; + repeated Table tables = 3; + repeated Enum enums = 4; + repeated CompositeType composite_types = 5; +} + +message CompositeType { + string name = 1; + string comment = 2; +} + +message Enum { + string name = 1; + repeated string vals = 2; + string comment = 3; +} + +message Table { + Identifier rel = 1; + repeated Column columns = 2; + string comment = 3; +} + +message Identifier { + string catalog = 1; + string schema = 2; + string name = 3; +} + +message Column { + string name = 1; + bool not_null = 3; + bool is_array = 4; + string comment = 5; + int32 length = 6; + bool is_named_param = 7; + bool is_func_call = 8; + + // XXX: Figure out what PostgreSQL calls `foo.id` + string scope = 9; + Identifier table = 10; + string table_alias = 11; + Identifier type = 12; + bool is_sqlc_slice = 13; + Identifier embed_table = 14; + string original_name = 15; + bool unsigned = 16; + int32 array_dims = 17; +} + +message Query { + string text = 1 [ json_name = "text" ]; + string name = 2 [ json_name = "name" ]; + string cmd = 3 [ json_name = "cmd" ]; + repeated Column columns = 4 [ json_name = "columns" ]; + repeated Parameter params = 5 [ json_name = "parameters" ]; + repeated string comments = 6 [ json_name = "comments" ]; + string filename = 7 [ json_name = "filename" ]; + Identifier insert_into_table = 8 [ json_name = "insert_into_table" ]; +} + +message Parameter { + int32 number = 1 [ json_name = "number" ]; + Column column = 2 [ json_name = "column" ]; +} + +message GenerateRequest { + Settings settings = 1 [ json_name = "settings" ]; + Catalog catalog = 2 [ json_name = "catalog" ]; + repeated Query queries = 3 [ json_name = "queries" ]; + string sqlc_version = 4 [ json_name = "sqlc_version" ]; + bytes plugin_options = 5 [ json_name = "plugin_options" ]; + bytes global_options = 6 [ json_name = "global_options" ]; +} + +message GenerateResponse { repeated File files = 1 [ json_name = "files" ]; } From 23fb5266a8eae34ef3e3229c821b7b8549069cd4 Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Wed, 29 Jan 2025 14:46:41 +0000 Subject: [PATCH 02/10] add Makefile --- Makefile | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..261a5d5 --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +# Using make as a task runner. + +.DEFAULT_GOAL := help + +SHELL := /bin/bash +PWD := $(shell pwd) +CI_CONTAINER_IMAGE_NAME ?= nmfr/sqlc-template + +# By default -count=1 for no cache. +# -p number of paralel processes allowed +GO_TEST_FLAGS?=-count=1 -p=4 + +# make help # Display available commands. +# Only comments starting with "# make " will be printed. +.PHONY: help +help: + @egrep "^# make " [Mm]akefile | cut -c 3- + +# make tidy # Tidy the go module files. +.PHONY: tidy +tidy: + go mod tidy + +# make fmt # Format and fix (if possible) all .go files. +.PHONY: fmt +fmt: + go fmt ./... + +# make lint # Lint the code base searching for formatting or known bad patterns. +.PHONY: lint +lint: + @golangci-lint run + +# make test # Run tests. +.PHONY: test +test: + go test $(GO_TEST_FLAGS) ./... + +# Generate protobuf code for every "*.proto" file in this repository. +.PHONY: generate-protobuf +generate-protobuf: + find . -type f -name "*.proto" -exec protoc --go_out=. --go_opt=paths=source_relative "{}" \; + +# make clean # Clean up the previous build artifacts. +.PHONY: clean +clean: + rm -rf ./bin + +# make build # Build the go binary. +.PHONY: build +build: clean generate-protobuf + mkdir -p bin + GOOS=wasip1 GOARCH=wasm go build -o bin/main.wasm cmd/sqlc-template/main.go + +# make container run="" # Run a command from inside the container. Examples: `make container run="make spell-check"`. +.PHONY: container +container: +# If caching is enabled attempt to pull the container from the registry to fill the cache before the build. + [[ "$$USE_CONTAINER_CACHE" == "true" ]] && (docker pull $(CI_CONTAINER_IMAGE_NAME)) || true + docker build --target ci --tag $(CI_CONTAINER_IMAGE_NAME) --cache-from=$(CI_CONTAINER_IMAGE_NAME) --build-arg BUILDKIT_INLINE_CACHE=1 . + docker run --init -v "$(CURDIR):/opt/app" $(CI_CONTAINER_IMAGE_NAME) $(run) From 2a255bcda9826c1a6766c11c1ccbe67cd66d416e Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Wed, 29 Jan 2025 17:43:56 +0000 Subject: [PATCH 03/10] move main login out of the main package --- .gitignore | 1 + cmd/sqlc-template/main.go | 95 +--- internal/generator/generator.go | 105 ++++ .../protos}/plugin/codegen.pb.go | 502 +++++++++--------- .../protos}/plugin/codegen.proto | 5 +- 5 files changed, 366 insertions(+), 342 deletions(-) create mode 100644 internal/generator/generator.go rename {pkg/sqlc => internal/protos}/plugin/codegen.pb.go (59%) rename {pkg/sqlc => internal/protos}/plugin/codegen.proto (94%) diff --git a/.gitignore b/.gitignore index e69de29..5e56e04 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/cmd/sqlc-template/main.go b/cmd/sqlc-template/main.go index 260c000..55ab6f4 100644 --- a/cmd/sqlc-template/main.go +++ b/cmd/sqlc-template/main.go @@ -1,102 +1,13 @@ package main import ( - "bytes" - "encoding/json" - "fmt" - "io" "os" - "strings" - "text/template" - "github.com/iancoleman/strcase" - "google.golang.org/protobuf/proto" - - "github.com/NMFR/sqlc-template/pkg/sqlc/plugin" + "github.com/NMFR/sqlc-template/internal/generator" ) -type PluginOptions struct { - Filename *string `json:"filename,omitempty"` - Template *string `json:"template,omitempty"` -} - -func generate(request *plugin.GenerateRequest) (*plugin.GenerateResponse, error) { - pluginOptions := &PluginOptions{} - if err := json.Unmarshal(request.GetPluginOptions(), pluginOptions); err != nil { - return nil, fmt.Errorf("failed to parse the sqlc 'plugin options' field to JSON, %w", err) - } - - if pluginOptions.Filename == nil { - return nil, fmt.Errorf("missing the 'filename' plugin option") - } - - if pluginOptions.Template == nil { - return nil, fmt.Errorf("missing the 'template' plugin option") - } - - funcMap := template.FuncMap{ - "Replace": strings.Replace, - "ReplaceAll": strings.ReplaceAll, - "ToLower": strings.ToLower, - "ToUpper": strings.ToUpper, - "TrimSpace": strings.TrimSpace, - - "ToSnake": strcase.ToSnake, //(s) any_kind_of_string - "ToSnakeWithIgnore": strcase.ToSnakeWithIgnore, //(s, '.') any_kind.of_string - "ToScreamingSnake": strcase.ToScreamingSnake, //(s) ANY_KIND_OF_STRING - "ToKebab": strcase.ToKebab, //(s) any-kind-of-string - "ToScreamingKebab": strcase.ToScreamingKebab, //(s) ANY-KIND-OF-STRING - "ToDelimited": strcase.ToDelimited, //(s, '.') any.kind.of.string - "ToScreamingDelimited": strcase.ToScreamingDelimited, //(s, '.', ' ', true) ANY.KIND OF.STRING - "ToCamel": strcase.ToCamel, //(s) AnyKindOfString - "ToLowerCamel": strcase.ToLowerCamel, //(s) anyKindOfString - } - - tmpl, err := template.New("template").Funcs(funcMap).Parse(*pluginOptions.Template) - if err != nil { - return nil, fmt.Errorf("failed to parse the provided template, %w", err) - } - - buf := bytes.Buffer{} - if err := tmpl.Execute(&buf, request); err != nil { - return nil, fmt.Errorf("failed to execute the provided template, %w", err) - } - - json, err := json.Marshal(request) - if err != nil { - panic(fmt.Errorf("failed to convert to JSON, %w", err)) - } - - return &plugin.GenerateResponse{ - Files: []*plugin.File{ - {Name: *pluginOptions.Filename, Contents: buf.Bytes()}, - {Name: "input.json", Contents: []byte(json)}, - }, - }, nil -} - func main() { - stdin, err := io.ReadAll(os.Stdin) - if err != nil { - panic(fmt.Errorf("failed to read from stdin, %w", err)) - } - - request := &plugin.GenerateRequest{} - if err := proto.Unmarshal(stdin, request); err != nil { - panic(fmt.Errorf("failed to parse / unmarshal the sqlc request, %w", err)) - } - - response, err := generate(request) - if err != nil { - panic(fmt.Errorf("failed to generate, %w", err)) - } - - out, err := proto.Marshal(response) - if err != nil { - panic(fmt.Errorf("failed to format / marshal the sqlc response, %w", err)) - } - - if _, err = os.Stdout.Write(out); err != nil { - panic(fmt.Errorf("failed to write to stdout, %w", err)) + if err := generator.GenerateFromReader(os.Stdin, os.Stdout); err != nil { + panic(err) } } diff --git a/internal/generator/generator.go b/internal/generator/generator.go new file mode 100644 index 0000000..a3e017f --- /dev/null +++ b/internal/generator/generator.go @@ -0,0 +1,105 @@ +package generator + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "strings" + "text/template" + + "github.com/iancoleman/strcase" + "google.golang.org/protobuf/proto" + + "github.com/NMFR/sqlc-template/internal/protos/plugin" +) + +type pluginOptions struct { + Filename *string `json:"filename,omitempty"` + Template *string `json:"template,omitempty"` +} + +func Generate(request *plugin.GenerateRequest) (*plugin.GenerateResponse, error) { + pluginOptions := &pluginOptions{} + if err := json.Unmarshal(request.GetPluginOptions(), pluginOptions); err != nil { + return nil, fmt.Errorf("failed to parse the sqlc config 'sql[].codegen.options' field to JSON, %w", err) + } + + if pluginOptions.Filename == nil { + return nil, fmt.Errorf("missing the sqlc config 'sql[].codegen.options.filename' field") + } + + if pluginOptions.Template == nil { + return nil, fmt.Errorf("missing the sqlc 'sql[].codegen.options.template' field") + } + + funcMap := template.FuncMap{ + "Replace": strings.Replace, + "ReplaceAll": strings.ReplaceAll, + "ToLower": strings.ToLower, + "ToUpper": strings.ToUpper, + "TrimSpace": strings.TrimSpace, + + "ToSnake": strcase.ToSnake, // ("foo bar") => "foo_bar" + "ToScreamingSnake": strcase.ToScreamingSnake, // ("foo bar") => "FOO_BAR" + "ToKebab": strcase.ToKebab, // ("foo bar") => "foo-bar" + "ToScreamingKebab": strcase.ToScreamingKebab, // ("foo bar") => "FOO-BAR" + "ToCamel": strcase.ToCamel, // ("foo bar") => "FooBar" + "ToLowerCamel": strcase.ToLowerCamel, // ("foo bar") => "fooBar" + "ToDelimited": strcase.ToDelimited, // ("foo bar", '.') => "FOO.BAR" + } + + tmpl, err := template.New("template").Funcs(funcMap).Parse(*pluginOptions.Template) + if err != nil { + return nil, fmt.Errorf("failed to parse the template, %w", err) + } + + buf := bytes.Buffer{} + if err := tmpl.Execute(&buf, request); err != nil { + return nil, fmt.Errorf("failed to execute the template, %w", err) + } + + return &plugin.GenerateResponse{ + Files: []*plugin.File{ + {Name: *pluginOptions.Filename, Contents: buf.Bytes()}, + }, + }, + nil +} + +func GenerateFromBytes(in []byte) ([]byte, error) { + request := &plugin.GenerateRequest{} + if err := proto.Unmarshal(in, request); err != nil { + return nil, fmt.Errorf("failed to parse / unmarshal the sqlc plugin GenerateRequest, %w", err) + } + + response, err := Generate(request) + if err != nil { + return nil, fmt.Errorf("failed to generate, %w", err) + } + + out, err := proto.Marshal(response) + if err != nil { + return nil, fmt.Errorf("failed to format / marshal the sqlc plugin GenerateResponse, %w", err) + } + + return out, nil +} + +func GenerateFromReader(reader io.Reader, writer io.Writer) error { + in, err := io.ReadAll(reader) + if err != nil { + return fmt.Errorf("failed to read from stream, %w", err) + } + + out, err := GenerateFromBytes(in) + if err != nil { + return err + } + + if _, err = writer.Write(out); err != nil { + return fmt.Errorf("failed to write to the stream, %w", err) + } + + return nil +} diff --git a/pkg/sqlc/plugin/codegen.pb.go b/internal/protos/plugin/codegen.pb.go similarity index 59% rename from pkg/sqlc/plugin/codegen.pb.go rename to internal/protos/plugin/codegen.pb.go index 29f4143..3aa7b46 100644 --- a/pkg/sqlc/plugin/codegen.pb.go +++ b/internal/protos/plugin/codegen.pb.go @@ -1,8 +1,11 @@ +// Copied from: +// https://github.com/sqlc-dev/sqlc/blob/349137bd291b6da69489c22f34d0ac13bbaf3589/protos/plugin/codegen.proto + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 // protoc v4.25.1 -// source: pkg/sqlc/plugin/codegen.proto +// source: internal/protos/plugin/codegen.proto package plugin @@ -32,7 +35,7 @@ type File struct { func (x *File) Reset() { *x = File{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[0] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -45,7 +48,7 @@ func (x *File) String() string { func (*File) ProtoMessage() {} func (x *File) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[0] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -58,7 +61,7 @@ func (x *File) ProtoReflect() protoreflect.Message { // Deprecated: Use File.ProtoReflect.Descriptor instead. func (*File) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{0} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{0} } func (x *File) GetName() string { @@ -90,7 +93,7 @@ type Settings struct { func (x *Settings) Reset() { *x = Settings{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[1] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -103,7 +106,7 @@ func (x *Settings) String() string { func (*Settings) ProtoMessage() {} func (x *Settings) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[1] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -116,7 +119,7 @@ func (x *Settings) ProtoReflect() protoreflect.Message { // Deprecated: Use Settings.ProtoReflect.Descriptor instead. func (*Settings) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{1} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{1} } func (x *Settings) GetVersion() string { @@ -170,7 +173,7 @@ type Codegen struct { func (x *Codegen) Reset() { *x = Codegen{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[2] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -183,7 +186,7 @@ func (x *Codegen) String() string { func (*Codegen) ProtoMessage() {} func (x *Codegen) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[2] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -196,7 +199,7 @@ func (x *Codegen) ProtoReflect() protoreflect.Message { // Deprecated: Use Codegen.ProtoReflect.Descriptor instead. func (*Codegen) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{2} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{2} } func (x *Codegen) GetOut() string { @@ -255,7 +258,7 @@ type Catalog struct { func (x *Catalog) Reset() { *x = Catalog{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[3] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -268,7 +271,7 @@ func (x *Catalog) String() string { func (*Catalog) ProtoMessage() {} func (x *Catalog) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[3] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -281,7 +284,7 @@ func (x *Catalog) ProtoReflect() protoreflect.Message { // Deprecated: Use Catalog.ProtoReflect.Descriptor instead. func (*Catalog) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{3} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{3} } func (x *Catalog) GetComment() string { @@ -327,7 +330,7 @@ type Schema struct { func (x *Schema) Reset() { *x = Schema{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[4] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -340,7 +343,7 @@ func (x *Schema) String() string { func (*Schema) ProtoMessage() {} func (x *Schema) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[4] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -353,7 +356,7 @@ func (x *Schema) ProtoReflect() protoreflect.Message { // Deprecated: Use Schema.ProtoReflect.Descriptor instead. func (*Schema) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{4} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{4} } func (x *Schema) GetComment() string { @@ -403,7 +406,7 @@ type CompositeType struct { func (x *CompositeType) Reset() { *x = CompositeType{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[5] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -416,7 +419,7 @@ func (x *CompositeType) String() string { func (*CompositeType) ProtoMessage() {} func (x *CompositeType) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[5] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -429,7 +432,7 @@ func (x *CompositeType) ProtoReflect() protoreflect.Message { // Deprecated: Use CompositeType.ProtoReflect.Descriptor instead. func (*CompositeType) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{5} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{5} } func (x *CompositeType) GetName() string { @@ -459,7 +462,7 @@ type Enum struct { func (x *Enum) Reset() { *x = Enum{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[6] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -472,7 +475,7 @@ func (x *Enum) String() string { func (*Enum) ProtoMessage() {} func (x *Enum) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[6] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -485,7 +488,7 @@ func (x *Enum) ProtoReflect() protoreflect.Message { // Deprecated: Use Enum.ProtoReflect.Descriptor instead. func (*Enum) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{6} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{6} } func (x *Enum) GetName() string { @@ -522,7 +525,7 @@ type Table struct { func (x *Table) Reset() { *x = Table{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[7] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -535,7 +538,7 @@ func (x *Table) String() string { func (*Table) ProtoMessage() {} func (x *Table) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[7] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -548,7 +551,7 @@ func (x *Table) ProtoReflect() protoreflect.Message { // Deprecated: Use Table.ProtoReflect.Descriptor instead. func (*Table) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{7} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{7} } func (x *Table) GetRel() *Identifier { @@ -585,7 +588,7 @@ type Identifier struct { func (x *Identifier) Reset() { *x = Identifier{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[8] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -598,7 +601,7 @@ func (x *Identifier) String() string { func (*Identifier) ProtoMessage() {} func (x *Identifier) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[8] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -611,7 +614,7 @@ func (x *Identifier) ProtoReflect() protoreflect.Message { // Deprecated: Use Identifier.ProtoReflect.Descriptor instead. func (*Identifier) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{8} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{8} } func (x *Identifier) GetCatalog() string { @@ -662,7 +665,7 @@ type Column struct { func (x *Column) Reset() { *x = Column{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[9] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -675,7 +678,7 @@ func (x *Column) String() string { func (*Column) ProtoMessage() {} func (x *Column) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[9] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -688,7 +691,7 @@ func (x *Column) ProtoReflect() protoreflect.Message { // Deprecated: Use Column.ProtoReflect.Descriptor instead. func (*Column) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{9} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{9} } func (x *Column) GetName() string { @@ -821,7 +824,7 @@ type Query struct { func (x *Query) Reset() { *x = Query{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[10] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -834,7 +837,7 @@ func (x *Query) String() string { func (*Query) ProtoMessage() {} func (x *Query) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[10] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -847,7 +850,7 @@ func (x *Query) ProtoReflect() protoreflect.Message { // Deprecated: Use Query.ProtoReflect.Descriptor instead. func (*Query) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{10} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{10} } func (x *Query) GetText() string { @@ -918,7 +921,7 @@ type Parameter struct { func (x *Parameter) Reset() { *x = Parameter{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[11] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -931,7 +934,7 @@ func (x *Parameter) String() string { func (*Parameter) ProtoMessage() {} func (x *Parameter) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[11] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -944,7 +947,7 @@ func (x *Parameter) ProtoReflect() protoreflect.Message { // Deprecated: Use Parameter.ProtoReflect.Descriptor instead. func (*Parameter) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{11} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{11} } func (x *Parameter) GetNumber() int32 { @@ -977,7 +980,7 @@ type GenerateRequest struct { func (x *GenerateRequest) Reset() { *x = GenerateRequest{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[12] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -990,7 +993,7 @@ func (x *GenerateRequest) String() string { func (*GenerateRequest) ProtoMessage() {} func (x *GenerateRequest) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[12] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1003,7 +1006,7 @@ func (x *GenerateRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GenerateRequest.ProtoReflect.Descriptor instead. func (*GenerateRequest) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{12} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{12} } func (x *GenerateRequest) GetSettings() *Settings { @@ -1059,7 +1062,7 @@ type GenerateResponse struct { func (x *GenerateResponse) Reset() { *x = GenerateResponse{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[13] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1072,7 +1075,7 @@ func (x *GenerateResponse) String() string { func (*GenerateResponse) ProtoMessage() {} func (x *GenerateResponse) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[13] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1085,7 +1088,7 @@ func (x *GenerateResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GenerateResponse.ProtoReflect.Descriptor instead. func (*GenerateResponse) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{13} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{13} } func (x *GenerateResponse) GetFiles() []*File { @@ -1106,7 +1109,7 @@ type Codegen_Process struct { func (x *Codegen_Process) Reset() { *x = Codegen_Process{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[14] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1119,7 +1122,7 @@ func (x *Codegen_Process) String() string { func (*Codegen_Process) ProtoMessage() {} func (x *Codegen_Process) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[14] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1132,7 +1135,7 @@ func (x *Codegen_Process) ProtoReflect() protoreflect.Message { // Deprecated: Use Codegen_Process.ProtoReflect.Descriptor instead. func (*Codegen_Process) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{2, 0} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{2, 0} } func (x *Codegen_Process) GetCmd() string { @@ -1154,7 +1157,7 @@ type Codegen_WASM struct { func (x *Codegen_WASM) Reset() { *x = Codegen_WASM{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[15] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1167,7 +1170,7 @@ func (x *Codegen_WASM) String() string { func (*Codegen_WASM) ProtoMessage() {} func (x *Codegen_WASM) ProtoReflect() protoreflect.Message { - mi := &file_pkg_sqlc_plugin_codegen_proto_msgTypes[15] + mi := &file_internal_protos_plugin_codegen_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1180,7 +1183,7 @@ func (x *Codegen_WASM) ProtoReflect() protoreflect.Message { // Deprecated: Use Codegen_WASM.ProtoReflect.Descriptor instead. func (*Codegen_WASM) Descriptor() ([]byte, []int) { - return file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP(), []int{2, 1} + return file_internal_protos_plugin_codegen_proto_rawDescGZIP(), []int{2, 1} } func (x *Codegen_WASM) GetUrl() string { @@ -1197,186 +1200,187 @@ func (x *Codegen_WASM) GetSha256() string { return "" } -var File_pkg_sqlc_plugin_codegen_proto protoreflect.FileDescriptor - -var file_pkg_sqlc_plugin_codegen_proto_rawDesc = []byte{ - 0x0a, 0x1d, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, 0x36, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, - 0xb7, 0x01, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x12, 0x16, - 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, - 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, - 0x12, 0x29, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x67, - 0x65, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x4a, 0x04, 0x08, 0x05, 0x10, - 0x06, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, - 0x0a, 0x10, 0x0b, 0x4a, 0x04, 0x08, 0x0b, 0x10, 0x0c, 0x22, 0x8b, 0x02, 0x0a, 0x07, 0x43, 0x6f, - 0x64, 0x65, 0x67, 0x65, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, - 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x76, - 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x12, 0x31, 0x0a, 0x07, 0x70, - 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x2e, 0x50, 0x72, - 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x28, - 0x0a, 0x04, 0x77, 0x61, 0x73, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x2e, 0x57, 0x41, - 0x53, 0x4d, 0x52, 0x04, 0x77, 0x61, 0x73, 0x6d, 0x1a, 0x1b, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x63, - 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x63, 0x6d, 0x64, 0x1a, 0x30, 0x0a, 0x04, 0x57, 0x41, 0x53, 0x4d, 0x12, 0x10, 0x0a, - 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, - 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x22, 0x88, 0x01, 0x0a, 0x07, 0x43, 0x61, 0x74, 0x61, - 0x6c, 0x6f, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, - 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x06, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, - 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x06, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x73, 0x12, 0x22, 0x0a, 0x05, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52, - 0x05, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x12, 0x3e, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x15, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x22, 0x3d, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x48, 0x0a, 0x04, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x04, 0x76, 0x61, 0x6c, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, - 0x71, 0x0a, 0x05, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x24, 0x0a, 0x03, 0x72, 0x65, 0x6c, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, - 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x03, 0x72, 0x65, 0x6c, 0x12, 0x28, - 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, - 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, - 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, - 0x6e, 0x74, 0x22, 0x52, 0x0a, 0x0a, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, - 0x12, 0x18, 0x0a, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x8e, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6c, 0x75, 0x6d, - 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x74, 0x5f, 0x6e, 0x75, 0x6c, - 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6e, 0x6f, 0x74, 0x4e, 0x75, 0x6c, 0x6c, - 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x63, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x24, 0x0a, - 0x0e, 0x69, 0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x12, 0x20, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x63, - 0x61, 0x6c, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x46, 0x75, 0x6e, - 0x63, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x05, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x05, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, - 0x6c, 0x69, 0x61, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x26, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0c, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x22, - 0x0a, 0x0d, 0x69, 0x73, 0x5f, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x18, - 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x53, 0x71, 0x6c, 0x63, 0x53, 0x6c, 0x69, - 0x63, 0x65, 0x12, 0x33, 0x0a, 0x0b, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x5f, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x0a, 0x65, 0x6d, 0x62, - 0x65, 0x64, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, - 0x6e, 0x61, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, - 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, - 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x72, 0x72, 0x61, - 0x79, 0x5f, 0x64, 0x69, 0x6d, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x61, 0x72, - 0x72, 0x61, 0x79, 0x44, 0x69, 0x6d, 0x73, 0x22, 0x94, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x6d, 0x64, 0x12, 0x28, 0x0a, 0x07, 0x63, - 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x07, 0x63, 0x6f, - 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, - 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, - 0x74, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, - 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, - 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x11, - 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x69, 0x6e, 0x73, - 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x4b, - 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6e, - 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, - 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, - 0x75, 0x6d, 0x6e, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x22, 0x87, 0x02, 0x0a, 0x0f, - 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x2c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x73, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x29, 0x0a, - 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, - 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, - 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x27, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, - 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, - 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, - 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x70, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, - 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x36, 0x0a, 0x10, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, 0x6c, - 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x32, 0x4f, 0x0a, - 0x0e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x3d, 0x0a, 0x08, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x65, - 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2f, - 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4e, 0x4d, 0x46, - 0x52, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2d, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2f, - 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var File_internal_protos_plugin_codegen_proto protoreflect.FileDescriptor + +var file_internal_protos_plugin_codegen_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, 0x36, + 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xb7, 0x01, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, + 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, + 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, + 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, + 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x67, + 0x65, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x67, + 0x65, 0x6e, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, + 0x08, 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0a, 0x10, 0x0b, 0x4a, 0x04, 0x08, 0x0b, 0x10, 0x0c, + 0x22, 0x8b, 0x02, 0x0a, 0x07, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x12, 0x10, 0x0a, 0x03, + 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x75, 0x74, 0x12, 0x16, + 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x76, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x65, + 0x6e, 0x76, 0x12, 0x31, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, + 0x65, 0x67, 0x65, 0x6e, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x07, 0x70, 0x72, + 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x28, 0x0a, 0x04, 0x77, 0x61, 0x73, 0x6d, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, + 0x65, 0x67, 0x65, 0x6e, 0x2e, 0x57, 0x41, 0x53, 0x4d, 0x52, 0x04, 0x77, 0x61, 0x73, 0x6d, 0x1a, + 0x1b, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x6d, 0x64, 0x1a, 0x30, 0x0a, 0x04, + 0x57, 0x41, 0x53, 0x4d, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x22, 0x88, + 0x01, 0x0a, 0x07, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, + 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, + 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x28, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x06, 0x53, 0x63, + 0x68, 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x54, 0x61, 0x62, 0x6c, + 0x65, 0x52, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x05, 0x65, 0x6e, 0x75, + 0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x05, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x12, 0x3e, 0x0a, + 0x0f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, + 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0e, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x22, 0x3d, 0x0a, + 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x48, 0x0a, 0x04, + 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x76, 0x61, 0x6c, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x12, 0x18, 0x0a, 0x07, + 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x71, 0x0a, 0x05, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, + 0x24, 0x0a, 0x03, 0x72, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, + 0x52, 0x03, 0x72, 0x65, 0x6c, 0x12, 0x28, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, + 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, + 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x52, 0x0a, 0x0a, 0x49, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, + 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, + 0x67, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x8e, 0x04, + 0x0a, 0x06, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, + 0x6e, 0x6f, 0x74, 0x5f, 0x6e, 0x75, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x6e, 0x6f, 0x74, 0x4e, 0x75, 0x6c, 0x6c, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x41, 0x72, 0x72, + 0x61, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6c, 0x65, + 0x6e, 0x67, 0x74, 0x68, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x64, + 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, + 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x20, 0x0a, 0x0c, 0x69, 0x73, + 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0a, 0x69, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x14, 0x0a, 0x05, + 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x63, 0x6f, + 0x70, 0x65, 0x12, 0x28, 0x0a, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x0b, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x26, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x73, 0x5f, 0x73, 0x71, 0x6c, 0x63, + 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, + 0x53, 0x71, 0x6c, 0x63, 0x53, 0x6c, 0x69, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x0b, 0x65, 0x6d, 0x62, + 0x65, 0x64, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, + 0x65, 0x72, 0x52, 0x0a, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x23, + 0x0a, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x18, + 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x12, + 0x1d, 0x0a, 0x0a, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5f, 0x64, 0x69, 0x6d, 0x73, 0x18, 0x11, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x09, 0x61, 0x72, 0x72, 0x61, 0x79, 0x44, 0x69, 0x6d, 0x73, 0x22, 0x94, + 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, + 0x6d, 0x64, 0x12, 0x28, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, + 0x75, 0x6d, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x2d, 0x0a, 0x06, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, + 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x11, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, + 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, + 0x65, 0x72, 0x52, 0x11, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x6f, 0x5f, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x4b, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, + 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x06, 0x63, 0x6f, + 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, + 0x6d, 0x6e, 0x22, 0x87, 0x02, 0x0a, 0x0f, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, + 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, + 0x27, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, + 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, + 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x0e, + 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, + 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x36, 0x0a, 0x10, + 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, + 0x69, 0x6c, 0x65, 0x73, 0x32, 0x4f, 0x0a, 0x0e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x08, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, + 0x74, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x65, 0x6e, 0x65, + 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x4e, 0x4d, 0x46, 0x52, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2d, 0x74, 0x65, + 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_pkg_sqlc_plugin_codegen_proto_rawDescOnce sync.Once - file_pkg_sqlc_plugin_codegen_proto_rawDescData = file_pkg_sqlc_plugin_codegen_proto_rawDesc + file_internal_protos_plugin_codegen_proto_rawDescOnce sync.Once + file_internal_protos_plugin_codegen_proto_rawDescData = file_internal_protos_plugin_codegen_proto_rawDesc ) -func file_pkg_sqlc_plugin_codegen_proto_rawDescGZIP() []byte { - file_pkg_sqlc_plugin_codegen_proto_rawDescOnce.Do(func() { - file_pkg_sqlc_plugin_codegen_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_sqlc_plugin_codegen_proto_rawDescData) +func file_internal_protos_plugin_codegen_proto_rawDescGZIP() []byte { + file_internal_protos_plugin_codegen_proto_rawDescOnce.Do(func() { + file_internal_protos_plugin_codegen_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_protos_plugin_codegen_proto_rawDescData) }) - return file_pkg_sqlc_plugin_codegen_proto_rawDescData + return file_internal_protos_plugin_codegen_proto_rawDescData } -var file_pkg_sqlc_plugin_codegen_proto_msgTypes = make([]protoimpl.MessageInfo, 16) -var file_pkg_sqlc_plugin_codegen_proto_goTypes = []interface{}{ +var file_internal_protos_plugin_codegen_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_internal_protos_plugin_codegen_proto_goTypes = []interface{}{ (*File)(nil), // 0: plugin.File (*Settings)(nil), // 1: plugin.Settings (*Codegen)(nil), // 2: plugin.Codegen @@ -1394,7 +1398,7 @@ var file_pkg_sqlc_plugin_codegen_proto_goTypes = []interface{}{ (*Codegen_Process)(nil), // 14: plugin.Codegen.Process (*Codegen_WASM)(nil), // 15: plugin.Codegen.WASM } -var file_pkg_sqlc_plugin_codegen_proto_depIdxs = []int32{ +var file_internal_protos_plugin_codegen_proto_depIdxs = []int32{ 2, // 0: plugin.Settings.codegen:type_name -> plugin.Codegen 14, // 1: plugin.Codegen.process:type_name -> plugin.Codegen.Process 15, // 2: plugin.Codegen.wasm:type_name -> plugin.Codegen.WASM @@ -1424,13 +1428,13 @@ var file_pkg_sqlc_plugin_codegen_proto_depIdxs = []int32{ 0, // [0:20] is the sub-list for field type_name } -func init() { file_pkg_sqlc_plugin_codegen_proto_init() } -func file_pkg_sqlc_plugin_codegen_proto_init() { - if File_pkg_sqlc_plugin_codegen_proto != nil { +func init() { file_internal_protos_plugin_codegen_proto_init() } +func file_internal_protos_plugin_codegen_proto_init() { + if File_internal_protos_plugin_codegen_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_pkg_sqlc_plugin_codegen_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*File); i { case 0: return &v.state @@ -1442,7 +1446,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Settings); i { case 0: return &v.state @@ -1454,7 +1458,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Codegen); i { case 0: return &v.state @@ -1466,7 +1470,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Catalog); i { case 0: return &v.state @@ -1478,7 +1482,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Schema); i { case 0: return &v.state @@ -1490,7 +1494,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CompositeType); i { case 0: return &v.state @@ -1502,7 +1506,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Enum); i { case 0: return &v.state @@ -1514,7 +1518,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Table); i { case 0: return &v.state @@ -1526,7 +1530,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Identifier); i { case 0: return &v.state @@ -1538,7 +1542,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Column); i { case 0: return &v.state @@ -1550,7 +1554,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Query); i { case 0: return &v.state @@ -1562,7 +1566,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Parameter); i { case 0: return &v.state @@ -1574,7 +1578,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GenerateRequest); i { case 0: return &v.state @@ -1586,7 +1590,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GenerateResponse); i { case 0: return &v.state @@ -1598,7 +1602,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Codegen_Process); i { case 0: return &v.state @@ -1610,7 +1614,7 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { return nil } } - file_pkg_sqlc_plugin_codegen_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_internal_protos_plugin_codegen_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Codegen_WASM); i { case 0: return &v.state @@ -1627,18 +1631,18 @@ func file_pkg_sqlc_plugin_codegen_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_pkg_sqlc_plugin_codegen_proto_rawDesc, + RawDescriptor: file_internal_protos_plugin_codegen_proto_rawDesc, NumEnums: 0, NumMessages: 16, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_pkg_sqlc_plugin_codegen_proto_goTypes, - DependencyIndexes: file_pkg_sqlc_plugin_codegen_proto_depIdxs, - MessageInfos: file_pkg_sqlc_plugin_codegen_proto_msgTypes, + GoTypes: file_internal_protos_plugin_codegen_proto_goTypes, + DependencyIndexes: file_internal_protos_plugin_codegen_proto_depIdxs, + MessageInfos: file_internal_protos_plugin_codegen_proto_msgTypes, }.Build() - File_pkg_sqlc_plugin_codegen_proto = out.File - file_pkg_sqlc_plugin_codegen_proto_rawDesc = nil - file_pkg_sqlc_plugin_codegen_proto_goTypes = nil - file_pkg_sqlc_plugin_codegen_proto_depIdxs = nil + File_internal_protos_plugin_codegen_proto = out.File + file_internal_protos_plugin_codegen_proto_rawDesc = nil + file_internal_protos_plugin_codegen_proto_goTypes = nil + file_internal_protos_plugin_codegen_proto_depIdxs = nil } diff --git a/pkg/sqlc/plugin/codegen.proto b/internal/protos/plugin/codegen.proto similarity index 94% rename from pkg/sqlc/plugin/codegen.proto rename to internal/protos/plugin/codegen.proto index fbc38e9..14a2ea4 100644 --- a/pkg/sqlc/plugin/codegen.proto +++ b/internal/protos/plugin/codegen.proto @@ -1,6 +1,9 @@ +// Copied from: +// https://github.com/sqlc-dev/sqlc/blob/349137bd291b6da69489c22f34d0ac13bbaf3589/protos/plugin/codegen.proto + syntax = "proto3"; -option go_package = "github.com/NMFR/sqlc-template/pkg/sqlc/plugin"; +option go_package = "github.com/NMFR/sqlc-template/internal/protos/plugin"; package plugin; From ae2543d5362212c50b9af659f9e14b2b8e52fa77 Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Wed, 29 Jan 2025 21:43:10 +0000 Subject: [PATCH 04/10] add tests remove some useless template functions --- Makefile | 3 +- go.mod | 7 + go.sum | 10 + internal/generator/generator.go | 3 - internal/generator/generator_test.go | 273 +++++++++++++++++++++++++++ 5 files changed, 292 insertions(+), 4 deletions(-) create mode 100644 internal/generator/generator_test.go diff --git a/Makefile b/Makefile index 261a5d5..530265e 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,8 @@ CI_CONTAINER_IMAGE_NAME ?= nmfr/sqlc-template # By default -count=1 for no cache. # -p number of paralel processes allowed -GO_TEST_FLAGS?=-count=1 -p=4 +# -cover to include coverage % +GO_TEST_FLAGS?=-count=1 -p=4 -cover # make help # Display available commands. # Only comments starting with "# make " will be printed. diff --git a/go.mod b/go.mod index 47ab726..c0ecd4f 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,12 @@ go 1.21.4 require ( github.com/iancoleman/strcase v0.3.0 + github.com/stretchr/testify v1.10.0 google.golang.org/protobuf v1.36.4 ) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum index 0f681c8..a8fde69 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,18 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/generator/generator.go b/internal/generator/generator.go index a3e017f..b53fb5f 100644 --- a/internal/generator/generator.go +++ b/internal/generator/generator.go @@ -34,11 +34,9 @@ func Generate(request *plugin.GenerateRequest) (*plugin.GenerateResponse, error) } funcMap := template.FuncMap{ - "Replace": strings.Replace, "ReplaceAll": strings.ReplaceAll, "ToLower": strings.ToLower, "ToUpper": strings.ToUpper, - "TrimSpace": strings.TrimSpace, "ToSnake": strcase.ToSnake, // ("foo bar") => "foo_bar" "ToScreamingSnake": strcase.ToScreamingSnake, // ("foo bar") => "FOO_BAR" @@ -46,7 +44,6 @@ func Generate(request *plugin.GenerateRequest) (*plugin.GenerateResponse, error) "ToScreamingKebab": strcase.ToScreamingKebab, // ("foo bar") => "FOO-BAR" "ToCamel": strcase.ToCamel, // ("foo bar") => "FooBar" "ToLowerCamel": strcase.ToLowerCamel, // ("foo bar") => "fooBar" - "ToDelimited": strcase.ToDelimited, // ("foo bar", '.') => "FOO.BAR" } tmpl, err := template.New("template").Funcs(funcMap).Parse(*pluginOptions.Template) diff --git a/internal/generator/generator_test.go b/internal/generator/generator_test.go new file mode 100644 index 0000000..aedeb47 --- /dev/null +++ b/internal/generator/generator_test.go @@ -0,0 +1,273 @@ +package generator_test + +import ( + "bytes" + "io" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "google.golang.org/protobuf/proto" + + "github.com/NMFR/sqlc-template/internal/generator" + "github.com/NMFR/sqlc-template/internal/protos/plugin" +) + +// jsonString escapes a string for a valid string property in a json document. +func jsonString(str string) string { + for old, new := range map[string]string{ + "\n": "\\n", + "\t": "\\t", + "\"": "\\\"", + } { + str = strings.ReplaceAll(str, old, new) + } + + return str +} + +// runGenerateFromReader run the `generator.GenerateFromReader` by marshaling the `plugin.GenerateRequest` input to bytes and unmarshaling the result back to a `plugin.GenerateResponse`. +func runGenerateFromReader(request *plugin.GenerateRequest) (*plugin.GenerateResponse, error) { + requestBytes, err := proto.Marshal(request) + if err != nil { + return nil, err + } + + requestReader := bytes.NewBuffer(requestBytes) + responseWriter := bytes.Buffer{} + + err = generator.GenerateFromReader(requestReader, &responseWriter) + if err != nil { + return nil, err + } + + responseBytes, err := io.ReadAll(&responseWriter) + if err != nil { + return nil, err + } + + response := &plugin.GenerateResponse{} + err = proto.Unmarshal(responseBytes, response) + if err != nil { + return nil, err + } + + return response, nil +} + +func TestGeneratorSuccess(t *testing.T) { + testCases := map[string]struct { + request plugin.GenerateRequest + expected plugin.GenerateResponse + }{ + "empty": { + request: plugin.GenerateRequest{ + PluginOptions: []byte(`{ + "filename": "test.file", + "template": "" + }`), + }, + expected: plugin.GenerateResponse{ + Files: []*plugin.File{ + { + Name: "test.file", + Contents: nil, + }, + }, + }, + }, + "test-buildin-funcs": { + request: plugin.GenerateRequest{ + PluginOptions: []byte(`{ + "filename": "test.file", + "template": "` + jsonString(` + {{ ReplaceAll "foo bar foo bar" "bar" "foo" }} + {{ "FoO bAr" | ToLower }} + {{ "FoO bAr" | ToUpper }} + {{ "foo bar" | ToSnake }} + {{ "foo bar" | ToScreamingSnake }} + {{ "foo bar" | ToKebab }} + {{ "foo bar" | ToScreamingKebab }} + {{ "foo bar" | ToCamel }} + {{ "foo bar" | ToLowerCamel }} +`) + `" + }`), + }, + expected: plugin.GenerateResponse{ + Files: []*plugin.File{ + { + Name: "test.file", + Contents: []byte(` + foo foo foo foo + foo bar + FOO BAR + foo_bar + FOO_BAR + foo-bar + FOO-BAR + FooBar + fooBar +`), + }, + }, + }, + }, + "simple-template": { + request: plugin.GenerateRequest{ + Queries: []*plugin.Query{ + { + Name: "mock query", + Cmd: ":one", + Params: []*plugin.Parameter{ + { + Column: &plugin.Column{ + Name: "mock param", + Type: &plugin.Identifier{Name: "text"}, + }, + }, + { + Column: &plugin.Column{ + Name: "another mock param", + Type: &plugin.Identifier{Name: "int"}, + }, + }, + }, + Columns: []*plugin.Column{ + { + Name: "mock column", + Type: &plugin.Identifier{Name: "int"}, + }, + { + Name: "another mock column", + Type: &plugin.Identifier{Name: "bool"}, + }, + }, + }, + }, + PluginOptions: []byte(`{ + "filename": "some.file", + "template": "` + jsonString(` + queries: + {{- range .Queries }} + - name: {{ .Name | ToLowerCamel }} + cmd: {{ .Cmd }} + params: + {{- range .Params }} + - name: {{ .Column.Name | ToLowerCamel }} + type: {{ .Column.Type.Name -}} + {{ end }} + columns: + {{- range .Columns }} + - name: {{ .Name | ToLowerCamel }} + type: {{ .Type.Name -}} + {{ end -}} + {{ end }} +`) + `" + }`), + }, + expected: plugin.GenerateResponse{ + Files: []*plugin.File{ + { + Name: "some.file", + Contents: []byte(` + queries: + - name: mockQuery + cmd: :one + params: + - name: mockParam + type: text + - name: anotherMockParam + type: int + columns: + - name: mockColumn + type: int + - name: anotherMockColumn + type: bool +`), + }, + }, + }, + }, + } + + for testName, testCase := range testCases { + testCase := testCase + + t.Run(testName, func(t *testing.T) { + response, err := runGenerateFromReader(&testCase.request) + + assert.NoError(t, err) + assert.EqualExportedValues(t, &testCase.expected, response) + }) + } +} + +func TestGeneratorFailure(t *testing.T) { + testCases := map[string]struct { + request plugin.GenerateRequest + expectedErrMsg string + }{ + "empty options": { + request: plugin.GenerateRequest{}, + expectedErrMsg: "failed to parse the sqlc config 'sql[].codegen.options' field to JSON", + }, + "invalid options JSON": { + request: plugin.GenerateRequest{ + PluginOptions: []byte("not a JSON at all"), + }, + expectedErrMsg: "failed to parse the sqlc config 'sql[].codegen.options' field to JSON", + }, + "empty options JSON": { + request: plugin.GenerateRequest{ + PluginOptions: []byte("{}"), + }, + expectedErrMsg: "missing the sqlc config 'sql[].codegen.options.filename' field", + }, + "missing template option": { + request: plugin.GenerateRequest{ + PluginOptions: []byte(`{ + "filename": "test.file" + }`), + }, + expectedErrMsg: "missing the sqlc 'sql[].codegen.options.template' field", + }, + "missing filename option": { + request: plugin.GenerateRequest{ + PluginOptions: []byte(`{ + "template": "nothing" + }`), + }, + expectedErrMsg: "missing the sqlc config 'sql[].codegen.options.filename' field", + }, + "invalid template option": { + request: plugin.GenerateRequest{ + PluginOptions: []byte(`{ + "filename": "test.file", + "template": "{{ invalid" + }`), + }, + expectedErrMsg: "failed to parse the template", + }, + "template option using non existant data": { + request: plugin.GenerateRequest{ + PluginOptions: []byte(`{ + "filename": "test.file", + "template": "{{ .invalid }}" + }`), + }, + expectedErrMsg: "failed to execute the template", + }, + } + + for testName, testCase := range testCases { + testCase := testCase + + t.Run(testName, func(t *testing.T) { + response, err := runGenerateFromReader(&testCase.request) + + assert.Error(t, err) + assert.Nil(t, response) + assert.ErrorContains(t, err, testCase.expectedErrMsg) + }) + } +} From d97153ff906ebd6793ccdde36098c1a1fcb37552 Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Wed, 29 Jan 2025 21:47:00 +0000 Subject: [PATCH 05/10] fix proto copy lock warning --- internal/generator/generator_test.go | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/generator/generator_test.go b/internal/generator/generator_test.go index aedeb47..22b5525 100644 --- a/internal/generator/generator_test.go +++ b/internal/generator/generator_test.go @@ -57,17 +57,17 @@ func runGenerateFromReader(request *plugin.GenerateRequest) (*plugin.GenerateRes func TestGeneratorSuccess(t *testing.T) { testCases := map[string]struct { - request plugin.GenerateRequest - expected plugin.GenerateResponse + request *plugin.GenerateRequest + expected *plugin.GenerateResponse }{ "empty": { - request: plugin.GenerateRequest{ + request: &plugin.GenerateRequest{ PluginOptions: []byte(`{ "filename": "test.file", "template": "" }`), }, - expected: plugin.GenerateResponse{ + expected: &plugin.GenerateResponse{ Files: []*plugin.File{ { Name: "test.file", @@ -77,7 +77,7 @@ func TestGeneratorSuccess(t *testing.T) { }, }, "test-buildin-funcs": { - request: plugin.GenerateRequest{ + request: &plugin.GenerateRequest{ PluginOptions: []byte(`{ "filename": "test.file", "template": "` + jsonString(` @@ -93,7 +93,7 @@ func TestGeneratorSuccess(t *testing.T) { `) + `" }`), }, - expected: plugin.GenerateResponse{ + expected: &plugin.GenerateResponse{ Files: []*plugin.File{ { Name: "test.file", @@ -113,7 +113,7 @@ func TestGeneratorSuccess(t *testing.T) { }, }, "simple-template": { - request: plugin.GenerateRequest{ + request: &plugin.GenerateRequest{ Queries: []*plugin.Query{ { Name: "mock query", @@ -165,7 +165,7 @@ func TestGeneratorSuccess(t *testing.T) { `) + `" }`), }, - expected: plugin.GenerateResponse{ + expected: &plugin.GenerateResponse{ Files: []*plugin.File{ { Name: "some.file", @@ -194,37 +194,37 @@ func TestGeneratorSuccess(t *testing.T) { testCase := testCase t.Run(testName, func(t *testing.T) { - response, err := runGenerateFromReader(&testCase.request) + response, err := runGenerateFromReader(testCase.request) assert.NoError(t, err) - assert.EqualExportedValues(t, &testCase.expected, response) + assert.EqualExportedValues(t, testCase.expected, response) }) } } func TestGeneratorFailure(t *testing.T) { testCases := map[string]struct { - request plugin.GenerateRequest + request *plugin.GenerateRequest expectedErrMsg string }{ "empty options": { - request: plugin.GenerateRequest{}, + request: &plugin.GenerateRequest{}, expectedErrMsg: "failed to parse the sqlc config 'sql[].codegen.options' field to JSON", }, "invalid options JSON": { - request: plugin.GenerateRequest{ + request: &plugin.GenerateRequest{ PluginOptions: []byte("not a JSON at all"), }, expectedErrMsg: "failed to parse the sqlc config 'sql[].codegen.options' field to JSON", }, "empty options JSON": { - request: plugin.GenerateRequest{ + request: &plugin.GenerateRequest{ PluginOptions: []byte("{}"), }, expectedErrMsg: "missing the sqlc config 'sql[].codegen.options.filename' field", }, "missing template option": { - request: plugin.GenerateRequest{ + request: &plugin.GenerateRequest{ PluginOptions: []byte(`{ "filename": "test.file" }`), @@ -232,7 +232,7 @@ func TestGeneratorFailure(t *testing.T) { expectedErrMsg: "missing the sqlc 'sql[].codegen.options.template' field", }, "missing filename option": { - request: plugin.GenerateRequest{ + request: &plugin.GenerateRequest{ PluginOptions: []byte(`{ "template": "nothing" }`), @@ -240,7 +240,7 @@ func TestGeneratorFailure(t *testing.T) { expectedErrMsg: "missing the sqlc config 'sql[].codegen.options.filename' field", }, "invalid template option": { - request: plugin.GenerateRequest{ + request: &plugin.GenerateRequest{ PluginOptions: []byte(`{ "filename": "test.file", "template": "{{ invalid" @@ -249,7 +249,7 @@ func TestGeneratorFailure(t *testing.T) { expectedErrMsg: "failed to parse the template", }, "template option using non existant data": { - request: plugin.GenerateRequest{ + request: &plugin.GenerateRequest{ PluginOptions: []byte(`{ "filename": "test.file", "template": "{{ .invalid }}" @@ -263,7 +263,7 @@ func TestGeneratorFailure(t *testing.T) { testCase := testCase t.Run(testName, func(t *testing.T) { - response, err := runGenerateFromReader(&testCase.request) + response, err := runGenerateFromReader(testCase.request) assert.Error(t, err) assert.Nil(t, response) From 8c5d251aca545f5497cebe444a85db709419355f Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Thu, 30 Jan 2025 11:25:06 +0000 Subject: [PATCH 06/10] add stream tests --- internal/generator/generator_test.go | 92 ++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 24 deletions(-) diff --git a/internal/generator/generator_test.go b/internal/generator/generator_test.go index 22b5525..3a94928 100644 --- a/internal/generator/generator_test.go +++ b/internal/generator/generator_test.go @@ -2,6 +2,7 @@ package generator_test import ( "bytes" + "fmt" "io" "strings" "testing" @@ -26,22 +27,26 @@ func jsonString(str string) string { return str } -// runGenerateFromReader run the `generator.GenerateFromReader` by marshaling the `plugin.GenerateRequest` input to bytes and unmarshaling the result back to a `plugin.GenerateResponse`. -func runGenerateFromReader(request *plugin.GenerateRequest) (*plugin.GenerateResponse, error) { +func requestToReader(request *plugin.GenerateRequest) (io.Reader, error) { requestBytes, err := proto.Marshal(request) if err != nil { return nil, err } - requestReader := bytes.NewBuffer(requestBytes) - responseWriter := bytes.Buffer{} + return bytes.NewBuffer(requestBytes), nil +} - err = generator.GenerateFromReader(requestReader, &responseWriter) +func requestToReaderNoErr(request *plugin.GenerateRequest) io.Reader { + response, err := requestToReader(request) if err != nil { - return nil, err + panic(err) } - responseBytes, err := io.ReadAll(&responseWriter) + return response +} + +func responseFromReader(reader io.Reader) (*plugin.GenerateResponse, error) { + responseBytes, err := io.ReadAll(reader) if err != nil { return nil, err } @@ -55,6 +60,16 @@ func runGenerateFromReader(request *plugin.GenerateRequest) (*plugin.GenerateRes return response, nil } +type errorReaderWriter struct{} + +func (rw *errorReaderWriter) Read(p []byte) (n int, err error) { + return 0, fmt.Errorf("read error") +} + +func (rw *errorReaderWriter) Write(p []byte) (n int, err error) { + return 0, fmt.Errorf("write error") +} + func TestGeneratorSuccess(t *testing.T) { testCases := map[string]struct { request *plugin.GenerateRequest @@ -194,9 +209,16 @@ func TestGeneratorSuccess(t *testing.T) { testCase := testCase t.Run(testName, func(t *testing.T) { - response, err := runGenerateFromReader(testCase.request) + requestReader, err := requestToReader(testCase.request) + assert.NoError(t, err) + + responseBuffer := &bytes.Buffer{} + err = generator.GenerateFromReader(requestReader, responseBuffer) + assert.NoError(t, err) + response, err := responseFromReader(responseBuffer) assert.NoError(t, err) + assert.EqualExportedValues(t, testCase.expected, response) }) } @@ -204,57 +226,80 @@ func TestGeneratorSuccess(t *testing.T) { func TestGeneratorFailure(t *testing.T) { testCases := map[string]struct { - request *plugin.GenerateRequest + requestReader io.Reader + response io.Writer expectedErrMsg string }{ + "bad reader": { + requestReader: &errorReaderWriter{}, + response: &bytes.Buffer{}, + expectedErrMsg: "failed to read from stream", + }, + "bad writer": { + requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ + PluginOptions: []byte(`{ + "filename": "test.file", + "template": "" + }`), + }), + response: &errorReaderWriter{}, + expectedErrMsg: "failed to write to the stream", + }, "empty options": { - request: &plugin.GenerateRequest{}, + requestReader: requestToReaderNoErr(&plugin.GenerateRequest{}), + response: &bytes.Buffer{}, expectedErrMsg: "failed to parse the sqlc config 'sql[].codegen.options' field to JSON", }, "invalid options JSON": { - request: &plugin.GenerateRequest{ + requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ PluginOptions: []byte("not a JSON at all"), - }, + }), + response: &bytes.Buffer{}, expectedErrMsg: "failed to parse the sqlc config 'sql[].codegen.options' field to JSON", }, "empty options JSON": { - request: &plugin.GenerateRequest{ + requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ PluginOptions: []byte("{}"), - }, + }), + response: &bytes.Buffer{}, expectedErrMsg: "missing the sqlc config 'sql[].codegen.options.filename' field", }, "missing template option": { - request: &plugin.GenerateRequest{ + requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ PluginOptions: []byte(`{ "filename": "test.file" }`), - }, + }), + response: &bytes.Buffer{}, expectedErrMsg: "missing the sqlc 'sql[].codegen.options.template' field", }, "missing filename option": { - request: &plugin.GenerateRequest{ + requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ PluginOptions: []byte(`{ "template": "nothing" }`), - }, + }), + response: &bytes.Buffer{}, expectedErrMsg: "missing the sqlc config 'sql[].codegen.options.filename' field", }, "invalid template option": { - request: &plugin.GenerateRequest{ + requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ PluginOptions: []byte(`{ "filename": "test.file", "template": "{{ invalid" }`), - }, + }), + response: &bytes.Buffer{}, expectedErrMsg: "failed to parse the template", }, "template option using non existant data": { - request: &plugin.GenerateRequest{ + requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ PluginOptions: []byte(`{ "filename": "test.file", "template": "{{ .invalid }}" }`), - }, + }), + response: &bytes.Buffer{}, expectedErrMsg: "failed to execute the template", }, } @@ -263,10 +308,9 @@ func TestGeneratorFailure(t *testing.T) { testCase := testCase t.Run(testName, func(t *testing.T) { - response, err := runGenerateFromReader(testCase.request) + err := generator.GenerateFromReader(testCase.requestReader, testCase.response) assert.Error(t, err) - assert.Nil(t, response) assert.ErrorContains(t, err, testCase.expectedErrMsg) }) } From 30a0a9bbbe77695cbcc08f21f30db7b6849a1d8a Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Thu, 30 Jan 2025 11:56:41 +0000 Subject: [PATCH 07/10] add tinygo compiler --- Dockerfile | 10 ++++++++++ Makefile | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 31964a6..d1ab95a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,8 @@ ARG DEV_USER_NAME=dev ARG DEV_GROUP_ID=${DEV_USER_ID} ARG DEV_GROUP_NAME=${DEV_USER_NAME} +ENV TINYGOROOT="/usr/local/tinygo/" + RUN \ # Install tools. apt-get update && \ @@ -57,6 +59,14 @@ RUN \ apt-get clean && \ apt-get autoremove && \ rm -rf /var/lib/apt/lists/* && \ + # Install tinygo, go compiler capable of building smaller binaries. + mkdir -p /tmp/tinygo && \ + curl -sL https://github.com/tinygo-org/tinygo/releases/download/v0.35.0/tinygo0.35.0.linux-amd64.tar.gz -o /tmp/tinygo/tinygo.tar.gz && \ + tar xzf /tmp/tinygo/tinygo.tar.gz --directory /tmp/tinygo && \ + mkdir -p /usr/local/tinygo && \ + mv /tmp/tinygo/tinygo/* /usr/local/tinygo/ && \ + ln -s /usr/local/tinygo/bin/tinygo /usr/local/bin/tinygo && \ + rm -Rf /tmp/tinygo && \ # Set zsh as the default shell for the root user. chsh -s $(which zsh) && \ # Install Oh My Zsh (to improve the development shell experience) for the root user. diff --git a/Makefile b/Makefile index 530265e..41d3917 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,13 @@ clean: .PHONY: build build: clean generate-protobuf mkdir -p bin - GOOS=wasip1 GOARCH=wasm go build -o bin/main.wasm cmd/sqlc-template/main.go + GOOS=wasip1 GOARCH=wasm go build -o bin/sqlc-template.wasm cmd/sqlc-template/main.go + +# make tiny-build # Build the go binary using the tinygo compiler. +.PHONY: tiny-build +tiny-build: clean generate-protobuf + mkdir -p bin + GOOS=wasip1 GOARCH=wasm tinygo build -o bin/sqlc-template.wasm cmd/sqlc-template/main.go # make container run="" # Run a command from inside the container. Examples: `make container run="make spell-check"`. .PHONY: container From 741d0b1457849e4713d1663f9257b5537f383ea4 Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Thu, 30 Jan 2025 14:40:25 +0000 Subject: [PATCH 08/10] add bad reader data test --- internal/generator/generator_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/generator/generator_test.go b/internal/generator/generator_test.go index 3a94928..68a7b16 100644 --- a/internal/generator/generator_test.go +++ b/internal/generator/generator_test.go @@ -245,6 +245,11 @@ func TestGeneratorFailure(t *testing.T) { response: &errorReaderWriter{}, expectedErrMsg: "failed to write to the stream", }, + "bad reader data": { + requestReader: bytes.NewBuffer([]byte("not a binary protobuf message at all")), + response: &bytes.Buffer{}, + expectedErrMsg: "failed to parse / unmarshal the sqlc plugin GenerateRequest", + }, "empty options": { requestReader: requestToReaderNoErr(&plugin.GenerateRequest{}), response: &bytes.Buffer{}, From c869062fd5ef20edc178a02e2590a314c02b927d Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Fri, 31 Jan 2025 19:07:47 +0000 Subject: [PATCH 09/10] remove missed file from merge --- go.mod | 1 - go.sum | 2 - internal/generator/generator.go | 102 --------- internal/generator/generator_test.go | 322 --------------------------- 4 files changed, 427 deletions(-) delete mode 100644 internal/generator/generator.go delete mode 100644 internal/generator/generator_test.go diff --git a/go.mod b/go.mod index 9330463..7939c91 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.21.4 require ( github.com/Masterminds/sprig/v3 v3.3.0 - github.com/iancoleman/strcase v0.3.0 github.com/stretchr/testify v1.10.0 google.golang.org/protobuf v1.36.4 ) diff --git a/go.sum b/go.sum index 4cd296b..b293e89 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= -github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= diff --git a/internal/generator/generator.go b/internal/generator/generator.go deleted file mode 100644 index b53fb5f..0000000 --- a/internal/generator/generator.go +++ /dev/null @@ -1,102 +0,0 @@ -package generator - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "strings" - "text/template" - - "github.com/iancoleman/strcase" - "google.golang.org/protobuf/proto" - - "github.com/NMFR/sqlc-template/internal/protos/plugin" -) - -type pluginOptions struct { - Filename *string `json:"filename,omitempty"` - Template *string `json:"template,omitempty"` -} - -func Generate(request *plugin.GenerateRequest) (*plugin.GenerateResponse, error) { - pluginOptions := &pluginOptions{} - if err := json.Unmarshal(request.GetPluginOptions(), pluginOptions); err != nil { - return nil, fmt.Errorf("failed to parse the sqlc config 'sql[].codegen.options' field to JSON, %w", err) - } - - if pluginOptions.Filename == nil { - return nil, fmt.Errorf("missing the sqlc config 'sql[].codegen.options.filename' field") - } - - if pluginOptions.Template == nil { - return nil, fmt.Errorf("missing the sqlc 'sql[].codegen.options.template' field") - } - - funcMap := template.FuncMap{ - "ReplaceAll": strings.ReplaceAll, - "ToLower": strings.ToLower, - "ToUpper": strings.ToUpper, - - "ToSnake": strcase.ToSnake, // ("foo bar") => "foo_bar" - "ToScreamingSnake": strcase.ToScreamingSnake, // ("foo bar") => "FOO_BAR" - "ToKebab": strcase.ToKebab, // ("foo bar") => "foo-bar" - "ToScreamingKebab": strcase.ToScreamingKebab, // ("foo bar") => "FOO-BAR" - "ToCamel": strcase.ToCamel, // ("foo bar") => "FooBar" - "ToLowerCamel": strcase.ToLowerCamel, // ("foo bar") => "fooBar" - } - - tmpl, err := template.New("template").Funcs(funcMap).Parse(*pluginOptions.Template) - if err != nil { - return nil, fmt.Errorf("failed to parse the template, %w", err) - } - - buf := bytes.Buffer{} - if err := tmpl.Execute(&buf, request); err != nil { - return nil, fmt.Errorf("failed to execute the template, %w", err) - } - - return &plugin.GenerateResponse{ - Files: []*plugin.File{ - {Name: *pluginOptions.Filename, Contents: buf.Bytes()}, - }, - }, - nil -} - -func GenerateFromBytes(in []byte) ([]byte, error) { - request := &plugin.GenerateRequest{} - if err := proto.Unmarshal(in, request); err != nil { - return nil, fmt.Errorf("failed to parse / unmarshal the sqlc plugin GenerateRequest, %w", err) - } - - response, err := Generate(request) - if err != nil { - return nil, fmt.Errorf("failed to generate, %w", err) - } - - out, err := proto.Marshal(response) - if err != nil { - return nil, fmt.Errorf("failed to format / marshal the sqlc plugin GenerateResponse, %w", err) - } - - return out, nil -} - -func GenerateFromReader(reader io.Reader, writer io.Writer) error { - in, err := io.ReadAll(reader) - if err != nil { - return fmt.Errorf("failed to read from stream, %w", err) - } - - out, err := GenerateFromBytes(in) - if err != nil { - return err - } - - if _, err = writer.Write(out); err != nil { - return fmt.Errorf("failed to write to the stream, %w", err) - } - - return nil -} diff --git a/internal/generator/generator_test.go b/internal/generator/generator_test.go deleted file mode 100644 index 68a7b16..0000000 --- a/internal/generator/generator_test.go +++ /dev/null @@ -1,322 +0,0 @@ -package generator_test - -import ( - "bytes" - "fmt" - "io" - "strings" - "testing" - - "github.com/stretchr/testify/assert" - "google.golang.org/protobuf/proto" - - "github.com/NMFR/sqlc-template/internal/generator" - "github.com/NMFR/sqlc-template/internal/protos/plugin" -) - -// jsonString escapes a string for a valid string property in a json document. -func jsonString(str string) string { - for old, new := range map[string]string{ - "\n": "\\n", - "\t": "\\t", - "\"": "\\\"", - } { - str = strings.ReplaceAll(str, old, new) - } - - return str -} - -func requestToReader(request *plugin.GenerateRequest) (io.Reader, error) { - requestBytes, err := proto.Marshal(request) - if err != nil { - return nil, err - } - - return bytes.NewBuffer(requestBytes), nil -} - -func requestToReaderNoErr(request *plugin.GenerateRequest) io.Reader { - response, err := requestToReader(request) - if err != nil { - panic(err) - } - - return response -} - -func responseFromReader(reader io.Reader) (*plugin.GenerateResponse, error) { - responseBytes, err := io.ReadAll(reader) - if err != nil { - return nil, err - } - - response := &plugin.GenerateResponse{} - err = proto.Unmarshal(responseBytes, response) - if err != nil { - return nil, err - } - - return response, nil -} - -type errorReaderWriter struct{} - -func (rw *errorReaderWriter) Read(p []byte) (n int, err error) { - return 0, fmt.Errorf("read error") -} - -func (rw *errorReaderWriter) Write(p []byte) (n int, err error) { - return 0, fmt.Errorf("write error") -} - -func TestGeneratorSuccess(t *testing.T) { - testCases := map[string]struct { - request *plugin.GenerateRequest - expected *plugin.GenerateResponse - }{ - "empty": { - request: &plugin.GenerateRequest{ - PluginOptions: []byte(`{ - "filename": "test.file", - "template": "" - }`), - }, - expected: &plugin.GenerateResponse{ - Files: []*plugin.File{ - { - Name: "test.file", - Contents: nil, - }, - }, - }, - }, - "test-buildin-funcs": { - request: &plugin.GenerateRequest{ - PluginOptions: []byte(`{ - "filename": "test.file", - "template": "` + jsonString(` - {{ ReplaceAll "foo bar foo bar" "bar" "foo" }} - {{ "FoO bAr" | ToLower }} - {{ "FoO bAr" | ToUpper }} - {{ "foo bar" | ToSnake }} - {{ "foo bar" | ToScreamingSnake }} - {{ "foo bar" | ToKebab }} - {{ "foo bar" | ToScreamingKebab }} - {{ "foo bar" | ToCamel }} - {{ "foo bar" | ToLowerCamel }} -`) + `" - }`), - }, - expected: &plugin.GenerateResponse{ - Files: []*plugin.File{ - { - Name: "test.file", - Contents: []byte(` - foo foo foo foo - foo bar - FOO BAR - foo_bar - FOO_BAR - foo-bar - FOO-BAR - FooBar - fooBar -`), - }, - }, - }, - }, - "simple-template": { - request: &plugin.GenerateRequest{ - Queries: []*plugin.Query{ - { - Name: "mock query", - Cmd: ":one", - Params: []*plugin.Parameter{ - { - Column: &plugin.Column{ - Name: "mock param", - Type: &plugin.Identifier{Name: "text"}, - }, - }, - { - Column: &plugin.Column{ - Name: "another mock param", - Type: &plugin.Identifier{Name: "int"}, - }, - }, - }, - Columns: []*plugin.Column{ - { - Name: "mock column", - Type: &plugin.Identifier{Name: "int"}, - }, - { - Name: "another mock column", - Type: &plugin.Identifier{Name: "bool"}, - }, - }, - }, - }, - PluginOptions: []byte(`{ - "filename": "some.file", - "template": "` + jsonString(` - queries: - {{- range .Queries }} - - name: {{ .Name | ToLowerCamel }} - cmd: {{ .Cmd }} - params: - {{- range .Params }} - - name: {{ .Column.Name | ToLowerCamel }} - type: {{ .Column.Type.Name -}} - {{ end }} - columns: - {{- range .Columns }} - - name: {{ .Name | ToLowerCamel }} - type: {{ .Type.Name -}} - {{ end -}} - {{ end }} -`) + `" - }`), - }, - expected: &plugin.GenerateResponse{ - Files: []*plugin.File{ - { - Name: "some.file", - Contents: []byte(` - queries: - - name: mockQuery - cmd: :one - params: - - name: mockParam - type: text - - name: anotherMockParam - type: int - columns: - - name: mockColumn - type: int - - name: anotherMockColumn - type: bool -`), - }, - }, - }, - }, - } - - for testName, testCase := range testCases { - testCase := testCase - - t.Run(testName, func(t *testing.T) { - requestReader, err := requestToReader(testCase.request) - assert.NoError(t, err) - - responseBuffer := &bytes.Buffer{} - err = generator.GenerateFromReader(requestReader, responseBuffer) - assert.NoError(t, err) - - response, err := responseFromReader(responseBuffer) - assert.NoError(t, err) - - assert.EqualExportedValues(t, testCase.expected, response) - }) - } -} - -func TestGeneratorFailure(t *testing.T) { - testCases := map[string]struct { - requestReader io.Reader - response io.Writer - expectedErrMsg string - }{ - "bad reader": { - requestReader: &errorReaderWriter{}, - response: &bytes.Buffer{}, - expectedErrMsg: "failed to read from stream", - }, - "bad writer": { - requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ - PluginOptions: []byte(`{ - "filename": "test.file", - "template": "" - }`), - }), - response: &errorReaderWriter{}, - expectedErrMsg: "failed to write to the stream", - }, - "bad reader data": { - requestReader: bytes.NewBuffer([]byte("not a binary protobuf message at all")), - response: &bytes.Buffer{}, - expectedErrMsg: "failed to parse / unmarshal the sqlc plugin GenerateRequest", - }, - "empty options": { - requestReader: requestToReaderNoErr(&plugin.GenerateRequest{}), - response: &bytes.Buffer{}, - expectedErrMsg: "failed to parse the sqlc config 'sql[].codegen.options' field to JSON", - }, - "invalid options JSON": { - requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ - PluginOptions: []byte("not a JSON at all"), - }), - response: &bytes.Buffer{}, - expectedErrMsg: "failed to parse the sqlc config 'sql[].codegen.options' field to JSON", - }, - "empty options JSON": { - requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ - PluginOptions: []byte("{}"), - }), - response: &bytes.Buffer{}, - expectedErrMsg: "missing the sqlc config 'sql[].codegen.options.filename' field", - }, - "missing template option": { - requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ - PluginOptions: []byte(`{ - "filename": "test.file" - }`), - }), - response: &bytes.Buffer{}, - expectedErrMsg: "missing the sqlc 'sql[].codegen.options.template' field", - }, - "missing filename option": { - requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ - PluginOptions: []byte(`{ - "template": "nothing" - }`), - }), - response: &bytes.Buffer{}, - expectedErrMsg: "missing the sqlc config 'sql[].codegen.options.filename' field", - }, - "invalid template option": { - requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ - PluginOptions: []byte(`{ - "filename": "test.file", - "template": "{{ invalid" - }`), - }), - response: &bytes.Buffer{}, - expectedErrMsg: "failed to parse the template", - }, - "template option using non existant data": { - requestReader: requestToReaderNoErr(&plugin.GenerateRequest{ - PluginOptions: []byte(`{ - "filename": "test.file", - "template": "{{ .invalid }}" - }`), - }), - response: &bytes.Buffer{}, - expectedErrMsg: "failed to execute the template", - }, - } - - for testName, testCase := range testCases { - testCase := testCase - - t.Run(testName, func(t *testing.T) { - err := generator.GenerateFromReader(testCase.requestReader, testCase.response) - - assert.Error(t, err) - assert.ErrorContains(t, err, testCase.expectedErrMsg) - }) - } -} From 61021501da3f2bc9aa52c05dbc643e6ba58eca29 Mon Sep 17 00:00:00 2001 From: Nuno Rodrigues Date: Fri, 31 Jan 2025 19:48:44 +0000 Subject: [PATCH 10/10] install tinygo in the base stage --- Dockerfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index f35eb8c..4407e25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,8 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] WORKDIR /opt/app +ENV TINYGOROOT="/usr/local/tinygo/" + # Non root user details. ARG USER_ID=1000 ARG USER_NAME=dev @@ -37,6 +39,14 @@ RUN \ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 && \ # Install the golangci-lint linter. curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.63.4 && \ + # Install tinygo, go compiler capable of building smaller binaries. + mkdir -p /tmp/tinygo && \ + curl -sL https://github.com/tinygo-org/tinygo/releases/download/v0.35.0/tinygo0.35.0.linux-amd64.tar.gz -o /tmp/tinygo/tinygo.tar.gz && \ + tar xzf /tmp/tinygo/tinygo.tar.gz --directory /tmp/tinygo && \ + mkdir -p /usr/local/tinygo && \ + mv /tmp/tinygo/tinygo/* /usr/local/tinygo/ && \ + ln -s /usr/local/tinygo/bin/tinygo /usr/local/bin/tinygo && \ + rm -Rf /tmp/tinygo && \ # Create the non root user and group. groupadd --gid ${GROUP_ID} ${GROUP_NAME} && \ useradd --uid ${USER_ID} --gid ${GROUP_ID} --create-home ${USER_NAME} && \ @@ -52,8 +62,6 @@ ENV GIT_EDITOR="code --wait" USER root -ENV TINYGOROOT="/usr/local/tinygo/" - RUN \ # Install tools. apt-get update && \ @@ -69,14 +77,6 @@ RUN \ apt-get clean && \ apt-get autoremove && \ rm -rf /var/lib/apt/lists/* && \ - # Install tinygo, go compiler capable of building smaller binaries. - mkdir -p /tmp/tinygo && \ - curl -sL https://github.com/tinygo-org/tinygo/releases/download/v0.35.0/tinygo0.35.0.linux-amd64.tar.gz -o /tmp/tinygo/tinygo.tar.gz && \ - tar xzf /tmp/tinygo/tinygo.tar.gz --directory /tmp/tinygo && \ - mkdir -p /usr/local/tinygo && \ - mv /tmp/tinygo/tinygo/* /usr/local/tinygo/ && \ - ln -s /usr/local/tinygo/bin/tinygo /usr/local/bin/tinygo && \ - rm -Rf /tmp/tinygo && \ # Set zsh as the default shell for the root user. chsh -s $(which zsh) && \ # Install Oh My Zsh (to improve the development shell experience) for the root user.