From 57242d56b543f8cc9f8ef91c0fa5913bd175d0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Thu, 15 Feb 2024 09:57:06 +0100 Subject: [PATCH 1/7] Add --region flag --- tdl/main.go | 6 ++++++ trainings/config/global.go | 1 + trainings/configure.go | 11 +++++++++-- trainings/handlers.go | 9 +++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tdl/main.go b/tdl/main.go index 940fcd9..464b5ee 100644 --- a/tdl/main.go +++ b/tdl/main.go @@ -85,6 +85,11 @@ var app = &cli.App{ Usage: "custom server", Hidden: true, }, + &cli.StringFlag{ + Name: "region", + Usage: "the region to use (eu or us)", + Hidden: true, + }, &cli.BoolFlag{ Name: "insecure", Usage: "do not verify certificate", @@ -106,6 +111,7 @@ var app = &cli.App{ c.Context, token, c.String("server"), + c.String("region"), c.Bool("override"), c.Bool("insecure"), ) diff --git a/trainings/config/global.go b/trainings/config/global.go index 8711509..73c6439 100644 --- a/trainings/config/global.go +++ b/trainings/config/global.go @@ -16,6 +16,7 @@ import ( type GlobalConfig struct { Token string `toml:"token"` ServerAddr string `toml:"server_addr"` + Region string `toml:"region"` Insecure bool `toml:"insecure"` } diff --git a/trainings/configure.go b/trainings/configure.go index 713c60d..c016318 100644 --- a/trainings/configure.go +++ b/trainings/configure.go @@ -8,12 +8,18 @@ import ( "github.com/ThreeDotsLabs/cli/trainings/genproto" ) -func (h *Handlers) ConfigureGlobally(ctx context.Context, token, serverAddr string, override, insecure bool) error { +func (h *Handlers) ConfigureGlobally(ctx context.Context, token, serverAddr, region string, override, insecure bool) error { if !override && h.config.ConfiguredGlobally() { return errors.New("trainings are already configured. Please pass --override flag to configure again") } - if _, err := h.newGrpcClientWithAddr(ctx, serverAddr, insecure).Init( + if region != "" { + if region != "eu" && region != "us" { + return errors.New("region can be only eu or us") + } + } + + if _, err := h.newGrpcClientWithAddr(ctx, serverAddr, region, insecure).Init( ctxWithRequestHeader(ctx, h.cliMetadata), &genproto.InitRequest{ Token: token, @@ -25,6 +31,7 @@ func (h *Handlers) ConfigureGlobally(ctx context.Context, token, serverAddr stri return h.config.WriteGlobalConfig(config.GlobalConfig{ Token: token, ServerAddr: serverAddr, + Region: region, Insecure: insecure, }) } diff --git a/trainings/handlers.go b/trainings/handlers.go index 2ab9dcc..5630938 100644 --- a/trainings/handlers.go +++ b/trainings/handlers.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "crypto/x509" + "fmt" "runtime" "github.com/pkg/errors" @@ -47,14 +48,18 @@ func NewHandlers(cliVersion CliMetadata) *Handlers { func (h *Handlers) newGrpcClient(ctx context.Context) genproto.TrainingsClient { globalConfig := h.config.GlobalConfig() - return h.newGrpcClientWithAddr(ctx, globalConfig.ServerAddr, globalConfig.Insecure) + return h.newGrpcClientWithAddr(ctx, globalConfig.ServerAddr, globalConfig.Region, globalConfig.Insecure) } -func (h *Handlers) newGrpcClientWithAddr(ctx context.Context, addr string, insecure bool) genproto.TrainingsClient { +func (h *Handlers) newGrpcClientWithAddr(ctx context.Context, addr string, region string, insecure bool) genproto.TrainingsClient { if addr == "" { addr = internal.DefaultTrainingsServer } + if region != "" { + addr = fmt.Sprintf("%s.%s", region, addr) + } + if h.grpcClient == nil { var opts []grpc.DialOption From 062e743b237669723f055a7a472c2aebab402dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Wed, 21 Feb 2024 20:29:56 +0100 Subject: [PATCH 2/7] Add support for region selection --- README.md | 39 +++ internal/update.go | 42 +++ tdl/main.go | 8 +- trainings/api/protobuf/server.proto | 6 +- trainings/configure.go | 9 +- trainings/genproto/server.pb.go | 412 +++++++++++++++------------ trainings/genproto/server_grpc.pb.go | 40 +-- 7 files changed, 361 insertions(+), 195 deletions(-) create mode 100644 README.md create mode 100644 internal/update.go diff --git a/README.md b/README.md new file mode 100644 index 0000000..8a574fc --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# tdl + +This is the `tdl` CLI tool used for running the interactive trainings on the [Three Dots Labs Academy](https://academy.threedots.tech). + +## Install + +### Script (macOS, Linux) + +```sh +sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/ThreeDotsLabs/cli/master/install.sh)" -- -b /usr/local/bin``` +``` + +### Script (Windows) + +Install to your home directory: + +```sh +iwr https://raw.githubusercontent.com/ThreeDotsLabs/cli/master/install.ps1 -useb | iex +``` + +Or install in any chosen path: + +```sh +$env:TDL_INSTALL = 'bin\' +iwr https://raw.githubusercontent.com/ThreeDotsLabs/cli/master/install.ps1 -useb | iex +``` + +### Binaries + +Download the latest binary from GitHub and move it to a directory in your `$PATH`. + +[See Releases](https://github.com/ThreeDotsLabs/cli/releases) + +### From source + +```sh +go install github.com/ThreeDotsLabs/cli/tdl@latest +``` + diff --git a/internal/update.go b/internal/update.go new file mode 100644 index 0000000..d7a1aa9 --- /dev/null +++ b/internal/update.go @@ -0,0 +1,42 @@ +package internal + +import ( + "encoding/json" + "fmt" + "github.com/fatih/color" + "net/http" +) + +type releaseResponse struct { + TagName string `json:"tag_name"` +} + +const repoURL = "https://github.com/ThreeDotsLabs/cli" +const releasesURL = "https://api.github.com/repos/ThreeDotsLabs/cli/releases/latest" + +func CheckForUpdate(currentVersion string) { + currentVersion = "v0.1.26" + if currentVersion == "" || currentVersion == "dev" { + return + } + + resp, err := http.Get(releasesURL) + if err != nil { + return + } + defer func() { + _ = resp.Body.Close() + }() + + var release releaseResponse + if err := json.NewDecoder(resp.Body).Decode(&release); err != nil { + return + } + + if release.TagName != currentVersion { + c := color.New(color.FgHiYellow) + _, _ = c.Printf("A new version is available: %s (current: %s)\n", release.TagName, currentVersion) + _, _ = c.Printf("Visit %v to update\n", repoURL) + fmt.Println() + } +} diff --git a/tdl/main.go b/tdl/main.go index 464b5ee..4a5b1fd 100644 --- a/tdl/main.go +++ b/tdl/main.go @@ -50,7 +50,10 @@ var app = &cli.App{ return } - fmt.Printf("%+v\n", err) + if err != nil { + fmt.Printf("%+v\n", err) + } + os.Exit(1) }, Flags: []cli.Flag{ @@ -67,6 +70,9 @@ var app = &cli.App{ } else { logrus.SetLevel(logrus.WarnLevel) } + + internal.CheckForUpdate(version) + return nil }, Commands: []*cli.Command{ diff --git a/trainings/api/protobuf/server.proto b/trainings/api/protobuf/server.proto index ac7c8c0..8e05456 100644 --- a/trainings/api/protobuf/server.proto +++ b/trainings/api/protobuf/server.proto @@ -4,7 +4,7 @@ import "google/protobuf/empty.proto"; option go_package = "github.com/ThreeDotsLabs/cli/tdl-cli/trainings/genproto"; service Trainings { - rpc Init(InitRequest) returns (google.protobuf.Empty) {}; + rpc Init(InitRequest) returns (InitResponse) {}; rpc GetTrainings(google.protobuf.Empty) returns (GetTrainingsResponse) {}; rpc StartTraining(StartTrainingRequest) returns (google.protobuf.Empty) {}; @@ -18,6 +18,10 @@ message InitRequest { string token = 1; } +message InitResponse { + string region = 1; +} + message Training { string id = 1; } diff --git a/trainings/configure.go b/trainings/configure.go index c016318..ef7a8ed 100644 --- a/trainings/configure.go +++ b/trainings/configure.go @@ -19,15 +19,20 @@ func (h *Handlers) ConfigureGlobally(ctx context.Context, token, serverAddr, reg } } - if _, err := h.newGrpcClientWithAddr(ctx, serverAddr, region, insecure).Init( + resp, err := h.newGrpcClientWithAddr(ctx, serverAddr, region, insecure).Init( ctxWithRequestHeader(ctx, h.cliMetadata), &genproto.InitRequest{ Token: token, }, - ); err != nil { + ) + if err != nil { return err } + if region == "" { + region = resp.Region + } + return h.config.WriteGlobalConfig(config.GlobalConfig{ Token: token, ServerAddr: serverAddr, diff --git a/trainings/genproto/server.pb.go b/trainings/genproto/server.pb.go index bcc7f49..424bddb 100644 --- a/trainings/genproto/server.pb.go +++ b/trainings/genproto/server.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.32.0 +// protoc v4.25.2 // source: server.proto package genproto @@ -67,7 +67,7 @@ func (x NextExerciseResponse_TrainingStatus) Number() protoreflect.EnumNumber { // Deprecated: Use NextExerciseResponse_TrainingStatus.Descriptor instead. func (NextExerciseResponse_TrainingStatus) EnumDescriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{6, 0} + return file_server_proto_rawDescGZIP(), []int{7, 0} } type InitRequest struct { @@ -117,6 +117,53 @@ func (x *InitRequest) GetToken() string { return "" } +type InitResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Region string `protobuf:"bytes,1,opt,name=region,proto3" json:"region,omitempty"` +} + +func (x *InitResponse) Reset() { + *x = InitResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_server_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InitResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InitResponse) ProtoMessage() {} + +func (x *InitResponse) ProtoReflect() protoreflect.Message { + mi := &file_server_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 InitResponse.ProtoReflect.Descriptor instead. +func (*InitResponse) Descriptor() ([]byte, []int) { + return file_server_proto_rawDescGZIP(), []int{1} +} + +func (x *InitResponse) GetRegion() string { + if x != nil { + return x.Region + } + return "" +} + type Training struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -128,7 +175,7 @@ type Training struct { func (x *Training) Reset() { *x = Training{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[1] + mi := &file_server_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -141,7 +188,7 @@ func (x *Training) String() string { func (*Training) ProtoMessage() {} func (x *Training) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[1] + mi := &file_server_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -154,7 +201,7 @@ func (x *Training) ProtoReflect() protoreflect.Message { // Deprecated: Use Training.ProtoReflect.Descriptor instead. func (*Training) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{1} + return file_server_proto_rawDescGZIP(), []int{2} } func (x *Training) GetId() string { @@ -175,7 +222,7 @@ type GetTrainingsResponse struct { func (x *GetTrainingsResponse) Reset() { *x = GetTrainingsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[2] + mi := &file_server_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -188,7 +235,7 @@ func (x *GetTrainingsResponse) String() string { func (*GetTrainingsResponse) ProtoMessage() {} func (x *GetTrainingsResponse) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[2] + mi := &file_server_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -201,7 +248,7 @@ func (x *GetTrainingsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetTrainingsResponse.ProtoReflect.Descriptor instead. func (*GetTrainingsResponse) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{2} + return file_server_proto_rawDescGZIP(), []int{3} } func (x *GetTrainingsResponse) GetTrainings() []*Training { @@ -223,7 +270,7 @@ type StartTrainingRequest struct { func (x *StartTrainingRequest) Reset() { *x = StartTrainingRequest{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[3] + mi := &file_server_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -236,7 +283,7 @@ func (x *StartTrainingRequest) String() string { func (*StartTrainingRequest) ProtoMessage() {} func (x *StartTrainingRequest) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[3] + mi := &file_server_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -249,7 +296,7 @@ func (x *StartTrainingRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use StartTrainingRequest.ProtoReflect.Descriptor instead. func (*StartTrainingRequest) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{3} + return file_server_proto_rawDescGZIP(), []int{4} } func (x *StartTrainingRequest) GetTrainingName() string { @@ -275,7 +322,7 @@ type StartTrainingResponse struct { func (x *StartTrainingResponse) Reset() { *x = StartTrainingResponse{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[4] + mi := &file_server_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -288,7 +335,7 @@ func (x *StartTrainingResponse) String() string { func (*StartTrainingResponse) ProtoMessage() {} func (x *StartTrainingResponse) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[4] + mi := &file_server_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -301,7 +348,7 @@ func (x *StartTrainingResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StartTrainingResponse.ProtoReflect.Descriptor instead. func (*StartTrainingResponse) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{4} + return file_server_proto_rawDescGZIP(), []int{5} } type NextExerciseRequest struct { @@ -317,7 +364,7 @@ type NextExerciseRequest struct { func (x *NextExerciseRequest) Reset() { *x = NextExerciseRequest{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[5] + mi := &file_server_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -330,7 +377,7 @@ func (x *NextExerciseRequest) String() string { func (*NextExerciseRequest) ProtoMessage() {} func (x *NextExerciseRequest) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[5] + mi := &file_server_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -343,7 +390,7 @@ func (x *NextExerciseRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use NextExerciseRequest.ProtoReflect.Descriptor instead. func (*NextExerciseRequest) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{5} + return file_server_proto_rawDescGZIP(), []int{6} } func (x *NextExerciseRequest) GetTrainingName() string { @@ -382,7 +429,7 @@ type NextExerciseResponse struct { func (x *NextExerciseResponse) Reset() { *x = NextExerciseResponse{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[6] + mi := &file_server_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -395,7 +442,7 @@ func (x *NextExerciseResponse) String() string { func (*NextExerciseResponse) ProtoMessage() {} func (x *NextExerciseResponse) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[6] + mi := &file_server_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -408,7 +455,7 @@ func (x *NextExerciseResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use NextExerciseResponse.ProtoReflect.Descriptor instead. func (*NextExerciseResponse) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{6} + return file_server_proto_rawDescGZIP(), []int{7} } func (x *NextExerciseResponse) GetTrainingStatus() NextExerciseResponse_TrainingStatus { @@ -458,7 +505,7 @@ type NextExercise struct { func (x *NextExercise) Reset() { *x = NextExercise{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[7] + mi := &file_server_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -471,7 +518,7 @@ func (x *NextExercise) String() string { func (*NextExercise) ProtoMessage() {} func (x *NextExercise) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[7] + mi := &file_server_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -484,7 +531,7 @@ func (x *NextExercise) ProtoReflect() protoreflect.Message { // Deprecated: Use NextExercise.ProtoReflect.Descriptor instead. func (*NextExercise) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{7} + return file_server_proto_rawDescGZIP(), []int{8} } func (x *NextExercise) GetDir() string { @@ -514,7 +561,7 @@ type VerifyExerciseRequest struct { func (x *VerifyExerciseRequest) Reset() { *x = VerifyExerciseRequest{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[8] + mi := &file_server_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -527,7 +574,7 @@ func (x *VerifyExerciseRequest) String() string { func (*VerifyExerciseRequest) ProtoMessage() {} func (x *VerifyExerciseRequest) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[8] + mi := &file_server_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -540,7 +587,7 @@ func (x *VerifyExerciseRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyExerciseRequest.ProtoReflect.Descriptor instead. func (*VerifyExerciseRequest) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{8} + return file_server_proto_rawDescGZIP(), []int{9} } func (x *VerifyExerciseRequest) GetExerciseId() string { @@ -576,7 +623,7 @@ type File struct { func (x *File) Reset() { *x = File{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[9] + mi := &file_server_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -589,7 +636,7 @@ func (x *File) String() string { func (*File) ProtoMessage() {} func (x *File) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[9] + mi := &file_server_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -602,7 +649,7 @@ func (x *File) ProtoReflect() protoreflect.Message { // Deprecated: Use File.ProtoReflect.Descriptor instead. func (*File) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{9} + return file_server_proto_rawDescGZIP(), []int{10} } func (x *File) GetPath() string { @@ -638,7 +685,7 @@ type VerifyExerciseResponse struct { func (x *VerifyExerciseResponse) Reset() { *x = VerifyExerciseResponse{} if protoimpl.UnsafeEnabled { - mi := &file_server_proto_msgTypes[10] + mi := &file_server_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -651,7 +698,7 @@ func (x *VerifyExerciseResponse) String() string { func (*VerifyExerciseResponse) ProtoMessage() {} func (x *VerifyExerciseResponse) ProtoReflect() protoreflect.Message { - mi := &file_server_proto_msgTypes[10] + mi := &file_server_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -664,7 +711,7 @@ func (x *VerifyExerciseResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyExerciseResponse.ProtoReflect.Descriptor instead. func (*VerifyExerciseResponse) Descriptor() ([]byte, []int) { - return file_server_proto_rawDescGZIP(), []int{10} + return file_server_proto_rawDescGZIP(), []int{11} } func (x *VerifyExerciseResponse) GetFinished() bool { @@ -738,112 +785,114 @@ var file_server_proto_rawDesc = []byte{ 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x23, 0x0a, 0x0b, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x22, 0x1a, 0x0a, 0x08, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x3f, 0x0a, 0x14, - 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, - 0x6e, 0x67, 0x52, 0x09, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x51, 0x0a, - 0x14, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, - 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x72, - 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x22, 0x17, 0x0a, 0x15, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x80, 0x01, 0x0a, 0x13, 0x4e, 0x65, - 0x78, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, - 0x6e, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x5f, 0x65, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x11, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, 0x78, 0x65, 0x72, - 0x63, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xb0, 0x02, 0x0a, - 0x14, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x0f, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, - 0x67, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, - 0x2e, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x0e, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x64, 0x69, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x78, 0x65, 0x72, 0x63, 0x69, - 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x65, - 0x72, 0x63, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x2d, 0x0a, 0x0f, 0x66, 0x69, 0x6c, 0x65, 0x73, - 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x05, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x54, 0x6f, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x74, 0x65, 0x78, - 0x74, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, - 0x54, 0x65, 0x78, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0x45, 0x0a, 0x0e, 0x54, 0x72, 0x61, 0x69, - 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0f, 0x0a, 0x0b, 0x49, 0x4e, - 0x5f, 0x50, 0x52, 0x4f, 0x47, 0x52, 0x45, 0x53, 0x53, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x50, - 0x41, 0x59, 0x4d, 0x45, 0x4e, 0x54, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x49, 0x52, 0x45, 0x44, 0x10, - 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x48, 0x45, 0x44, 0x10, 0x02, 0x22, - 0x4f, 0x0a, 0x0c, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x12, - 0x10, 0x0a, 0x03, 0x64, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x69, - 0x72, 0x12, 0x2d, 0x0a, 0x0f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x46, 0x69, 0x6c, - 0x65, 0x52, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x54, 0x6f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x22, 0x6b, 0x0a, 0x15, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, - 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x78, 0x65, - 0x72, 0x63, 0x69, 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x65, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x05, 0x66, 0x69, - 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x46, 0x69, 0x6c, 0x65, - 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x34, 0x0a, - 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x74, 0x22, 0x9b, 0x03, 0x0a, 0x16, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x78, - 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, - 0x63, 0x63, 0x65, 0x73, 0x73, 0x66, 0x75, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, - 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x66, 0x75, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, - 0x73, 0x74, 0x64, 0x65, 0x72, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, - 0x64, 0x65, 0x72, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x65, - 0x72, 0x63, 0x69, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6c, 0x61, 0x73, - 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x73, 0x6f, 0x6c, - 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x41, - 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x76, 0x65, 0x72, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, - 0x64, 0x12, 0x41, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, - 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x32, 0xc4, 0x02, 0x0a, 0x09, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x12, - 0x2e, 0x0a, 0x04, 0x49, 0x6e, 0x69, 0x74, 0x12, 0x0c, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, - 0x3f, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x12, - 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x15, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, - 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x40, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, - 0x67, 0x12, 0x15, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x0c, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, - 0x73, 0x65, 0x12, 0x14, 0x2e, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x4e, 0x65, 0x78, 0x74, 0x45, - 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x45, 0x0a, 0x0e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, 0x63, - 0x69, 0x73, 0x65, 0x12, 0x16, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, - 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x56, 0x65, + 0x22, 0x26, 0x0a, 0x0c, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x22, 0x1a, 0x0a, 0x08, 0x54, 0x72, 0x61, 0x69, + 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x22, 0x3f, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, + 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x09, + 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x09, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x74, 0x72, 0x61, 0x69, + 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x51, 0x0a, 0x14, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x72, + 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, + 0x0d, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x17, 0x0a, 0x15, 0x53, 0x74, 0x61, 0x72, + 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x80, 0x01, 0x0a, 0x13, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, + 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x72, 0x61, + 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0c, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2e, + 0x0a, 0x13, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x78, 0x65, 0x72, 0x63, 0x69, + 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x14, + 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xb0, 0x02, 0x0a, 0x14, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, + 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, + 0x0f, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, + 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x54, 0x72, + 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0e, 0x74, 0x72, + 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x03, + 0x64, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x69, 0x72, 0x12, 0x1f, + 0x0a, 0x0b, 0x65, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, + 0x2d, 0x0a, 0x0f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, + 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x54, 0x6f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x20, + 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x54, 0x65, 0x78, 0x74, 0x4f, 0x6e, 0x6c, 0x79, + 0x22, 0x45, 0x0a, 0x0e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x0f, 0x0a, 0x0b, 0x49, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x47, 0x52, 0x45, 0x53, + 0x53, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x50, 0x41, 0x59, 0x4d, 0x45, 0x4e, 0x54, 0x5f, 0x52, + 0x45, 0x51, 0x55, 0x49, 0x52, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x49, 0x4e, + 0x49, 0x53, 0x48, 0x45, 0x44, 0x10, 0x02, 0x22, 0x4f, 0x0a, 0x0c, 0x4e, 0x65, 0x78, 0x74, 0x45, + 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x69, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x69, 0x72, 0x12, 0x2d, 0x0a, 0x0f, 0x66, 0x69, 0x6c, + 0x65, 0x73, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x73, + 0x54, 0x6f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x22, 0x6b, 0x0a, 0x15, 0x56, 0x65, 0x72, 0x69, + 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, + 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x05, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x12, + 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x34, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x9b, 0x03, 0x0a, 0x16, + 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, + 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, + 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x66, 0x75, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x66, + 0x75, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, + 0x64, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x64, 0x65, 0x72, 0x72, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x64, 0x65, 0x72, 0x72, 0x12, 0x23, 0x0a, 0x0d, + 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, + 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x76, + 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x73, + 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, + 0x12, 0x27, 0x0a, 0x0f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x76, 0x65, 0x72, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x41, 0x0a, 0x08, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0x39, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x68, 0x72, 0x65, 0x65, 0x44, 0x6f, 0x74, 0x73, - 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x74, 0x64, 0x6c, 0x2d, 0x63, 0x6c, 0x69, - 0x2f, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, 0x0d, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0xbb, 0x02, 0x0a, 0x09, 0x54, 0x72, + 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x25, 0x0a, 0x04, 0x49, 0x6e, 0x69, 0x74, 0x12, + 0x0c, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, + 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3f, + 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x15, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, + 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x40, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, + 0x12, 0x15, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, + 0x00, 0x12, 0x3d, 0x0a, 0x0c, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, + 0x65, 0x12, 0x14, 0x2e, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x4e, 0x65, 0x78, 0x74, 0x45, 0x78, + 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x45, 0x0a, 0x0e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, + 0x73, 0x65, 0x12, 0x16, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, 0x63, + 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x56, 0x65, 0x72, + 0x69, 0x66, 0x79, 0x45, 0x78, 0x65, 0x72, 0x63, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0x39, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x68, 0x72, 0x65, 0x65, 0x44, 0x6f, 0x74, 0x73, 0x4c, + 0x61, 0x62, 0x73, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x74, 0x64, 0x6c, 0x2d, 0x63, 0x6c, 0x69, 0x2f, + 0x74, 0x72, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -859,40 +908,41 @@ func file_server_proto_rawDescGZIP() []byte { } var file_server_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_server_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_server_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_server_proto_goTypes = []interface{}{ (NextExerciseResponse_TrainingStatus)(0), // 0: NextExerciseResponse.TrainingStatus (*InitRequest)(nil), // 1: InitRequest - (*Training)(nil), // 2: Training - (*GetTrainingsResponse)(nil), // 3: GetTrainingsResponse - (*StartTrainingRequest)(nil), // 4: StartTrainingRequest - (*StartTrainingResponse)(nil), // 5: StartTrainingResponse - (*NextExerciseRequest)(nil), // 6: NextExerciseRequest - (*NextExerciseResponse)(nil), // 7: NextExerciseResponse - (*NextExercise)(nil), // 8: NextExercise - (*VerifyExerciseRequest)(nil), // 9: VerifyExerciseRequest - (*File)(nil), // 10: File - (*VerifyExerciseResponse)(nil), // 11: VerifyExerciseResponse - nil, // 12: VerifyExerciseResponse.MetadataEntry - (*emptypb.Empty)(nil), // 13: google.protobuf.Empty + (*InitResponse)(nil), // 2: InitResponse + (*Training)(nil), // 3: Training + (*GetTrainingsResponse)(nil), // 4: GetTrainingsResponse + (*StartTrainingRequest)(nil), // 5: StartTrainingRequest + (*StartTrainingResponse)(nil), // 6: StartTrainingResponse + (*NextExerciseRequest)(nil), // 7: NextExerciseRequest + (*NextExerciseResponse)(nil), // 8: NextExerciseResponse + (*NextExercise)(nil), // 9: NextExercise + (*VerifyExerciseRequest)(nil), // 10: VerifyExerciseRequest + (*File)(nil), // 11: File + (*VerifyExerciseResponse)(nil), // 12: VerifyExerciseResponse + nil, // 13: VerifyExerciseResponse.MetadataEntry + (*emptypb.Empty)(nil), // 14: google.protobuf.Empty } var file_server_proto_depIdxs = []int32{ - 2, // 0: GetTrainingsResponse.trainings:type_name -> Training + 3, // 0: GetTrainingsResponse.trainings:type_name -> Training 0, // 1: NextExerciseResponse.training_status:type_name -> NextExerciseResponse.TrainingStatus - 10, // 2: NextExerciseResponse.files_to_create:type_name -> File - 10, // 3: NextExercise.files_to_create:type_name -> File - 10, // 4: VerifyExerciseRequest.files:type_name -> File - 12, // 5: VerifyExerciseResponse.metadata:type_name -> VerifyExerciseResponse.MetadataEntry + 11, // 2: NextExerciseResponse.files_to_create:type_name -> File + 11, // 3: NextExercise.files_to_create:type_name -> File + 11, // 4: VerifyExerciseRequest.files:type_name -> File + 13, // 5: VerifyExerciseResponse.metadata:type_name -> VerifyExerciseResponse.MetadataEntry 1, // 6: Trainings.Init:input_type -> InitRequest - 13, // 7: Trainings.GetTrainings:input_type -> google.protobuf.Empty - 4, // 8: Trainings.StartTraining:input_type -> StartTrainingRequest - 6, // 9: Trainings.NextExercise:input_type -> NextExerciseRequest - 9, // 10: Trainings.VerifyExercise:input_type -> VerifyExerciseRequest - 13, // 11: Trainings.Init:output_type -> google.protobuf.Empty - 3, // 12: Trainings.GetTrainings:output_type -> GetTrainingsResponse - 13, // 13: Trainings.StartTraining:output_type -> google.protobuf.Empty - 7, // 14: Trainings.NextExercise:output_type -> NextExerciseResponse - 11, // 15: Trainings.VerifyExercise:output_type -> VerifyExerciseResponse + 14, // 7: Trainings.GetTrainings:input_type -> google.protobuf.Empty + 5, // 8: Trainings.StartTraining:input_type -> StartTrainingRequest + 7, // 9: Trainings.NextExercise:input_type -> NextExerciseRequest + 10, // 10: Trainings.VerifyExercise:input_type -> VerifyExerciseRequest + 2, // 11: Trainings.Init:output_type -> InitResponse + 4, // 12: Trainings.GetTrainings:output_type -> GetTrainingsResponse + 14, // 13: Trainings.StartTraining:output_type -> google.protobuf.Empty + 8, // 14: Trainings.NextExercise:output_type -> NextExerciseResponse + 12, // 15: Trainings.VerifyExercise:output_type -> VerifyExerciseResponse 11, // [11:16] is the sub-list for method output_type 6, // [6:11] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name @@ -919,7 +969,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Training); i { + switch v := v.(*InitResponse); i { case 0: return &v.state case 1: @@ -931,7 +981,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetTrainingsResponse); i { + switch v := v.(*Training); i { case 0: return &v.state case 1: @@ -943,7 +993,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StartTrainingRequest); i { + switch v := v.(*GetTrainingsResponse); i { case 0: return &v.state case 1: @@ -955,7 +1005,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StartTrainingResponse); i { + switch v := v.(*StartTrainingRequest); i { case 0: return &v.state case 1: @@ -967,7 +1017,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NextExerciseRequest); i { + switch v := v.(*StartTrainingResponse); i { case 0: return &v.state case 1: @@ -979,7 +1029,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NextExerciseResponse); i { + switch v := v.(*NextExerciseRequest); i { case 0: return &v.state case 1: @@ -991,7 +1041,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NextExercise); i { + switch v := v.(*NextExerciseResponse); i { case 0: return &v.state case 1: @@ -1003,7 +1053,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VerifyExerciseRequest); i { + switch v := v.(*NextExercise); i { case 0: return &v.state case 1: @@ -1015,7 +1065,7 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*File); i { + switch v := v.(*VerifyExerciseRequest); i { case 0: return &v.state case 1: @@ -1027,6 +1077,18 @@ func file_server_proto_init() { } } file_server_proto_msgTypes[10].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_server_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*VerifyExerciseResponse); i { case 0: return &v.state @@ -1045,7 +1107,7 @@ func file_server_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_server_proto_rawDesc, NumEnums: 1, - NumMessages: 12, + NumMessages: 13, NumExtensions: 0, NumServices: 1, }, diff --git a/trainings/genproto/server_grpc.pb.go b/trainings/genproto/server_grpc.pb.go index 2f6b770..fec23f3 100644 --- a/trainings/genproto/server_grpc.pb.go +++ b/trainings/genproto/server_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.25.2 // source: server.proto package genproto @@ -19,11 +19,19 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + Trainings_Init_FullMethodName = "/Trainings/Init" + Trainings_GetTrainings_FullMethodName = "/Trainings/GetTrainings" + Trainings_StartTraining_FullMethodName = "/Trainings/StartTraining" + Trainings_NextExercise_FullMethodName = "/Trainings/NextExercise" + Trainings_VerifyExercise_FullMethodName = "/Trainings/VerifyExercise" +) + // TrainingsClient is the client API for Trainings service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type TrainingsClient interface { - Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*InitResponse, error) GetTrainings(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*GetTrainingsResponse, error) StartTraining(ctx context.Context, in *StartTrainingRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) NextExercise(ctx context.Context, in *NextExerciseRequest, opts ...grpc.CallOption) (*NextExerciseResponse, error) @@ -38,9 +46,9 @@ func NewTrainingsClient(cc grpc.ClientConnInterface) TrainingsClient { return &trainingsClient{cc} } -func (c *trainingsClient) Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/Trainings/Init", in, out, opts...) +func (c *trainingsClient) Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*InitResponse, error) { + out := new(InitResponse) + err := c.cc.Invoke(ctx, Trainings_Init_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -49,7 +57,7 @@ func (c *trainingsClient) Init(ctx context.Context, in *InitRequest, opts ...grp func (c *trainingsClient) GetTrainings(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*GetTrainingsResponse, error) { out := new(GetTrainingsResponse) - err := c.cc.Invoke(ctx, "/Trainings/GetTrainings", in, out, opts...) + err := c.cc.Invoke(ctx, Trainings_GetTrainings_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -58,7 +66,7 @@ func (c *trainingsClient) GetTrainings(ctx context.Context, in *emptypb.Empty, o func (c *trainingsClient) StartTraining(ctx context.Context, in *StartTrainingRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/Trainings/StartTraining", in, out, opts...) + err := c.cc.Invoke(ctx, Trainings_StartTraining_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -67,7 +75,7 @@ func (c *trainingsClient) StartTraining(ctx context.Context, in *StartTrainingRe func (c *trainingsClient) NextExercise(ctx context.Context, in *NextExerciseRequest, opts ...grpc.CallOption) (*NextExerciseResponse, error) { out := new(NextExerciseResponse) - err := c.cc.Invoke(ctx, "/Trainings/NextExercise", in, out, opts...) + err := c.cc.Invoke(ctx, Trainings_NextExercise_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -75,7 +83,7 @@ func (c *trainingsClient) NextExercise(ctx context.Context, in *NextExerciseRequ } func (c *trainingsClient) VerifyExercise(ctx context.Context, in *VerifyExerciseRequest, opts ...grpc.CallOption) (Trainings_VerifyExerciseClient, error) { - stream, err := c.cc.NewStream(ctx, &Trainings_ServiceDesc.Streams[0], "/Trainings/VerifyExercise", opts...) + stream, err := c.cc.NewStream(ctx, &Trainings_ServiceDesc.Streams[0], Trainings_VerifyExercise_FullMethodName, opts...) if err != nil { return nil, err } @@ -110,7 +118,7 @@ func (x *trainingsVerifyExerciseClient) Recv() (*VerifyExerciseResponse, error) // All implementations should embed UnimplementedTrainingsServer // for forward compatibility type TrainingsServer interface { - Init(context.Context, *InitRequest) (*emptypb.Empty, error) + Init(context.Context, *InitRequest) (*InitResponse, error) GetTrainings(context.Context, *emptypb.Empty) (*GetTrainingsResponse, error) StartTraining(context.Context, *StartTrainingRequest) (*emptypb.Empty, error) NextExercise(context.Context, *NextExerciseRequest) (*NextExerciseResponse, error) @@ -121,7 +129,7 @@ type TrainingsServer interface { type UnimplementedTrainingsServer struct { } -func (UnimplementedTrainingsServer) Init(context.Context, *InitRequest) (*emptypb.Empty, error) { +func (UnimplementedTrainingsServer) Init(context.Context, *InitRequest) (*InitResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Init not implemented") } func (UnimplementedTrainingsServer) GetTrainings(context.Context, *emptypb.Empty) (*GetTrainingsResponse, error) { @@ -158,7 +166,7 @@ func _Trainings_Init_Handler(srv interface{}, ctx context.Context, dec func(inte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/Trainings/Init", + FullMethod: Trainings_Init_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TrainingsServer).Init(ctx, req.(*InitRequest)) @@ -176,7 +184,7 @@ func _Trainings_GetTrainings_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/Trainings/GetTrainings", + FullMethod: Trainings_GetTrainings_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TrainingsServer).GetTrainings(ctx, req.(*emptypb.Empty)) @@ -194,7 +202,7 @@ func _Trainings_StartTraining_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/Trainings/StartTraining", + FullMethod: Trainings_StartTraining_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TrainingsServer).StartTraining(ctx, req.(*StartTrainingRequest)) @@ -212,7 +220,7 @@ func _Trainings_NextExercise_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/Trainings/NextExercise", + FullMethod: Trainings_NextExercise_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TrainingsServer).NextExercise(ctx, req.(*NextExerciseRequest)) From 097027c9d065c4be81c11cfe2c6ac526a56026c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Wed, 21 Feb 2024 20:30:48 +0100 Subject: [PATCH 3/7] Remove debug --- internal/update.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/update.go b/internal/update.go index d7a1aa9..799d27e 100644 --- a/internal/update.go +++ b/internal/update.go @@ -15,7 +15,6 @@ const repoURL = "https://github.com/ThreeDotsLabs/cli" const releasesURL = "https://api.github.com/repos/ThreeDotsLabs/cli/releases/latest" func CheckForUpdate(currentVersion string) { - currentVersion = "v0.1.26" if currentVersion == "" || currentVersion == "dev" { return } From a214c00ccf093adf58adb6ac6095956b12627df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Wed, 21 Feb 2024 20:33:04 +0100 Subject: [PATCH 4/7] Cosmetics --- tdl/main.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tdl/main.go b/tdl/main.go index 4a5b1fd..ef881d6 100644 --- a/tdl/main.go +++ b/tdl/main.go @@ -91,16 +91,15 @@ var app = &cli.App{ Usage: "custom server", Hidden: true, }, - &cli.StringFlag{ - Name: "region", - Usage: "the region to use (eu or us)", - Hidden: true, - }, &cli.BoolFlag{ Name: "insecure", Usage: "do not verify certificate", Hidden: true, }, + &cli.StringFlag{ + Name: "region", + Usage: "the region to use (eu or us)", + }, &cli.BoolFlag{ Name: "override", Usage: "if config already exists, it will be overridden", From 0113a7b8840d935defd08b73a28284d525e416ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Wed, 21 Feb 2024 20:53:51 +0100 Subject: [PATCH 5/7] Update README.md Co-authored-by: Robert Laszczak --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a574fc..59f540c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This is the `tdl` CLI tool used for running the interactive trainings on the [Th ## Install -### Script (macOS, Linux) +### Script (macOS, Linux) - recommended ```sh sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/ThreeDotsLabs/cli/master/install.sh)" -- -b /usr/local/bin``` From 317b8f8cc420ce87acfcfb709dbbc880f3d81678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Wed, 21 Feb 2024 20:54:05 +0100 Subject: [PATCH 6/7] Update README.md Co-authored-by: Robert Laszczak --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59f540c..8d1b0c1 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is the `tdl` CLI tool used for running the interactive trainings on the [Th ### Script (macOS, Linux) - recommended ```sh -sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/ThreeDotsLabs/cli/master/install.sh)" -- -b /usr/local/bin``` +sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/ThreeDotsLabs/cli/master/install.sh)" -- -b /usr/local/bin ``` ### Script (Windows) From 1a21eae4dbb4ba2d8d52bd2e69a3599d65598acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Wed, 21 Feb 2024 21:10:44 +0100 Subject: [PATCH 7/7] Timeouts + check once per day --- internal/config.go | 15 ++++++++++ internal/update.go | 59 +++++++++++++++++++++++++++++++++++++- trainings/config/global.go | 11 +------ 3 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 internal/config.go diff --git a/internal/config.go b/internal/config.go new file mode 100644 index 0000000..98ffa06 --- /dev/null +++ b/internal/config.go @@ -0,0 +1,15 @@ +package internal + +import ( + "os" + "path/filepath" +) + +func GlobalConfigDir() string { + userConfigDir, err := os.UserConfigDir() + if err != nil { + panic(err) + } + + return filepath.Join(userConfigDir, "three-dots-labs") +} diff --git a/internal/update.go b/internal/update.go index 799d27e..8ece012 100644 --- a/internal/update.go +++ b/internal/update.go @@ -1,10 +1,14 @@ package internal import ( + "context" "encoding/json" "fmt" "github.com/fatih/color" "net/http" + "os" + "path" + "time" ) type releaseResponse struct { @@ -19,7 +23,25 @@ func CheckForUpdate(currentVersion string) { return } - resp, err := http.Get(releasesURL) + lastUpdate, _ := LastUpdateCheckTime() + + if time.Since(lastUpdate) < 24*time.Hour { + return + } + + defer func() { + _ = StoreUpdateCheckTime(time.Now().UTC()) + }() + + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + + req, err := http.NewRequestWithContext(ctx, http.MethodGet, releasesURL, nil) + if err != nil { + return + } + + resp, err := http.DefaultClient.Do(req) if err != nil { return } @@ -39,3 +61,38 @@ func CheckForUpdate(currentVersion string) { fmt.Println() } } + +func lastUpdateCheckPath() string { + return path.Join(GlobalConfigDir(), "last-update-check") +} + +func LastUpdateCheckTime() (time.Time, error) { + if !fileExists(lastUpdateCheckPath()) { + return time.Time{}, nil + } + + content, err := os.ReadFile(lastUpdateCheckPath()) + if err != nil { + return time.Time{}, err + } + + t, err := time.Parse(time.RFC3339, string(content)) + if err != nil { + return time.Time{}, err + } + + return t, nil +} + +func StoreUpdateCheckTime(t time.Time) error { + return os.WriteFile(lastUpdateCheckPath(), []byte(t.Format(time.RFC3339)), 0644) +} + +func fileExists(path string) bool { + _, err := os.Stat(path) + if err == nil { + return true + } + + return false +} diff --git a/trainings/config/global.go b/trainings/config/global.go index 73c6439..5119ab8 100644 --- a/trainings/config/global.go +++ b/trainings/config/global.go @@ -2,7 +2,6 @@ package config import ( "fmt" - "os" "path/filepath" "strings" @@ -21,15 +20,7 @@ type GlobalConfig struct { } func globalConfigPath() string { - userConfigDir, err := os.UserConfigDir() - if err != nil { - panic(err) - } - - configDir := filepath.Join(userConfigDir, "three-dots-labs") - configPath := filepath.Join(configDir, ".trainings-config") - - return configPath + return filepath.Join(internal.GlobalConfigDir(), ".trainings-config") } func (c Config) ConfiguredGlobally() bool {