From 8c2676b6e862efb598cbc6e4a675acdfc01eaed2 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Mon, 25 Sep 2023 13:22:07 -0700 Subject: [PATCH 1/7] feat(upload): Point upload command at new endpoint --- internal/bundler/metadata.go | 16 -- internal/bundler/multipart.go | 67 ++---- internal/bundler/upload.go | 68 +++--- internal/quickdb/v1/quickdb.pb.go | 368 +++++++++++++++++++++++++++--- 4 files changed, 390 insertions(+), 129 deletions(-) delete mode 100644 internal/bundler/metadata.go diff --git a/internal/bundler/metadata.go b/internal/bundler/metadata.go deleted file mode 100644 index 18d41e9f68..0000000000 --- a/internal/bundler/metadata.go +++ /dev/null @@ -1,16 +0,0 @@ -package bundler - -import ( - "runtime" - - "github.com/sqlc-dev/sqlc/internal/info" -) - -func projectMetadata() ([][2]string, error) { - return [][2]string{ - {"sqlc_version", info.Version}, - {"go_version", runtime.Version()}, - {"goos", runtime.GOOS}, - {"goarch", runtime.GOARCH}, - }, nil -} diff --git a/internal/bundler/multipart.go b/internal/bundler/multipart.go index dd4eed10a1..add9fc0543 100644 --- a/internal/bundler/multipart.go +++ b/internal/bundler/multipart.go @@ -1,16 +1,15 @@ package bundler import ( - "io" - "mime/multipart" "os" "path/filepath" "github.com/sqlc-dev/sqlc/internal/config" + pb "github.com/sqlc-dev/sqlc/internal/quickdb/v1" "github.com/sqlc-dev/sqlc/internal/sql/sqlpath" ) -func writeInputs(w *multipart.Writer, file string, conf *config.Config) error { +func readInputs(file string, conf *config.Config) ([]*pb.File, error) { refs := map[string]struct{}{} refs[filepath.Base(file)] = struct{}{} @@ -18,7 +17,7 @@ func writeInputs(w *multipart.Writer, file string, conf *config.Config) error { for _, paths := range []config.Paths{pkg.Schema, pkg.Queries} { files, err := sqlpath.Glob(paths) if err != nil { - return err + return nil, err } for _, file := range files { refs[file] = struct{}{} @@ -26,55 +25,33 @@ func writeInputs(w *multipart.Writer, file string, conf *config.Config) error { } } + var files []*pb.File for file, _ := range refs { - if err := addPart(w, file); err != nil { - return err - } - } - - params, err := projectMetadata() - if err != nil { - return err - } - params = append(params, [2]string{"project_id", conf.Project.ID}) - for _, val := range params { - if err = w.WriteField(val[0], val[1]); err != nil { - return err + contents, err := os.ReadFile(file) + if err != nil { + return nil, err } + files = append(files, &pb.File{ + Name: file, + MediaType: "application/octet-stream", + Contents: contents, + }) } - return nil + return files, nil } -func addPart(w *multipart.Writer, file string) error { - h, err := os.Open(file) - if err != nil { - return err - } - defer h.Close() - part, err := w.CreateFormFile("inputs", file) - if err != nil { - return err - } - _, err = io.Copy(part, h) - if err != nil { - return err - } - return nil -} - -func writeOutputs(w *multipart.Writer, dir string, output map[string]string) error { +func readOutputs(dir string, output map[string]string) ([]*pb.File, error) { + var files []*pb.File for filename, contents := range output { rel, err := filepath.Rel(dir, filename) if err != nil { - return err - } - part, err := w.CreateFormFile("outputs", rel) - if err != nil { - return err - } - if _, err := io.WriteString(part, contents); err != nil { - return err + return nil, err } + files = append(files, &pb.File{ + Name: rel, + MediaType: "application/octet-stream", + Contents: []byte(contents), + }) } - return nil + return files, nil } diff --git a/internal/bundler/upload.go b/internal/bundler/upload.go index 0d1d508f9a..eb496e6f40 100644 --- a/internal/bundler/upload.go +++ b/internal/bundler/upload.go @@ -1,16 +1,16 @@ package bundler import ( - "bytes" "context" "fmt" - "io" - "mime/multipart" - "net/http" - "net/http/httputil" "os" + "runtime" "github.com/sqlc-dev/sqlc/internal/config" + "github.com/sqlc-dev/sqlc/internal/debug" + "github.com/sqlc-dev/sqlc/internal/info" + "github.com/sqlc-dev/sqlc/internal/quickdb" + pb "github.com/sqlc-dev/sqlc/internal/quickdb/v1" ) type Uploader struct { @@ -18,6 +18,7 @@ type Uploader struct { configPath string config *config.Config dir string + client pb.QuickClient } func NewUploader(configPath, dir string, conf *config.Config) *Uploader { @@ -30,35 +31,40 @@ func NewUploader(configPath, dir string, conf *config.Config) *Uploader { } func (up *Uploader) Validate() error { - if up.config.Project.ID == "" { - return fmt.Errorf("project.id is not set") + if up.config.Cloud.Project == "" { + return fmt.Errorf("cloud.project is not set") } if up.token == "" { return fmt.Errorf("SQLC_AUTH_TOKEN environment variable is not set") } + if up.client == nil { + client, err := quickdb.NewClientFromConfig(up.config.Cloud) + if err != nil { + return fmt.Errorf("client init failed: %w", err) + } + up.client = client + } return nil } -func (up *Uploader) buildRequest(ctx context.Context, result map[string]string) (*http.Request, error) { - body := bytes.NewBuffer([]byte{}) - w := multipart.NewWriter(body) - if err := writeInputs(w, up.configPath, up.config); err != nil { - return nil, err +func (up *Uploader) buildRequest(ctx context.Context, result map[string]string) (*pb.UploadArchiveRequest, error) { + req := &pb.UploadArchiveRequest{ + SqlcVersion: info.Version, + GoVersion: runtime.Version(), + Goos: runtime.GOOS, + Goarch: runtime.GOARCH, } - if err := writeOutputs(w, up.dir, result); err != nil { - return nil, err - } - if err := w.Close(); err != nil { + ins, err := readInputs(up.configPath, up.config) + if err != nil { return nil, err } - req, err := http.NewRequest("POST", "https://api.sqlc.dev/upload", body) + outs, err := readOutputs(up.dir, result) if err != nil { return nil, err } - // Set sqlc-version header - req.Header.Set("Content-Type", w.FormDataContentType()) - req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", up.token)) - return req.WithContext(ctx), nil + req.Inputs = ins + req.Outputs = outs + return req, nil } func (up *Uploader) DumpRequestOut(ctx context.Context, result map[string]string) error { @@ -66,11 +72,7 @@ func (up *Uploader) DumpRequestOut(ctx context.Context, result map[string]string if err != nil { return err } - dump, err := httputil.DumpRequest(req, true) - if err != nil { - return err - } - os.Stdout.Write(dump) + debug.Dump(req) return nil } @@ -82,18 +84,8 @@ func (up *Uploader) Upload(ctx context.Context, result map[string]string) error if err != nil { return err } - client := &http.Client{} - resp, err := client.Do(req) - if err != nil { - return err - } - if resp.StatusCode >= 400 { - body, err := io.ReadAll(resp.Body) - defer resp.Body.Close() - if err != nil { - return fmt.Errorf("upload error: endpoint returned non-200 status code: %d", resp.StatusCode) - } - return fmt.Errorf("upload error: %d: %s", resp.StatusCode, string(body)) + if _, err := up.client.UploadArchive(ctx, req); err != nil { + return fmt.Errorf("upload error: %w", err) } return nil } diff --git a/internal/quickdb/v1/quickdb.pb.go b/internal/quickdb/v1/quickdb.pb.go index 7bdec99748..eb39dd3c68 100755 --- a/internal/quickdb/v1/quickdb.pb.go +++ b/internal/quickdb/v1/quickdb.pb.go @@ -235,6 +235,203 @@ func (*DropEphemeralDatabaseResponse) Descriptor() ([]byte, []int) { return file_proto_quickdb_v1_quickdb_proto_rawDescGZIP(), []int{3} } +type File struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MediaType string `protobuf:"bytes,1,opt,name=media_type,json=mediaType,proto3" json:"media_type,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Contents []byte `protobuf:"bytes,3,opt,name=contents,proto3" json:"contents,omitempty"` +} + +func (x *File) Reset() { + *x = File{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_quickdb_v1_quickdb_proto_msgTypes[4] + 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_proto_quickdb_v1_quickdb_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 File.ProtoReflect.Descriptor instead. +func (*File) Descriptor() ([]byte, []int) { + return file_proto_quickdb_v1_quickdb_proto_rawDescGZIP(), []int{4} +} + +func (x *File) GetMediaType() string { + if x != nil { + return x.MediaType + } + return "" +} + +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 UploadArchiveRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SqlcVersion string `protobuf:"bytes,1,opt,name=sqlc_version,json=sqlcVersion,proto3" json:"sqlc_version,omitempty"` + GoVersion string `protobuf:"bytes,2,opt,name=go_version,json=goVersion,proto3" json:"go_version,omitempty"` + Goos string `protobuf:"bytes,3,opt,name=goos,proto3" json:"goos,omitempty"` + Goarch string `protobuf:"bytes,4,opt,name=goarch,proto3" json:"goarch,omitempty"` + Inputs []*File `protobuf:"bytes,5,rep,name=inputs,proto3" json:"inputs,omitempty"` + Outputs []*File `protobuf:"bytes,6,rep,name=outputs,proto3" json:"outputs,omitempty"` +} + +func (x *UploadArchiveRequest) Reset() { + *x = UploadArchiveRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_quickdb_v1_quickdb_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UploadArchiveRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UploadArchiveRequest) ProtoMessage() {} + +func (x *UploadArchiveRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_quickdb_v1_quickdb_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 UploadArchiveRequest.ProtoReflect.Descriptor instead. +func (*UploadArchiveRequest) Descriptor() ([]byte, []int) { + return file_proto_quickdb_v1_quickdb_proto_rawDescGZIP(), []int{5} +} + +func (x *UploadArchiveRequest) GetSqlcVersion() string { + if x != nil { + return x.SqlcVersion + } + return "" +} + +func (x *UploadArchiveRequest) GetGoVersion() string { + if x != nil { + return x.GoVersion + } + return "" +} + +func (x *UploadArchiveRequest) GetGoos() string { + if x != nil { + return x.Goos + } + return "" +} + +func (x *UploadArchiveRequest) GetGoarch() string { + if x != nil { + return x.Goarch + } + return "" +} + +func (x *UploadArchiveRequest) GetInputs() []*File { + if x != nil { + return x.Inputs + } + return nil +} + +func (x *UploadArchiveRequest) GetOutputs() []*File { + if x != nil { + return x.Outputs + } + return nil +} + +type UploadArchiveResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Checksum []byte `protobuf:"bytes,1,opt,name=checksum,proto3" json:"checksum,omitempty"` +} + +func (x *UploadArchiveResponse) Reset() { + *x = UploadArchiveResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_quickdb_v1_quickdb_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UploadArchiveResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UploadArchiveResponse) ProtoMessage() {} + +func (x *UploadArchiveResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_quickdb_v1_quickdb_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 UploadArchiveResponse.ProtoReflect.Descriptor instead. +func (*UploadArchiveResponse) Descriptor() ([]byte, []int) { + return file_proto_quickdb_v1_quickdb_proto_rawDescGZIP(), []int{6} +} + +func (x *UploadArchiveResponse) GetChecksum() []byte { + if x != nil { + return x.Checksum + } + return nil +} + var File_proto_quickdb_v1_quickdb_proto protoreflect.FileDescriptor var file_proto_quickdb_v1_quickdb_proto_rawDesc = []byte{ @@ -262,26 +459,58 @@ var file_proto_quickdb_v1_quickdb_proto_rawDesc = []byte{ 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x49, 0x64, 0x22, 0x1f, 0x0a, 0x1d, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xab, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x12, 0x92, - 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, - 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x3a, 0x2e, 0x72, 0x65, 0x6d, - 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, - 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, - 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, - 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, - 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, - 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x8c, 0x01, 0x0a, 0x15, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, - 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x38, 0x2e, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x55, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x1d, 0x0a, 0x0a, + 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xfa, 0x01, 0x0a, 0x14, + 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x71, 0x6c, 0x63, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x6f, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x6f, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x67, 0x6f, 0x6f, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x67, 0x6f, 0x6f, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x6f, + 0x61, 0x72, 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x6f, 0x61, 0x72, + 0x63, 0x68, 0x12, 0x38, 0x0a, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, + 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, + 0x46, 0x69, 0x6c, 0x65, 0x52, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x07, + 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, - 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, - 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, - 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, - 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, - 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, + 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x22, 0x33, 0x0a, 0x15, 0x55, 0x70, 0x6c, 0x6f, + 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x32, 0xa1, 0x03, + 0x0a, 0x05, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x12, 0x92, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, + 0x61, 0x73, 0x65, 0x12, 0x3a, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, + 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, + 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x3b, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, + 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, + 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8c, 0x01, 0x0a, + 0x15, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, + 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x38, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, + 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, + 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, + 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x39, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, + 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, + 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, + 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x74, 0x0a, 0x0d, 0x55, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x12, 0x30, 0x2e, 0x72, + 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, + 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, + 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, + 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, + 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, + 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -296,23 +525,30 @@ func file_proto_quickdb_v1_quickdb_proto_rawDescGZIP() []byte { return file_proto_quickdb_v1_quickdb_proto_rawDescData } -var file_proto_quickdb_v1_quickdb_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_proto_quickdb_v1_quickdb_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_proto_quickdb_v1_quickdb_proto_goTypes = []interface{}{ (*CreateEphemeralDatabaseRequest)(nil), // 0: remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseRequest (*CreateEphemeralDatabaseResponse)(nil), // 1: remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseResponse (*DropEphemeralDatabaseRequest)(nil), // 2: remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseRequest (*DropEphemeralDatabaseResponse)(nil), // 3: remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseResponse + (*File)(nil), // 4: remote.sqlc.dev.quickdb.v1.File + (*UploadArchiveRequest)(nil), // 5: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest + (*UploadArchiveResponse)(nil), // 6: remote.sqlc.dev.quickdb.v1.UploadArchiveResponse } var file_proto_quickdb_v1_quickdb_proto_depIdxs = []int32{ - 0, // 0: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseRequest - 2, // 1: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseRequest - 1, // 2: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseResponse - 3, // 3: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseResponse - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 4, // 0: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.inputs:type_name -> remote.sqlc.dev.quickdb.v1.File + 4, // 1: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.outputs:type_name -> remote.sqlc.dev.quickdb.v1.File + 0, // 2: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseRequest + 2, // 3: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseRequest + 5, // 4: remote.sqlc.dev.quickdb.v1.Quick.UploadArchive:input_type -> remote.sqlc.dev.quickdb.v1.UploadArchiveRequest + 1, // 5: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseResponse + 3, // 6: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseResponse + 6, // 7: remote.sqlc.dev.quickdb.v1.Quick.UploadArchive:output_type -> remote.sqlc.dev.quickdb.v1.UploadArchiveResponse + 5, // [5:8] is the sub-list for method output_type + 2, // [2:5] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_proto_quickdb_v1_quickdb_proto_init() } @@ -369,6 +605,42 @@ func file_proto_quickdb_v1_quickdb_proto_init() { return nil } } + file_proto_quickdb_v1_quickdb_proto_msgTypes[4].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_proto_quickdb_v1_quickdb_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadArchiveRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_quickdb_v1_quickdb_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadArchiveResponse); 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{ @@ -376,7 +648,7 @@ func file_proto_quickdb_v1_quickdb_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_quickdb_v1_quickdb_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, @@ -404,6 +676,7 @@ const _ = grpc.SupportPackageIsVersion6 type QuickClient interface { CreateEphemeralDatabase(ctx context.Context, in *CreateEphemeralDatabaseRequest, opts ...grpc.CallOption) (*CreateEphemeralDatabaseResponse, error) DropEphemeralDatabase(ctx context.Context, in *DropEphemeralDatabaseRequest, opts ...grpc.CallOption) (*DropEphemeralDatabaseResponse, error) + UploadArchive(ctx context.Context, in *UploadArchiveRequest, opts ...grpc.CallOption) (*UploadArchiveResponse, error) } type quickClient struct { @@ -432,10 +705,20 @@ func (c *quickClient) DropEphemeralDatabase(ctx context.Context, in *DropEphemer return out, nil } +func (c *quickClient) UploadArchive(ctx context.Context, in *UploadArchiveRequest, opts ...grpc.CallOption) (*UploadArchiveResponse, error) { + out := new(UploadArchiveResponse) + err := c.cc.Invoke(ctx, "/remote.sqlc.dev.quickdb.v1.Quick/UploadArchive", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QuickServer is the server API for Quick service. type QuickServer interface { CreateEphemeralDatabase(context.Context, *CreateEphemeralDatabaseRequest) (*CreateEphemeralDatabaseResponse, error) DropEphemeralDatabase(context.Context, *DropEphemeralDatabaseRequest) (*DropEphemeralDatabaseResponse, error) + UploadArchive(context.Context, *UploadArchiveRequest) (*UploadArchiveResponse, error) } // UnimplementedQuickServer can be embedded to have forward compatible implementations. @@ -448,6 +731,9 @@ func (*UnimplementedQuickServer) CreateEphemeralDatabase(context.Context, *Creat func (*UnimplementedQuickServer) DropEphemeralDatabase(context.Context, *DropEphemeralDatabaseRequest) (*DropEphemeralDatabaseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DropEphemeralDatabase not implemented") } +func (*UnimplementedQuickServer) UploadArchive(context.Context, *UploadArchiveRequest) (*UploadArchiveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UploadArchive not implemented") +} func RegisterQuickServer(s *grpc.Server, srv QuickServer) { s.RegisterService(&_Quick_serviceDesc, srv) @@ -489,6 +775,24 @@ func _Quick_DropEphemeralDatabase_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _Quick_UploadArchive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UploadArchiveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QuickServer).UploadArchive(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/remote.sqlc.dev.quickdb.v1.Quick/UploadArchive", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QuickServer).UploadArchive(ctx, req.(*UploadArchiveRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Quick_serviceDesc = grpc.ServiceDesc{ ServiceName: "remote.sqlc.dev.quickdb.v1.Quick", HandlerType: (*QuickServer)(nil), @@ -501,6 +805,10 @@ var _Quick_serviceDesc = grpc.ServiceDesc{ MethodName: "DropEphemeralDatabase", Handler: _Quick_DropEphemeralDatabase_Handler, }, + { + MethodName: "UploadArchive", + Handler: _Quick_UploadArchive_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "proto/quickdb/v1/quickdb.proto", From d10b14684e51fd5b3035889c4dbb34c70fa439b7 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Mon, 25 Sep 2023 13:23:59 -0700 Subject: [PATCH 2/7] fix(config): Remove unused project field --- internal/config/config.go | 5 ----- internal/config/v_one.go | 2 -- internal/config/v_one.json | 8 -------- internal/config/v_two.json | 8 -------- 4 files changed, 23 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index d28ec0e62d..4a17903e6e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -56,7 +56,6 @@ const ( type Config struct { Version string `json:"version" yaml:"version"` - Project Project `json:"project" yaml:"project"` Cloud Cloud `json:"cloud" yaml:"cloud"` SQL []SQL `json:"sql" yaml:"sql"` Gen Gen `json:"overrides,omitempty" yaml:"overrides"` @@ -64,10 +63,6 @@ type Config struct { Rules []Rule `json:"rules" yaml:"rules"` } -type Project struct { - ID string `json:"id" yaml:"id"` -} - type Database struct { URI string `json:"uri" yaml:"uri"` Managed bool `json:"managed" yaml:"managed"` diff --git a/internal/config/v_one.go b/internal/config/v_one.go index 22906cee82..3d2a53f13a 100644 --- a/internal/config/v_one.go +++ b/internal/config/v_one.go @@ -11,7 +11,6 @@ import ( type V1GenerateSettings struct { Version string `json:"version" yaml:"version"` Cloud Cloud `json:"cloud" yaml:"cloud"` - Project Project `json:"project" yaml:"project"` Packages []v1PackageSettings `json:"packages" yaml:"packages"` Overrides []Override `json:"overrides,omitempty" yaml:"overrides,omitempty"` Rename map[string]string `json:"rename,omitempty" yaml:"rename,omitempty"` @@ -132,7 +131,6 @@ func (c *V1GenerateSettings) ValidateGlobalOverrides() error { func (c *V1GenerateSettings) Translate() Config { conf := Config{ Version: c.Version, - Project: c.Project, Cloud: c.Cloud, Rules: c.Rules, } diff --git a/internal/config/v_one.json b/internal/config/v_one.json index 329b012ff4..e2e8fb03cc 100644 --- a/internal/config/v_one.json +++ b/internal/config/v_one.json @@ -8,14 +8,6 @@ "version": { "const": "1" }, - "project": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, "cloud": { "type": "object", "properties": { diff --git a/internal/config/v_two.json b/internal/config/v_two.json index 65fdd7bb7e..a77f2616df 100644 --- a/internal/config/v_two.json +++ b/internal/config/v_two.json @@ -8,14 +8,6 @@ "version": { "const": "2" }, - "project": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, "cloud": { "type": "object", "properties": { From 9eb6f94c947d7300b1fe83211ef5bac64f1bfeb1 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Mon, 25 Sep 2023 13:44:34 -0700 Subject: [PATCH 3/7] Update docs --- docs/howto/upload.md | 38 +++++++++++++++----------------------- internal/bundler/upload.go | 5 +++-- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/docs/howto/upload.md b/docs/howto/upload.md index 0add35c942..feb900fbf6 100644 --- a/docs/howto/upload.md +++ b/docs/howto/upload.md @@ -1,35 +1,26 @@ # Uploading projects -*This feature requires signing up for [sqlc Cloud](https://app.sqlc.dev), which is currently in beta.* +*Added in v1.22.0* -Uploading your project ensures that future releases of sqlc do not break your -existing code. Similar to Rust's [crater](https://github.com/rust-lang/crater) -project, uploaded projects are tested against development releases of sqlc to +Uploading an archive of your project ensures that future releases of sqlc do not +break your code. Similar to Rust's [crater](https://github.com/rust-lang/crater) +project, uploaded archives are tested against development releases of sqlc to verify correctness. +Interested in uploading projects? Sign up [here](https://docs.google.com/forms/d/e/1FAIpQLSdxoMzJ7rKkBpuez-KyBcPNyckYV-5iMR--FRB7WnhvAmEvKg/viewform) or send us an email +at [hello@sqlc.dev](mailto:hello@sqlc.dev). + ## Add configuration After creating a project, add the project ID to your sqlc configuration file. ```yaml -version: "1" -project: - id: "" -packages: [] -``` - -```json -{ - "version": "1", - "project": { - "id": "" - }, - "packages": [ - ] -} +version: "2" +cloud: + project: "" ``` -You'll also need to create an API token and make it available via the +You'll also need to create an auth token and make it available via the `SQLC_AUTH_TOKEN` environment variable. ```shell @@ -38,13 +29,14 @@ export SQLC_AUTH_TOKEN=sqlc_xxxxxxxx ## Dry run -You can see what's included when uploading your project by using using the `--dry-run` flag: +You can see what's included when uploading your project by using using the +`--dry-run` flag: ```shell sqlc upload --dry-run ``` -The output will be the exact HTTP request sent by `sqlc`. +The output will be request sent by `sqlc`. ## Upload @@ -54,4 +46,4 @@ Once you're ready to upload, remove the `--dry-run` flag. sqlc upload ``` -By uploading your project, you're making sqlc more stable and reliable. Thanks! +By uploading your project, you're making sqlc more stable and reliable. Thanks! \ No newline at end of file diff --git a/internal/bundler/upload.go b/internal/bundler/upload.go index eb496e6f40..de0409c47a 100644 --- a/internal/bundler/upload.go +++ b/internal/bundler/upload.go @@ -6,8 +6,9 @@ import ( "os" "runtime" + "google.golang.org/protobuf/encoding/protojson" + "github.com/sqlc-dev/sqlc/internal/config" - "github.com/sqlc-dev/sqlc/internal/debug" "github.com/sqlc-dev/sqlc/internal/info" "github.com/sqlc-dev/sqlc/internal/quickdb" pb "github.com/sqlc-dev/sqlc/internal/quickdb/v1" @@ -72,7 +73,7 @@ func (up *Uploader) DumpRequestOut(ctx context.Context, result map[string]string if err != nil { return err } - debug.Dump(req) + fmt.Println(protojson.Format(req)) return nil } From a93427d9032bb84392baa082c9ca0d26fca5f97f Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Mon, 25 Sep 2023 16:07:36 -0700 Subject: [PATCH 4/7] use latest client --- internal/bundler/multipart.go | 10 +-- internal/bundler/upload.go | 15 ++-- internal/quickdb/v1/quickdb.pb.go | 131 +++++++++++------------------- 3 files changed, 55 insertions(+), 101 deletions(-) diff --git a/internal/bundler/multipart.go b/internal/bundler/multipart.go index add9fc0543..1336c1a559 100644 --- a/internal/bundler/multipart.go +++ b/internal/bundler/multipart.go @@ -32,9 +32,8 @@ func readInputs(file string, conf *config.Config) ([]*pb.File, error) { return nil, err } files = append(files, &pb.File{ - Name: file, - MediaType: "application/octet-stream", - Contents: contents, + Name: file, + Contents: contents, }) } return files, nil @@ -48,9 +47,8 @@ func readOutputs(dir string, output map[string]string) ([]*pb.File, error) { return nil, err } files = append(files, &pb.File{ - Name: rel, - MediaType: "application/octet-stream", - Contents: []byte(contents), + Name: rel, + Contents: []byte(contents), }) } return files, nil diff --git a/internal/bundler/upload.go b/internal/bundler/upload.go index de0409c47a..1152925e02 100644 --- a/internal/bundler/upload.go +++ b/internal/bundler/upload.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "os" - "runtime" "google.golang.org/protobuf/encoding/protojson" @@ -49,12 +48,6 @@ func (up *Uploader) Validate() error { } func (up *Uploader) buildRequest(ctx context.Context, result map[string]string) (*pb.UploadArchiveRequest, error) { - req := &pb.UploadArchiveRequest{ - SqlcVersion: info.Version, - GoVersion: runtime.Version(), - Goos: runtime.GOOS, - Goarch: runtime.GOARCH, - } ins, err := readInputs(up.configPath, up.config) if err != nil { return nil, err @@ -63,9 +56,11 @@ func (up *Uploader) buildRequest(ctx context.Context, result map[string]string) if err != nil { return nil, err } - req.Inputs = ins - req.Outputs = outs - return req, nil + return &pb.UploadArchiveRequest{ + SqlcVersion: info.Version, + Inputs: ins, + Outputs: outs, + }, nil } func (up *Uploader) DumpRequestOut(ctx context.Context, result map[string]string) error { diff --git a/internal/quickdb/v1/quickdb.pb.go b/internal/quickdb/v1/quickdb.pb.go index eb39dd3c68..34f4e1739c 100755 --- a/internal/quickdb/v1/quickdb.pb.go +++ b/internal/quickdb/v1/quickdb.pb.go @@ -240,9 +240,8 @@ type File struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - MediaType string `protobuf:"bytes,1,opt,name=media_type,json=mediaType,proto3" json:"media_type,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Contents []byte `protobuf:"bytes,3,opt,name=contents,proto3" json:"contents,omitempty"` + 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() { @@ -277,13 +276,6 @@ func (*File) Descriptor() ([]byte, []int) { return file_proto_quickdb_v1_quickdb_proto_rawDescGZIP(), []int{4} } -func (x *File) GetMediaType() string { - if x != nil { - return x.MediaType - } - return "" -} - func (x *File) GetName() string { if x != nil { return x.Name @@ -304,11 +296,8 @@ type UploadArchiveRequest struct { unknownFields protoimpl.UnknownFields SqlcVersion string `protobuf:"bytes,1,opt,name=sqlc_version,json=sqlcVersion,proto3" json:"sqlc_version,omitempty"` - GoVersion string `protobuf:"bytes,2,opt,name=go_version,json=goVersion,proto3" json:"go_version,omitempty"` - Goos string `protobuf:"bytes,3,opt,name=goos,proto3" json:"goos,omitempty"` - Goarch string `protobuf:"bytes,4,opt,name=goarch,proto3" json:"goarch,omitempty"` - Inputs []*File `protobuf:"bytes,5,rep,name=inputs,proto3" json:"inputs,omitempty"` - Outputs []*File `protobuf:"bytes,6,rep,name=outputs,proto3" json:"outputs,omitempty"` + Inputs []*File `protobuf:"bytes,2,rep,name=inputs,proto3" json:"inputs,omitempty"` + Outputs []*File `protobuf:"bytes,3,rep,name=outputs,proto3" json:"outputs,omitempty"` } func (x *UploadArchiveRequest) Reset() { @@ -350,27 +339,6 @@ func (x *UploadArchiveRequest) GetSqlcVersion() string { return "" } -func (x *UploadArchiveRequest) GetGoVersion() string { - if x != nil { - return x.GoVersion - } - return "" -} - -func (x *UploadArchiveRequest) GetGoos() string { - if x != nil { - return x.Goos - } - return "" -} - -func (x *UploadArchiveRequest) GetGoarch() string { - if x != nil { - return x.Goarch - } - return "" -} - func (x *UploadArchiveRequest) GetInputs() []*File { if x != nil { return x.Inputs @@ -459,58 +427,51 @@ var file_proto_quickdb_v1_quickdb_proto_rawDesc = []byte{ 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x49, 0x64, 0x22, 0x1f, 0x0a, 0x1d, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x55, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x1d, 0x0a, 0x0a, - 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xfa, 0x01, 0x0a, 0x14, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x71, 0x6c, 0x63, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x6f, 0x5f, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x6f, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x67, 0x6f, 0x6f, 0x73, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x67, 0x6f, 0x6f, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x6f, - 0x61, 0x72, 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x6f, 0x61, 0x72, - 0x63, 0x68, 0x12, 0x38, 0x0a, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, - 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, - 0x46, 0x69, 0x6c, 0x65, 0x52, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x07, - 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, - 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, - 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, - 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x22, 0x33, 0x0a, 0x15, 0x55, 0x70, 0x6c, 0x6f, - 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x32, 0xa1, 0x03, - 0x0a, 0x05, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x12, 0x92, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, - 0x61, 0x73, 0x65, 0x12, 0x3a, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, + 0x6f, 0x6e, 0x73, 0x65, 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, 0xaf, 0x01, 0x0a, + 0x14, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x71, 0x6c, + 0x63, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x06, 0x69, 0x6e, 0x70, 0x75, + 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, + 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, + 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x06, 0x69, 0x6e, 0x70, 0x75, + 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, - 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x3b, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, - 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, - 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8c, 0x01, 0x0a, - 0x15, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, - 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x38, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, + 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x22, 0x33, + 0x0a, 0x15, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, + 0x73, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, + 0x73, 0x75, 0x6d, 0x32, 0xa1, 0x03, 0x0a, 0x05, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x12, 0x92, 0x01, + 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, + 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x3a, 0x2e, 0x72, 0x65, 0x6d, 0x6f, + 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, + 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, + 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, + 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, + 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x8c, 0x01, 0x0a, 0x15, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, + 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x38, 0x2e, 0x72, + 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, + 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, + 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, - 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x39, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, - 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, - 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, - 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x74, 0x0a, 0x0d, 0x55, - 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x12, 0x30, 0x2e, 0x72, - 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, - 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, - 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, - 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, - 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, - 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x74, 0x0a, 0x0d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, + 0x76, 0x65, 0x12, 0x30, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, + 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, + 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, + 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, + 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From 35bfa05ab158b6e138af0df51aef263f13a4fdfd Mon Sep 17 00:00:00 2001 From: Kyle Gray Date: Mon, 25 Sep 2023 16:14:57 -0700 Subject: [PATCH 5/7] Update docs/howto/upload.md Co-authored-by: Andrew Benton --- docs/howto/upload.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/howto/upload.md b/docs/howto/upload.md index feb900fbf6..b974252afc 100644 --- a/docs/howto/upload.md +++ b/docs/howto/upload.md @@ -36,7 +36,7 @@ You can see what's included when uploading your project by using using the sqlc upload --dry-run ``` -The output will be request sent by `sqlc`. +The output is the request `sqlc` would have sent without the `--dry-run` flag. ## Upload From 023e9dea93d9b5adabafdded9e7ea4816cec2eb0 Mon Sep 17 00:00:00 2001 From: Kyle Gray Date: Mon, 25 Sep 2023 16:15:04 -0700 Subject: [PATCH 6/7] Update internal/bundler/multipart.go Co-authored-by: Andrew Benton --- internal/bundler/multipart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/bundler/multipart.go b/internal/bundler/multipart.go index 1336c1a559..a3a3975875 100644 --- a/internal/bundler/multipart.go +++ b/internal/bundler/multipart.go @@ -48,7 +48,7 @@ func readOutputs(dir string, output map[string]string) ([]*pb.File, error) { } files = append(files, &pb.File{ Name: rel, - Contents: []byte(contents), + Contents: contents, }) } return files, nil From 41eabf4ab2840f6953acc689b80e7a73e6db2d71 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Mon, 25 Sep 2023 16:17:06 -0700 Subject: [PATCH 7/7] whoops --- internal/bundler/multipart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/bundler/multipart.go b/internal/bundler/multipart.go index a3a3975875..1336c1a559 100644 --- a/internal/bundler/multipart.go +++ b/internal/bundler/multipart.go @@ -48,7 +48,7 @@ func readOutputs(dir string, output map[string]string) ([]*pb.File, error) { } files = append(files, &pb.File{ Name: rel, - Contents: contents, + Contents: []byte(contents), }) } return files, nil