From a29518905fbc57b532d5d313e769f73da5fe26dc Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Tue, 9 Dec 2025 18:16:27 +0100 Subject: [PATCH 1/7] Add daemon command and gRPC list support --- Taskfile.yml | 16 + buf.gen.yaml | 14 + cmd/arduino-flasher-cli/daemon/daemon.go | 124 +++++++ cmd/arduino-flasher-cli/main.go | 5 + commands/service.go | 26 ++ commands/service_list.go | 40 +++ go.mod | 13 +- go.sum | 46 ++- .../flasher/cli/commands/v1/commands.pb.go | 304 ++++++++++++++++++ .../flasher/cli/commands/v1/commands.proto | 35 ++ .../cli/commands/v1/commands_grpc.pb.go | 136 ++++++++ 11 files changed, 744 insertions(+), 15 deletions(-) create mode 100644 buf.gen.yaml create mode 100644 cmd/arduino-flasher-cli/daemon/daemon.go create mode 100644 commands/service.go create mode 100644 commands/service_list.go create mode 100644 rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go create mode 100644 rpc/cc/arduino/flasher/cli/commands/v1/commands.proto create mode 100644 rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go diff --git a/Taskfile.yml b/Taskfile.yml index 40dd5b9..97c57c2 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -126,3 +126,19 @@ tasks: general:prepare-deps: desc: Prepare project dependencies for license check # No preparation is needed for Go module-based projects. + + protoc:compile: + desc: Compile protobuf definitions + cmds: + - buf dep update + - buf generate + + protoc:check: + desc: Perform linting of the protobuf definitions + cmds: + - buf lint + + protoc:format: + desc: Perform formatting of the protobuf definitions + cmds: + - buf format --write diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 0000000..555b1dd --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,14 @@ +version: v2 +plugins: + # Use protoc-gen-go + - remote: buf.build/protocolbuffers/go:v1.34.2 + out: ./rpc + opt: + - paths=source_relative + # Use of protoc-gen-go-grpc + - remote: buf.build/grpc/go:v1.5.1 + out: ./rpc + opt: + - paths=source_relative +inputs: + - directory: ./rpc diff --git a/cmd/arduino-flasher-cli/daemon/daemon.go b/cmd/arduino-flasher-cli/daemon/daemon.go new file mode 100644 index 0000000..b3669a7 --- /dev/null +++ b/cmd/arduino-flasher-cli/daemon/daemon.go @@ -0,0 +1,124 @@ +// This file is part of arduino-flasher-cli. +// +// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-flasher-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package daemon + +import ( + "encoding/json" + "errors" + "fmt" + "net" + "os" + "strings" + "syscall" + + "github.com/arduino/arduino-flasher-cli/cmd/feedback" + "github.com/arduino/arduino-flasher-cli/cmd/i18n" + "github.com/spf13/cobra" + "google.golang.org/grpc" + + rpc "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1" +) + +func NewDaemonCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command { + var daemonPort string + var maxGRPCRecvMsgSize int + daemonCommand := &cobra.Command{ + Use: "daemon", + Short: i18n.Tr("Run the Arduino Flasher CLI as a gRPC daemon."), + Example: " " + os.Args[0] + " daemon", + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + runDaemonCommand(srv, daemonPort, maxGRPCRecvMsgSize) + }, + } + + daemonCommand.Flags().StringVar(&daemonPort, + "port", "50051", + i18n.Tr("The TCP port the daemon will listen to")) + + daemonCommand.Flags().IntVar(&maxGRPCRecvMsgSize, + "max-grpc-recv-message-size", 16*1024*1024, + i18n.Tr("Sets the maximum message size in bytes the daemon can receive")) + + return daemonCommand +} + +func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort string, maxGRPCRecvMsgSize int) { + gRPCOptions := []grpc.ServerOption{} + gRPCOptions = append(gRPCOptions, grpc.MaxRecvMsgSize(maxGRPCRecvMsgSize)) + s := grpc.NewServer(gRPCOptions...) + + // register the commands service + rpc.RegisterArduinoCoreServiceServer(s, srv) + + daemonIP := "127.0.0.1" + lis, err := net.Listen("tcp", fmt.Sprintf("%s:%s", daemonIP, daemonPort)) + if err != nil { + // Invalid port, such as "Foo" + var dnsError *net.DNSError + if errors.As(err, &dnsError) { + feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %[1]s. %[2]s is unknown name.", daemonPort, dnsError.Name), feedback.ErrBadTCPPortArgument) + } + // Invalid port number, such as -1 + var addrError *net.AddrError + if errors.As(err, &addrError) { + feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %[1]s. %[2]s is an invalid port.", daemonPort, addrError.Addr), feedback.ErrBadTCPPortArgument) + } + // Port is already in use + var syscallErr *os.SyscallError + if errors.As(err, &syscallErr) && errors.Is(syscallErr.Err, syscall.EADDRINUSE) { + feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %s. Address already in use.", daemonPort), feedback.ErrFailedToListenToTCPPort) + } + feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %[1]s. Unexpected error: %[2]v", daemonPort, err), feedback.ErrFailedToListenToTCPPort) + } + + // We need to retrieve the port used only if the user did not specify it + // and let the OS choose it randomly, in all other cases we already know + // which port is used. + if daemonPort == "0" { + address := lis.Addr() + split := strings.Split(address.String(), ":") + + if len(split) <= 1 { + feedback.Fatal(i18n.Tr("Invalid TCP address: port is missing"), feedback.ErrBadTCPPortArgument) + } + + daemonPort = split[1] + } + + feedback.PrintResult(daemonResult{ + IP: daemonIP, + Port: daemonPort, + }) + + if err := s.Serve(lis); err != nil { + feedback.Fatal(fmt.Sprintf("Failed to serve: %v", err), feedback.ErrFailedToListenToTCPPort) + } +} + +type daemonResult struct { + IP string + Port string +} + +func (r daemonResult) Data() interface{} { + return r +} + +func (r daemonResult) String() string { + j, _ := json.Marshal(r) + return fmt.Sprintln(i18n.Tr("Daemon is now listening on %s:%s", r.IP, r.Port)) + fmt.Sprintln(string(j)) +} diff --git a/cmd/arduino-flasher-cli/main.go b/cmd/arduino-flasher-cli/main.go index d783968..43045fc 100644 --- a/cmd/arduino-flasher-cli/main.go +++ b/cmd/arduino-flasher-cli/main.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "go.bug.st/cleanup" + "github.com/arduino/arduino-flasher-cli/cmd/arduino-flasher-cli/daemon" "github.com/arduino/arduino-flasher-cli/cmd/arduino-flasher-cli/download" "github.com/arduino/arduino-flasher-cli/cmd/arduino-flasher-cli/drivers" "github.com/arduino/arduino-flasher-cli/cmd/arduino-flasher-cli/flash" @@ -30,6 +31,7 @@ import ( "github.com/arduino/arduino-flasher-cli/cmd/arduino-flasher-cli/version" "github.com/arduino/arduino-flasher-cli/cmd/feedback" "github.com/arduino/arduino-flasher-cli/cmd/i18n" + "github.com/arduino/arduino-flasher-cli/commands" ) // Version will be set a build time with -ldflags @@ -37,6 +39,8 @@ var Version string = "0.0.0-dev" var format string func main() { + srv := commands.NewArduinoCoreServer() + rootCmd := &cobra.Command{ Use: "arduino-flasher-cli", Short: "A CLI to update your Arduino UNO Q board, by downloading and flashing the latest Arduino Linux image", @@ -61,6 +65,7 @@ func main() { list.NewListCmd(), download.NewDownloadCmd(), version.NewVersionCmd(Version), + daemon.NewDaemonCommand(srv), ) ctx := context.Background() diff --git a/commands/service.go b/commands/service.go new file mode 100644 index 0000000..7a9ca4a --- /dev/null +++ b/commands/service.go @@ -0,0 +1,26 @@ +// This file is part of arduino-flasher-cli. +// +// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-flasher-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package commands + +import rpc "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1" + +type arduinoCoreServerImpl struct { + rpc.UnsafeArduinoCoreServiceServer // Force compile error for unimplemented methods +} + +func NewArduinoCoreServer() rpc.ArduinoCoreServiceServer { + return &arduinoCoreServerImpl{} +} diff --git a/commands/service_list.go b/commands/service_list.go new file mode 100644 index 0000000..0ae133d --- /dev/null +++ b/commands/service_list.go @@ -0,0 +1,40 @@ +// This file is part of arduino-flasher-cli. +// +// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-flasher-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package commands + +import ( + "context" + + "github.com/arduino/arduino-flasher-cli/internal/updater" + rpc "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1" +) + +func (s *arduinoCoreServerImpl) List(ctx context.Context, req *rpc.ListRequest) (*rpc.ListResponse, error) { + client := updater.NewClient() + + manifest, err := client.GetInfoManifest(ctx) + if err != nil { + return nil, err + } + + resp := &rpc.ListResponse{} + resp.Latest = manifest.Latest.Version + for _, r := range manifest.Releases { + resp.Releases = append(resp.Releases, &rpc.Release{BuildId: r.Version}) + } + + return resp, nil +} diff --git a/go.mod b/go.mod index cc0dada..8f03af7 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,8 @@ require ( go.bug.st/cleanup v1.0.0 go.bug.st/f v0.4.0 go.bug.st/relaxed-semver v0.15.0 + google.golang.org/grpc v1.77.0 + google.golang.org/protobuf v1.36.10 ) require ( @@ -71,12 +73,13 @@ require ( github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect github.com/zeebo/xxh3 v1.0.2 // indirect - golang.org/x/crypto v0.37.0 // indirect - golang.org/x/net v0.39.0 // indirect - golang.org/x/sync v0.16.0 // indirect + golang.org/x/crypto v0.43.0 // indirect + golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82 // indirect + golang.org/x/sync v0.17.0 // indirect golang.org/x/sys v0.37.0 // indirect - golang.org/x/term v0.35.0 // indirect - golang.org/x/text v0.24.0 // indirect + golang.org/x/term v0.36.0 // indirect + golang.org/x/text v0.30.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect mvdan.cc/sh/v3 v3.12.0 // indirect diff --git a/go.sum b/go.sum index 50ec8ea..b35710a 100644 --- a/go.sum +++ b/go.sum @@ -65,6 +65,10 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMj github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= github.com/go-git/go-git/v5 v5.16.2 h1:fT6ZIOjE5iEnkzKyxTHK1W4HGAsPhqEqiSAssSO77hM= github.com/go-git/go-git/v5 v5.16.2/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= @@ -78,6 +82,8 @@ github.com/go-task/template v0.2.0 h1:xW7ek0o65FUSTbKcSNeg2Vyf/I7wYXFgLUznptvviB github.com/go-task/template v0.2.0/go.mod h1:dbdoUb6qKnHQi1y6o+IdIrs0J4o/SEhSTA6bbzZmdtc= github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -181,16 +187,28 @@ go.bug.st/f v0.4.0 h1:Vstqb950nMA+PhAlRxUw8QL1ntHy/gXHNyyzjkQLJ10= go.bug.st/f v0.4.0/go.mod h1:bMo23205ll7UW63KwO1ut5RdlJ9JK8RyEEr88CmOF5Y= go.bug.st/relaxed-semver v0.15.0 h1:w37+SYQPxF53RQO7QZZuPIMaPouOifdaP0B1ktst2nA= go.bug.st/relaxed-semver v0.15.0/go.mod h1:bwHiCtYuD2m716tBk2OnOBjelsbXw9el5EIuyxT/ksU= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= +go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= +go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= +go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= +go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= +go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= +go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= -golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= +golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04= +golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= -golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= -golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= -golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82 h1:6/3JGEh1C88g7m+qzzTbl3A0FtsLguXieqofVLU/JAo= +golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= +golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= +golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -206,12 +224,20 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ= -golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA= +golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q= +golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= -golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= +golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= +golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 h1:M1rk8KBnUsBDg1oPGHNCxG4vc1f49epmTO7xscSajMk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= +google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM= +google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig= +google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= +google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go b/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go new file mode 100644 index 0000000..dbf56d1 --- /dev/null +++ b/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go @@ -0,0 +1,304 @@ +// This file is part of arduino-flasher-cli. +// +// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-flasher-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: cc/arduino/flasher/cli/commands/v1/commands.proto + +package commands + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListRequest) Reset() { + *x = ListRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRequest) ProtoMessage() {} + +func (x *ListRequest) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRequest.ProtoReflect.Descriptor instead. +func (*ListRequest) Descriptor() ([]byte, []int) { + return file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP(), []int{0} +} + +type ListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Latest string `protobuf:"bytes,1,opt,name=latest,proto3" json:"latest,omitempty"` + Releases []*Release `protobuf:"bytes,2,rep,name=releases,proto3" json:"releases,omitempty"` +} + +func (x *ListResponse) Reset() { + *x = ListResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListResponse) ProtoMessage() {} + +func (x *ListResponse) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_flasher_cli_commands_v1_commands_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 ListResponse.ProtoReflect.Descriptor instead. +func (*ListResponse) Descriptor() ([]byte, []int) { + return file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP(), []int{1} +} + +func (x *ListResponse) GetLatest() string { + if x != nil { + return x.Latest + } + return "" +} + +func (x *ListResponse) GetReleases() []*Release { + if x != nil { + return x.Releases + } + return nil +} + +type Release struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BuildId string `protobuf:"bytes,1,opt,name=build_id,json=buildId,proto3" json:"build_id,omitempty"` +} + +func (x *Release) Reset() { + *x = Release{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Release) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Release) ProtoMessage() {} + +func (x *Release) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Release.ProtoReflect.Descriptor instead. +func (*Release) Descriptor() ([]byte, []int) { + return file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP(), []int{2} +} + +func (x *Release) GetBuildId() string { + if x != nil { + return x.BuildId + } + return "" +} + +var File_cc_arduino_flasher_cli_commands_v1_commands_proto protoreflect.FileDescriptor + +var file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc = []byte{ + 0x0a, 0x31, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x66, 0x6c, 0x61, + 0x73, 0x68, 0x65, 0x72, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x22, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, + 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x6f, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0x47, + 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x2b, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, + 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x08, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x22, 0x24, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x32, 0x81, 0x01, + 0x0a, 0x12, 0x41, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x43, 0x6f, 0x72, 0x65, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x2e, 0x63, + 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, + 0x72, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, + 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, + 0x65, 0x72, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x42, 0x58, 0x5a, 0x56, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, + 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, + 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x66, 0x6c, 0x61, 0x73, 0x68, + 0x65, 0x72, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, + 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescOnce sync.Once + file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescData = file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc +) + +func file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP() []byte { + file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescOnce.Do(func() { + file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescData = protoimpl.X.CompressGZIP(file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescData) + }) + return file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescData +} + +var file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_cc_arduino_flasher_cli_commands_v1_commands_proto_goTypes = []any{ + (*ListRequest)(nil), // 0: cc.arduino.flasher.cli.commands.v1.ListRequest + (*ListResponse)(nil), // 1: cc.arduino.flasher.cli.commands.v1.ListResponse + (*Release)(nil), // 2: cc.arduino.flasher.cli.commands.v1.Release +} +var file_cc_arduino_flasher_cli_commands_v1_commands_proto_depIdxs = []int32{ + 2, // 0: cc.arduino.flasher.cli.commands.v1.ListResponse.releases:type_name -> cc.arduino.flasher.cli.commands.v1.Release + 0, // 1: cc.arduino.flasher.cli.commands.v1.ArduinoCoreService.List:input_type -> cc.arduino.flasher.cli.commands.v1.ListRequest + 1, // 2: cc.arduino.flasher.cli.commands.v1.ArduinoCoreService.List:output_type -> cc.arduino.flasher.cli.commands.v1.ListResponse + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_cc_arduino_flasher_cli_commands_v1_commands_proto_init() } +func file_cc_arduino_flasher_cli_commands_v1_commands_proto_init() { + if File_cc_arduino_flasher_cli_commands_v1_commands_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*ListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*ListResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*Release); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_cc_arduino_flasher_cli_commands_v1_commands_proto_goTypes, + DependencyIndexes: file_cc_arduino_flasher_cli_commands_v1_commands_proto_depIdxs, + MessageInfos: file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes, + }.Build() + File_cc_arduino_flasher_cli_commands_v1_commands_proto = out.File + file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc = nil + file_cc_arduino_flasher_cli_commands_v1_commands_proto_goTypes = nil + file_cc_arduino_flasher_cli_commands_v1_commands_proto_depIdxs = nil +} diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto b/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto new file mode 100644 index 0000000..3f6a84e --- /dev/null +++ b/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto @@ -0,0 +1,35 @@ +// This file is part of arduino-flasher-cli. +// +// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-flasher-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.flasher.cli.commands.v1; + +option go_package = "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1;commands"; + +service ArduinoCoreService { + rpc List(ListRequest) returns (ListResponse) {}; +} + +message ListRequest {} + +message ListResponse { + string latest = 1; + repeated Release releases = 2; +} + +message Release { + string build_id = 1; +} diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go b/rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go new file mode 100644 index 0000000..d57f005 --- /dev/null +++ b/rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go @@ -0,0 +1,136 @@ +// This file is part of arduino-flasher-cli. +// +// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-flasher-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: cc/arduino/flasher/cli/commands/v1/commands.proto + +package commands + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + ArduinoCoreService_List_FullMethodName = "/cc.arduino.flasher.cli.commands.v1.ArduinoCoreService/List" +) + +// ArduinoCoreServiceClient is the client API for ArduinoCoreService 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 ArduinoCoreServiceClient interface { + List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) +} + +type arduinoCoreServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewArduinoCoreServiceClient(cc grpc.ClientConnInterface) ArduinoCoreServiceClient { + return &arduinoCoreServiceClient{cc} +} + +func (c *arduinoCoreServiceClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListResponse) + err := c.cc.Invoke(ctx, ArduinoCoreService_List_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ArduinoCoreServiceServer is the server API for ArduinoCoreService service. +// All implementations must embed UnimplementedArduinoCoreServiceServer +// for forward compatibility. +type ArduinoCoreServiceServer interface { + List(context.Context, *ListRequest) (*ListResponse, error) + mustEmbedUnimplementedArduinoCoreServiceServer() +} + +// UnimplementedArduinoCoreServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedArduinoCoreServiceServer struct{} + +func (UnimplementedArduinoCoreServiceServer) List(context.Context, *ListRequest) (*ListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method List not implemented") +} +func (UnimplementedArduinoCoreServiceServer) mustEmbedUnimplementedArduinoCoreServiceServer() {} +func (UnimplementedArduinoCoreServiceServer) testEmbeddedByValue() {} + +// UnsafeArduinoCoreServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ArduinoCoreServiceServer will +// result in compilation errors. +type UnsafeArduinoCoreServiceServer interface { + mustEmbedUnimplementedArduinoCoreServiceServer() +} + +func RegisterArduinoCoreServiceServer(s grpc.ServiceRegistrar, srv ArduinoCoreServiceServer) { + // If the following call pancis, it indicates UnimplementedArduinoCoreServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&ArduinoCoreService_ServiceDesc, srv) +} + +func _ArduinoCoreService_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ArduinoCoreServiceServer).List(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ArduinoCoreService_List_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ArduinoCoreServiceServer).List(ctx, req.(*ListRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ArduinoCoreService_ServiceDesc is the grpc.ServiceDesc for ArduinoCoreService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ArduinoCoreService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "cc.arduino.flasher.cli.commands.v1.ArduinoCoreService", + HandlerType: (*ArduinoCoreServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "List", + Handler: _ArduinoCoreService_List_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cc/arduino/flasher/cli/commands/v1/commands.proto", +} From 001407504ff1277f257eb607a0ff35b50b464649 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 10 Dec 2025 09:29:27 +0100 Subject: [PATCH 2/7] Print releases in reverse order --- commands/service_list.go | 9 +++-- .../flasher/cli/commands/v1/commands.pb.go | 38 +++++++++---------- .../flasher/cli/commands/v1/commands.proto | 4 +- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/commands/service_list.go b/commands/service_list.go index 0ae133d..9760d14 100644 --- a/commands/service_list.go +++ b/commands/service_list.go @@ -31,9 +31,12 @@ func (s *arduinoCoreServerImpl) List(ctx context.Context, req *rpc.ListRequest) } resp := &rpc.ListResponse{} - resp.Latest = manifest.Latest.Version - for _, r := range manifest.Releases { - resp.Releases = append(resp.Releases, &rpc.Release{BuildId: r.Version}) + for i := len(manifest.Releases) - 1; i >= 0; i-- { + latest := false + if manifest.Releases[i].Version == manifest.Latest.Version { + latest = true + } + resp.Releases = append(resp.Releases, &rpc.Release{BuildId: manifest.Releases[i].Version, Latest: latest}) } return resp, nil diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go b/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go index dbf56d1..3b79c52 100644 --- a/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go +++ b/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go @@ -78,8 +78,7 @@ type ListResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Latest string `protobuf:"bytes,1,opt,name=latest,proto3" json:"latest,omitempty"` - Releases []*Release `protobuf:"bytes,2,rep,name=releases,proto3" json:"releases,omitempty"` + Releases []*Release `protobuf:"bytes,1,rep,name=releases,proto3" json:"releases,omitempty"` } func (x *ListResponse) Reset() { @@ -114,13 +113,6 @@ func (*ListResponse) Descriptor() ([]byte, []int) { return file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP(), []int{1} } -func (x *ListResponse) GetLatest() string { - if x != nil { - return x.Latest - } - return "" -} - func (x *ListResponse) GetReleases() []*Release { if x != nil { return x.Releases @@ -134,6 +126,7 @@ type Release struct { unknownFields protoimpl.UnknownFields BuildId string `protobuf:"bytes,1,opt,name=build_id,json=buildId,proto3" json:"build_id,omitempty"` + Latest bool `protobuf:"varint,2,opt,name=latest,proto3" json:"latest,omitempty"` } func (x *Release) Reset() { @@ -175,6 +168,13 @@ func (x *Release) GetBuildId() string { return "" } +func (x *Release) GetLatest() bool { + if x != nil { + return x.Latest + } + return false +} + var File_cc_arduino_flasher_cli_commands_v1_commands_proto protoreflect.FileDescriptor var file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc = []byte{ @@ -184,16 +184,16 @@ var file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x12, 0x22, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x6f, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0x47, - 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2b, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, - 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x08, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x22, 0x24, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x32, 0x81, 0x01, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x57, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, + 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6c, + 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x22, + 0x3c, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x32, 0x81, 0x01, 0x0a, 0x12, 0x41, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x43, 0x6f, 0x72, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto b/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto index 3f6a84e..f39f7e4 100644 --- a/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto +++ b/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto @@ -26,10 +26,10 @@ service ArduinoCoreService { message ListRequest {} message ListResponse { - string latest = 1; - repeated Release releases = 2; + repeated Release releases = 1; } message Release { string build_id = 1; + bool latest = 2; } From 3c5a4044f0d82e00b1fdcaa751a2e267d3b74b29 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 10 Dec 2025 11:17:37 +0100 Subject: [PATCH 3/7] Add buf.yaml file --- buf.lock | 2 ++ buf.yaml | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 buf.lock create mode 100644 buf.yaml diff --git a/buf.lock b/buf.lock new file mode 100644 index 0000000..4f98143 --- /dev/null +++ b/buf.lock @@ -0,0 +1,2 @@ +# Generated by buf. DO NOT EDIT. +version: v2 diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 0000000..d2ee8be --- /dev/null +++ b/buf.yaml @@ -0,0 +1,15 @@ +version: v2 +breaking: + use: + - FILE +lint: + use: + - STANDARD + - COMMENT_ENUM + - COMMENT_ENUM_VALUE + - COMMENT_FIELD + - COMMENT_RPC + - COMMENT_SERVICE +modules: + - path: rpc + name: buf.build/arduino/arduino-flasher-cli From 8e2e127740bf722c10e36d2883b64d7a6e8f91c8 Mon Sep 17 00:00:00 2001 From: MatteoPologruto <109663225+MatteoPologruto@users.noreply.github.com> Date: Wed, 10 Dec 2025 12:40:52 +0100 Subject: [PATCH 4/7] Update cmd/arduino-flasher-cli/daemon/daemon.go Co-authored-by: Cristian Maglie --- cmd/arduino-flasher-cli/daemon/daemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/arduino-flasher-cli/daemon/daemon.go b/cmd/arduino-flasher-cli/daemon/daemon.go index b3669a7..97c115c 100644 --- a/cmd/arduino-flasher-cli/daemon/daemon.go +++ b/cmd/arduino-flasher-cli/daemon/daemon.go @@ -46,7 +46,7 @@ func NewDaemonCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command { } daemonCommand.Flags().StringVar(&daemonPort, - "port", "50051", + "port", "50052", i18n.Tr("The TCP port the daemon will listen to")) daemonCommand.Flags().IntVar(&maxGRPCRecvMsgSize, From 60f327a1eb365182d618461ad336b5dac1eeffff Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 10 Dec 2025 13:54:22 +0100 Subject: [PATCH 5/7] Rename ArduinoCoreService to FlasherService --- cmd/arduino-flasher-cli/daemon/daemon.go | 6 +- cmd/arduino-flasher-cli/main.go | 2 +- commands/service.go | 8 +-- commands/service_list.go | 2 +- .../flasher/cli/commands/v1/commands.pb.go | 63 ++++++++--------- .../flasher/cli/commands/v1/commands.proto | 6 +- .../cli/commands/v1/commands_grpc.pb.go | 68 +++++++++---------- 7 files changed, 75 insertions(+), 80 deletions(-) diff --git a/cmd/arduino-flasher-cli/daemon/daemon.go b/cmd/arduino-flasher-cli/daemon/daemon.go index 97c115c..f856fcf 100644 --- a/cmd/arduino-flasher-cli/daemon/daemon.go +++ b/cmd/arduino-flasher-cli/daemon/daemon.go @@ -32,7 +32,7 @@ import ( rpc "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1" ) -func NewDaemonCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command { +func NewDaemonCommand(srv rpc.FlasherServiceServer) *cobra.Command { var daemonPort string var maxGRPCRecvMsgSize int daemonCommand := &cobra.Command{ @@ -56,13 +56,13 @@ func NewDaemonCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command { return daemonCommand } -func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort string, maxGRPCRecvMsgSize int) { +func runDaemonCommand(srv rpc.FlasherServiceServer, daemonPort string, maxGRPCRecvMsgSize int) { gRPCOptions := []grpc.ServerOption{} gRPCOptions = append(gRPCOptions, grpc.MaxRecvMsgSize(maxGRPCRecvMsgSize)) s := grpc.NewServer(gRPCOptions...) // register the commands service - rpc.RegisterArduinoCoreServiceServer(s, srv) + rpc.RegisterFlasherServiceServer(s, srv) daemonIP := "127.0.0.1" lis, err := net.Listen("tcp", fmt.Sprintf("%s:%s", daemonIP, daemonPort)) diff --git a/cmd/arduino-flasher-cli/main.go b/cmd/arduino-flasher-cli/main.go index 43045fc..cffca54 100644 --- a/cmd/arduino-flasher-cli/main.go +++ b/cmd/arduino-flasher-cli/main.go @@ -39,7 +39,7 @@ var Version string = "0.0.0-dev" var format string func main() { - srv := commands.NewArduinoCoreServer() + srv := commands.NewFlasherServer() rootCmd := &cobra.Command{ Use: "arduino-flasher-cli", diff --git a/commands/service.go b/commands/service.go index 7a9ca4a..de1656e 100644 --- a/commands/service.go +++ b/commands/service.go @@ -17,10 +17,10 @@ package commands import rpc "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1" -type arduinoCoreServerImpl struct { - rpc.UnsafeArduinoCoreServiceServer // Force compile error for unimplemented methods +type flasherServerImpl struct { + rpc.UnsafeFlasherServiceServer // Force compile error for unimplemented methods } -func NewArduinoCoreServer() rpc.ArduinoCoreServiceServer { - return &arduinoCoreServerImpl{} +func NewFlasherServer() rpc.FlasherServiceServer { + return &flasherServerImpl{} } diff --git a/commands/service_list.go b/commands/service_list.go index 9760d14..f4480af 100644 --- a/commands/service_list.go +++ b/commands/service_list.go @@ -22,7 +22,7 @@ import ( rpc "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1" ) -func (s *arduinoCoreServerImpl) List(ctx context.Context, req *rpc.ListRequest) (*rpc.ListResponse, error) { +func (s *flasherServerImpl) List(ctx context.Context, req *rpc.ListRequest) (*rpc.ListResponse, error) { client := updater.NewClient() manifest, err := client.GetInfoManifest(ctx) diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go b/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go index 3b79c52..f99f618 100644 --- a/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go +++ b/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go @@ -19,7 +19,7 @@ // protoc (unknown) // source: cc/arduino/flasher/cli/commands/v1/commands.proto -package commands +package flasher import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -181,34 +181,29 @@ var file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc = []byte{ 0x0a, 0x31, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x22, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, - 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x57, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, - 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6c, - 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, - 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x22, - 0x3c, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x75, - 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x75, - 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x32, 0x81, 0x01, - 0x0a, 0x12, 0x41, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x43, 0x6f, 0x72, 0x65, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x2e, 0x63, - 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, - 0x72, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, - 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, + 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, + 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4a, 0x0a, 0x0c, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x63, + 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, + 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x73, 0x22, 0x3c, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x12, 0x19, 0x0a, 0x08, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6c, + 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6c, 0x61, 0x74, + 0x65, 0x73, 0x74, 0x32, 0x63, 0x0a, 0x0e, 0x46, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x22, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, - 0x65, 0x72, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x58, 0x5a, 0x56, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, - 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, - 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x66, 0x6c, 0x61, 0x73, 0x68, - 0x65, 0x72, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, - 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x23, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, + 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x4b, 0x5a, 0x49, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, + 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2d, 0x63, + 0x6c, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2f, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x3b, 0x66, 0x6c, + 0x61, 0x73, 0x68, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -225,14 +220,14 @@ func file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP() []byte var file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_cc_arduino_flasher_cli_commands_v1_commands_proto_goTypes = []any{ - (*ListRequest)(nil), // 0: cc.arduino.flasher.cli.commands.v1.ListRequest - (*ListResponse)(nil), // 1: cc.arduino.flasher.cli.commands.v1.ListResponse - (*Release)(nil), // 2: cc.arduino.flasher.cli.commands.v1.Release + (*ListRequest)(nil), // 0: cc.arduino.flasher.v1.ListRequest + (*ListResponse)(nil), // 1: cc.arduino.flasher.v1.ListResponse + (*Release)(nil), // 2: cc.arduino.flasher.v1.Release } var file_cc_arduino_flasher_cli_commands_v1_commands_proto_depIdxs = []int32{ - 2, // 0: cc.arduino.flasher.cli.commands.v1.ListResponse.releases:type_name -> cc.arduino.flasher.cli.commands.v1.Release - 0, // 1: cc.arduino.flasher.cli.commands.v1.ArduinoCoreService.List:input_type -> cc.arduino.flasher.cli.commands.v1.ListRequest - 1, // 2: cc.arduino.flasher.cli.commands.v1.ArduinoCoreService.List:output_type -> cc.arduino.flasher.cli.commands.v1.ListResponse + 2, // 0: cc.arduino.flasher.v1.ListResponse.releases:type_name -> cc.arduino.flasher.v1.Release + 0, // 1: cc.arduino.flasher.v1.FlasherService.List:input_type -> cc.arduino.flasher.v1.ListRequest + 1, // 2: cc.arduino.flasher.v1.FlasherService.List:output_type -> cc.arduino.flasher.v1.ListResponse 2, // [2:3] is the sub-list for method output_type 1, // [1:2] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto b/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto index f39f7e4..00be47b 100644 --- a/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto +++ b/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto @@ -15,11 +15,11 @@ syntax = "proto3"; -package cc.arduino.flasher.cli.commands.v1; +package cc.arduino.flasher.v1; -option go_package = "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1;commands"; +option go_package = "github.com/arduino/arduino-flasher-cli/grpc/cc/arduino/flasher/v1;flasher"; -service ArduinoCoreService { +service FlasherService { rpc List(ListRequest) returns (ListResponse) {}; } diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go b/rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go index d57f005..d218ffe 100644 --- a/rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go +++ b/rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go @@ -19,7 +19,7 @@ // - protoc (unknown) // source: cc/arduino/flasher/cli/commands/v1/commands.proto -package commands +package flasher import ( context "context" @@ -34,101 +34,101 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - ArduinoCoreService_List_FullMethodName = "/cc.arduino.flasher.cli.commands.v1.ArduinoCoreService/List" + FlasherService_List_FullMethodName = "/cc.arduino.flasher.v1.FlasherService/List" ) -// ArduinoCoreServiceClient is the client API for ArduinoCoreService service. +// FlasherServiceClient is the client API for FlasherService 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 ArduinoCoreServiceClient interface { +type FlasherServiceClient interface { List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) } -type arduinoCoreServiceClient struct { +type flasherServiceClient struct { cc grpc.ClientConnInterface } -func NewArduinoCoreServiceClient(cc grpc.ClientConnInterface) ArduinoCoreServiceClient { - return &arduinoCoreServiceClient{cc} +func NewFlasherServiceClient(cc grpc.ClientConnInterface) FlasherServiceClient { + return &flasherServiceClient{cc} } -func (c *arduinoCoreServiceClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { +func (c *flasherServiceClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ListResponse) - err := c.cc.Invoke(ctx, ArduinoCoreService_List_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, FlasherService_List_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -// ArduinoCoreServiceServer is the server API for ArduinoCoreService service. -// All implementations must embed UnimplementedArduinoCoreServiceServer +// FlasherServiceServer is the server API for FlasherService service. +// All implementations must embed UnimplementedFlasherServiceServer // for forward compatibility. -type ArduinoCoreServiceServer interface { +type FlasherServiceServer interface { List(context.Context, *ListRequest) (*ListResponse, error) - mustEmbedUnimplementedArduinoCoreServiceServer() + mustEmbedUnimplementedFlasherServiceServer() } -// UnimplementedArduinoCoreServiceServer must be embedded to have +// UnimplementedFlasherServiceServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedArduinoCoreServiceServer struct{} +type UnimplementedFlasherServiceServer struct{} -func (UnimplementedArduinoCoreServiceServer) List(context.Context, *ListRequest) (*ListResponse, error) { +func (UnimplementedFlasherServiceServer) List(context.Context, *ListRequest) (*ListResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method List not implemented") } -func (UnimplementedArduinoCoreServiceServer) mustEmbedUnimplementedArduinoCoreServiceServer() {} -func (UnimplementedArduinoCoreServiceServer) testEmbeddedByValue() {} +func (UnimplementedFlasherServiceServer) mustEmbedUnimplementedFlasherServiceServer() {} +func (UnimplementedFlasherServiceServer) testEmbeddedByValue() {} -// UnsafeArduinoCoreServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ArduinoCoreServiceServer will +// UnsafeFlasherServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to FlasherServiceServer will // result in compilation errors. -type UnsafeArduinoCoreServiceServer interface { - mustEmbedUnimplementedArduinoCoreServiceServer() +type UnsafeFlasherServiceServer interface { + mustEmbedUnimplementedFlasherServiceServer() } -func RegisterArduinoCoreServiceServer(s grpc.ServiceRegistrar, srv ArduinoCoreServiceServer) { - // If the following call pancis, it indicates UnimplementedArduinoCoreServiceServer was +func RegisterFlasherServiceServer(s grpc.ServiceRegistrar, srv FlasherServiceServer) { + // If the following call pancis, it indicates UnimplementedFlasherServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&ArduinoCoreService_ServiceDesc, srv) + s.RegisterService(&FlasherService_ServiceDesc, srv) } -func _ArduinoCoreService_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _FlasherService_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ListRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ArduinoCoreServiceServer).List(ctx, in) + return srv.(FlasherServiceServer).List(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: ArduinoCoreService_List_FullMethodName, + FullMethod: FlasherService_List_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ArduinoCoreServiceServer).List(ctx, req.(*ListRequest)) + return srv.(FlasherServiceServer).List(ctx, req.(*ListRequest)) } return interceptor(ctx, in, info, handler) } -// ArduinoCoreService_ServiceDesc is the grpc.ServiceDesc for ArduinoCoreService service. +// FlasherService_ServiceDesc is the grpc.ServiceDesc for FlasherService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var ArduinoCoreService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "cc.arduino.flasher.cli.commands.v1.ArduinoCoreService", - HandlerType: (*ArduinoCoreServiceServer)(nil), +var FlasherService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "cc.arduino.flasher.v1.FlasherService", + HandlerType: (*FlasherServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "List", - Handler: _ArduinoCoreService_List_Handler, + Handler: _FlasherService_List_Handler, }, }, Streams: []grpc.StreamDesc{}, From d3b72e19bfe6224d306ed0d5fdeab7b118b81437 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 10 Dec 2025 14:38:23 +0100 Subject: [PATCH 6/7] Some more renaming --- cmd/arduino-flasher-cli/daemon/daemon.go | 8 +- cmd/arduino-flasher-cli/main.go | 4 +- .../{cli/commands => }/v1/commands.pb.go | 125 +++++++++--------- .../{cli/commands => }/v1/commands.proto | 4 +- .../{cli/commands => }/v1/commands_grpc.pb.go | 70 +++++----- {commands => service}/service.go | 8 +- {commands => service}/service_list.go | 10 +- 7 files changed, 114 insertions(+), 115 deletions(-) rename rpc/cc/arduino/flasher/{cli/commands => }/v1/commands.pb.go (52%) rename rpc/cc/arduino/flasher/{cli/commands => }/v1/commands.proto (86%) rename rpc/cc/arduino/flasher/{cli/commands => }/v1/commands_grpc.pb.go (56%) rename {commands => service}/service.go (74%) rename {commands => service}/service_list.go (73%) diff --git a/cmd/arduino-flasher-cli/daemon/daemon.go b/cmd/arduino-flasher-cli/daemon/daemon.go index f856fcf..f9e252f 100644 --- a/cmd/arduino-flasher-cli/daemon/daemon.go +++ b/cmd/arduino-flasher-cli/daemon/daemon.go @@ -29,10 +29,10 @@ import ( "github.com/spf13/cobra" "google.golang.org/grpc" - rpc "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1" + flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" ) -func NewDaemonCommand(srv rpc.FlasherServiceServer) *cobra.Command { +func NewDaemonCommand(srv flasher.FlasherServer) *cobra.Command { var daemonPort string var maxGRPCRecvMsgSize int daemonCommand := &cobra.Command{ @@ -56,13 +56,13 @@ func NewDaemonCommand(srv rpc.FlasherServiceServer) *cobra.Command { return daemonCommand } -func runDaemonCommand(srv rpc.FlasherServiceServer, daemonPort string, maxGRPCRecvMsgSize int) { +func runDaemonCommand(srv flasher.FlasherServer, daemonPort string, maxGRPCRecvMsgSize int) { gRPCOptions := []grpc.ServerOption{} gRPCOptions = append(gRPCOptions, grpc.MaxRecvMsgSize(maxGRPCRecvMsgSize)) s := grpc.NewServer(gRPCOptions...) // register the commands service - rpc.RegisterFlasherServiceServer(s, srv) + flasher.RegisterFlasherServer(s, srv) daemonIP := "127.0.0.1" lis, err := net.Listen("tcp", fmt.Sprintf("%s:%s", daemonIP, daemonPort)) diff --git a/cmd/arduino-flasher-cli/main.go b/cmd/arduino-flasher-cli/main.go index cffca54..5083ce5 100644 --- a/cmd/arduino-flasher-cli/main.go +++ b/cmd/arduino-flasher-cli/main.go @@ -31,7 +31,7 @@ import ( "github.com/arduino/arduino-flasher-cli/cmd/arduino-flasher-cli/version" "github.com/arduino/arduino-flasher-cli/cmd/feedback" "github.com/arduino/arduino-flasher-cli/cmd/i18n" - "github.com/arduino/arduino-flasher-cli/commands" + "github.com/arduino/arduino-flasher-cli/service" ) // Version will be set a build time with -ldflags @@ -39,7 +39,7 @@ var Version string = "0.0.0-dev" var format string func main() { - srv := commands.NewFlasherServer() + srv := service.NewFlasherServer() rootCmd := &cobra.Command{ Use: "arduino-flasher-cli", diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go b/rpc/cc/arduino/flasher/v1/commands.pb.go similarity index 52% rename from rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go rename to rpc/cc/arduino/flasher/v1/commands.pb.go index f99f618..eae743f 100644 --- a/rpc/cc/arduino/flasher/cli/commands/v1/commands.pb.go +++ b/rpc/cc/arduino/flasher/v1/commands.pb.go @@ -17,7 +17,7 @@ // versions: // protoc-gen-go v1.34.2 // protoc (unknown) -// source: cc/arduino/flasher/cli/commands/v1/commands.proto +// source: cc/arduino/flasher/v1/commands.proto package flasher @@ -44,7 +44,7 @@ type ListRequest struct { func (x *ListRequest) Reset() { *x = ListRequest{} if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[0] + mi := &file_cc_arduino_flasher_v1_commands_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -57,7 +57,7 @@ func (x *ListRequest) String() string { func (*ListRequest) ProtoMessage() {} func (x *ListRequest) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[0] + mi := &file_cc_arduino_flasher_v1_commands_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -70,7 +70,7 @@ func (x *ListRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRequest.ProtoReflect.Descriptor instead. func (*ListRequest) Descriptor() ([]byte, []int) { - return file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP(), []int{0} + return file_cc_arduino_flasher_v1_commands_proto_rawDescGZIP(), []int{0} } type ListResponse struct { @@ -84,7 +84,7 @@ type ListResponse struct { func (x *ListResponse) Reset() { *x = ListResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[1] + mi := &file_cc_arduino_flasher_v1_commands_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -97,7 +97,7 @@ func (x *ListResponse) String() string { func (*ListResponse) ProtoMessage() {} func (x *ListResponse) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[1] + mi := &file_cc_arduino_flasher_v1_commands_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -110,7 +110,7 @@ func (x *ListResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListResponse.ProtoReflect.Descriptor instead. func (*ListResponse) Descriptor() ([]byte, []int) { - return file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP(), []int{1} + return file_cc_arduino_flasher_v1_commands_proto_rawDescGZIP(), []int{1} } func (x *ListResponse) GetReleases() []*Release { @@ -132,7 +132,7 @@ type Release struct { func (x *Release) Reset() { *x = Release{} if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[2] + mi := &file_cc_arduino_flasher_v1_commands_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -145,7 +145,7 @@ func (x *Release) String() string { func (*Release) ProtoMessage() {} func (x *Release) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[2] + mi := &file_cc_arduino_flasher_v1_commands_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -158,7 +158,7 @@ func (x *Release) ProtoReflect() protoreflect.Message { // Deprecated: Use Release.ProtoReflect.Descriptor instead. func (*Release) Descriptor() ([]byte, []int) { - return file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP(), []int{2} + return file_cc_arduino_flasher_v1_commands_proto_rawDescGZIP(), []int{2} } func (x *Release) GetBuildId() string { @@ -175,59 +175,58 @@ func (x *Release) GetLatest() bool { return false } -var File_cc_arduino_flasher_cli_commands_v1_commands_proto protoreflect.FileDescriptor - -var file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc = []byte{ - 0x0a, 0x31, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x66, 0x6c, 0x61, - 0x73, 0x68, 0x65, 0x72, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, - 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4a, 0x0a, 0x0c, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x72, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x63, - 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, - 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x73, 0x22, 0x3c, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x12, 0x19, 0x0a, 0x08, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6c, - 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6c, 0x61, 0x74, - 0x65, 0x73, 0x74, 0x32, 0x63, 0x0a, 0x0e, 0x46, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x22, 0x2e, +var File_cc_arduino_flasher_v1_commands_proto protoreflect.FileDescriptor + +var file_cc_arduino_flasher_v1_commands_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x66, 0x6c, 0x61, + 0x73, 0x68, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x22, 0x0d, 0x0a, + 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4a, 0x0a, 0x0c, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x08, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, + 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, + 0x68, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x08, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x22, 0x3c, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x16, + 0x0a, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, + 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x32, 0x5c, 0x0a, 0x07, 0x46, 0x6c, 0x61, 0x73, 0x68, 0x65, + 0x72, 0x12, 0x51, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x22, 0x2e, 0x63, 0x63, 0x2e, 0x61, + 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x76, + 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x73, 0x68, - 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x23, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x66, - 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x4b, 0x5a, 0x49, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, - 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2d, 0x63, - 0x6c, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, - 0x6e, 0x6f, 0x2f, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x3b, 0x66, 0x6c, - 0x61, 0x73, 0x68, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2d, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, + 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x66, 0x6c, + 0x61, 0x73, 0x68, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x3b, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescOnce sync.Once - file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescData = file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc + file_cc_arduino_flasher_v1_commands_proto_rawDescOnce sync.Once + file_cc_arduino_flasher_v1_commands_proto_rawDescData = file_cc_arduino_flasher_v1_commands_proto_rawDesc ) -func file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescGZIP() []byte { - file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescOnce.Do(func() { - file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescData = protoimpl.X.CompressGZIP(file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescData) +func file_cc_arduino_flasher_v1_commands_proto_rawDescGZIP() []byte { + file_cc_arduino_flasher_v1_commands_proto_rawDescOnce.Do(func() { + file_cc_arduino_flasher_v1_commands_proto_rawDescData = protoimpl.X.CompressGZIP(file_cc_arduino_flasher_v1_commands_proto_rawDescData) }) - return file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDescData + return file_cc_arduino_flasher_v1_commands_proto_rawDescData } -var file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_cc_arduino_flasher_cli_commands_v1_commands_proto_goTypes = []any{ +var file_cc_arduino_flasher_v1_commands_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_cc_arduino_flasher_v1_commands_proto_goTypes = []any{ (*ListRequest)(nil), // 0: cc.arduino.flasher.v1.ListRequest (*ListResponse)(nil), // 1: cc.arduino.flasher.v1.ListResponse (*Release)(nil), // 2: cc.arduino.flasher.v1.Release } -var file_cc_arduino_flasher_cli_commands_v1_commands_proto_depIdxs = []int32{ +var file_cc_arduino_flasher_v1_commands_proto_depIdxs = []int32{ 2, // 0: cc.arduino.flasher.v1.ListResponse.releases:type_name -> cc.arduino.flasher.v1.Release - 0, // 1: cc.arduino.flasher.v1.FlasherService.List:input_type -> cc.arduino.flasher.v1.ListRequest - 1, // 2: cc.arduino.flasher.v1.FlasherService.List:output_type -> cc.arduino.flasher.v1.ListResponse + 0, // 1: cc.arduino.flasher.v1.Flasher.List:input_type -> cc.arduino.flasher.v1.ListRequest + 1, // 2: cc.arduino.flasher.v1.Flasher.List:output_type -> cc.arduino.flasher.v1.ListResponse 2, // [2:3] is the sub-list for method output_type 1, // [1:2] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -235,13 +234,13 @@ var file_cc_arduino_flasher_cli_commands_v1_commands_proto_depIdxs = []int32{ 0, // [0:1] is the sub-list for field type_name } -func init() { file_cc_arduino_flasher_cli_commands_v1_commands_proto_init() } -func file_cc_arduino_flasher_cli_commands_v1_commands_proto_init() { - if File_cc_arduino_flasher_cli_commands_v1_commands_proto != nil { +func init() { file_cc_arduino_flasher_v1_commands_proto_init() } +func file_cc_arduino_flasher_v1_commands_proto_init() { + if File_cc_arduino_flasher_v1_commands_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[0].Exporter = func(v any, i int) any { + file_cc_arduino_flasher_v1_commands_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ListRequest); i { case 0: return &v.state @@ -253,7 +252,7 @@ func file_cc_arduino_flasher_cli_commands_v1_commands_proto_init() { return nil } } - file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[1].Exporter = func(v any, i int) any { + file_cc_arduino_flasher_v1_commands_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ListResponse); i { case 0: return &v.state @@ -265,7 +264,7 @@ func file_cc_arduino_flasher_cli_commands_v1_commands_proto_init() { return nil } } - file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes[2].Exporter = func(v any, i int) any { + file_cc_arduino_flasher_v1_commands_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Release); i { case 0: return &v.state @@ -282,18 +281,18 @@ func file_cc_arduino_flasher_cli_commands_v1_commands_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc, + RawDescriptor: file_cc_arduino_flasher_v1_commands_proto_rawDesc, NumEnums: 0, NumMessages: 3, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_cc_arduino_flasher_cli_commands_v1_commands_proto_goTypes, - DependencyIndexes: file_cc_arduino_flasher_cli_commands_v1_commands_proto_depIdxs, - MessageInfos: file_cc_arduino_flasher_cli_commands_v1_commands_proto_msgTypes, + GoTypes: file_cc_arduino_flasher_v1_commands_proto_goTypes, + DependencyIndexes: file_cc_arduino_flasher_v1_commands_proto_depIdxs, + MessageInfos: file_cc_arduino_flasher_v1_commands_proto_msgTypes, }.Build() - File_cc_arduino_flasher_cli_commands_v1_commands_proto = out.File - file_cc_arduino_flasher_cli_commands_v1_commands_proto_rawDesc = nil - file_cc_arduino_flasher_cli_commands_v1_commands_proto_goTypes = nil - file_cc_arduino_flasher_cli_commands_v1_commands_proto_depIdxs = nil + File_cc_arduino_flasher_v1_commands_proto = out.File + file_cc_arduino_flasher_v1_commands_proto_rawDesc = nil + file_cc_arduino_flasher_v1_commands_proto_goTypes = nil + file_cc_arduino_flasher_v1_commands_proto_depIdxs = nil } diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto b/rpc/cc/arduino/flasher/v1/commands.proto similarity index 86% rename from rpc/cc/arduino/flasher/cli/commands/v1/commands.proto rename to rpc/cc/arduino/flasher/v1/commands.proto index 00be47b..c2de4d4 100644 --- a/rpc/cc/arduino/flasher/cli/commands/v1/commands.proto +++ b/rpc/cc/arduino/flasher/v1/commands.proto @@ -17,9 +17,9 @@ syntax = "proto3"; package cc.arduino.flasher.v1; -option go_package = "github.com/arduino/arduino-flasher-cli/grpc/cc/arduino/flasher/v1;flasher"; +option go_package = "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1;flasher"; -service FlasherService { +service Flasher { rpc List(ListRequest) returns (ListResponse) {}; } diff --git a/rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go b/rpc/cc/arduino/flasher/v1/commands_grpc.pb.go similarity index 56% rename from rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go rename to rpc/cc/arduino/flasher/v1/commands_grpc.pb.go index d218ffe..37de904 100644 --- a/rpc/cc/arduino/flasher/cli/commands/v1/commands_grpc.pb.go +++ b/rpc/cc/arduino/flasher/v1/commands_grpc.pb.go @@ -17,7 +17,7 @@ // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) -// source: cc/arduino/flasher/cli/commands/v1/commands.proto +// source: cc/arduino/flasher/v1/commands.proto package flasher @@ -34,103 +34,103 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - FlasherService_List_FullMethodName = "/cc.arduino.flasher.v1.FlasherService/List" + Flasher_List_FullMethodName = "/cc.arduino.flasher.v1.Flasher/List" ) -// FlasherServiceClient is the client API for FlasherService service. +// FlasherClient is the client API for Flasher 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 FlasherServiceClient interface { +type FlasherClient interface { List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) } -type flasherServiceClient struct { +type flasherClient struct { cc grpc.ClientConnInterface } -func NewFlasherServiceClient(cc grpc.ClientConnInterface) FlasherServiceClient { - return &flasherServiceClient{cc} +func NewFlasherClient(cc grpc.ClientConnInterface) FlasherClient { + return &flasherClient{cc} } -func (c *flasherServiceClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { +func (c *flasherClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ListResponse) - err := c.cc.Invoke(ctx, FlasherService_List_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, Flasher_List_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -// FlasherServiceServer is the server API for FlasherService service. -// All implementations must embed UnimplementedFlasherServiceServer +// FlasherServer is the server API for Flasher service. +// All implementations must embed UnimplementedFlasherServer // for forward compatibility. -type FlasherServiceServer interface { +type FlasherServer interface { List(context.Context, *ListRequest) (*ListResponse, error) - mustEmbedUnimplementedFlasherServiceServer() + mustEmbedUnimplementedFlasherServer() } -// UnimplementedFlasherServiceServer must be embedded to have +// UnimplementedFlasherServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedFlasherServiceServer struct{} +type UnimplementedFlasherServer struct{} -func (UnimplementedFlasherServiceServer) List(context.Context, *ListRequest) (*ListResponse, error) { +func (UnimplementedFlasherServer) List(context.Context, *ListRequest) (*ListResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method List not implemented") } -func (UnimplementedFlasherServiceServer) mustEmbedUnimplementedFlasherServiceServer() {} -func (UnimplementedFlasherServiceServer) testEmbeddedByValue() {} +func (UnimplementedFlasherServer) mustEmbedUnimplementedFlasherServer() {} +func (UnimplementedFlasherServer) testEmbeddedByValue() {} -// UnsafeFlasherServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to FlasherServiceServer will +// UnsafeFlasherServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to FlasherServer will // result in compilation errors. -type UnsafeFlasherServiceServer interface { - mustEmbedUnimplementedFlasherServiceServer() +type UnsafeFlasherServer interface { + mustEmbedUnimplementedFlasherServer() } -func RegisterFlasherServiceServer(s grpc.ServiceRegistrar, srv FlasherServiceServer) { - // If the following call pancis, it indicates UnimplementedFlasherServiceServer was +func RegisterFlasherServer(s grpc.ServiceRegistrar, srv FlasherServer) { + // If the following call pancis, it indicates UnimplementedFlasherServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&FlasherService_ServiceDesc, srv) + s.RegisterService(&Flasher_ServiceDesc, srv) } -func _FlasherService_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Flasher_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ListRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(FlasherServiceServer).List(ctx, in) + return srv.(FlasherServer).List(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: FlasherService_List_FullMethodName, + FullMethod: Flasher_List_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FlasherServiceServer).List(ctx, req.(*ListRequest)) + return srv.(FlasherServer).List(ctx, req.(*ListRequest)) } return interceptor(ctx, in, info, handler) } -// FlasherService_ServiceDesc is the grpc.ServiceDesc for FlasherService service. +// Flasher_ServiceDesc is the grpc.ServiceDesc for Flasher service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var FlasherService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "cc.arduino.flasher.v1.FlasherService", - HandlerType: (*FlasherServiceServer)(nil), +var Flasher_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "cc.arduino.flasher.v1.Flasher", + HandlerType: (*FlasherServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "List", - Handler: _FlasherService_List_Handler, + Handler: _Flasher_List_Handler, }, }, Streams: []grpc.StreamDesc{}, - Metadata: "cc/arduino/flasher/cli/commands/v1/commands.proto", + Metadata: "cc/arduino/flasher/v1/commands.proto", } diff --git a/commands/service.go b/service/service.go similarity index 74% rename from commands/service.go rename to service/service.go index de1656e..fcbdc3b 100644 --- a/commands/service.go +++ b/service/service.go @@ -13,14 +13,14 @@ // Arduino software without disclosing the source code of your own applications. // To purchase a commercial license, send an email to license@arduino.cc. -package commands +package service -import rpc "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1" +import flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" type flasherServerImpl struct { - rpc.UnsafeFlasherServiceServer // Force compile error for unimplemented methods + flasher.UnsafeFlasherServer // Force compile error for unimplemented methods } -func NewFlasherServer() rpc.FlasherServiceServer { +func NewFlasherServer() flasher.FlasherServer { return &flasherServerImpl{} } diff --git a/commands/service_list.go b/service/service_list.go similarity index 73% rename from commands/service_list.go rename to service/service_list.go index f4480af..f1dba3b 100644 --- a/commands/service_list.go +++ b/service/service_list.go @@ -13,16 +13,16 @@ // Arduino software without disclosing the source code of your own applications. // To purchase a commercial license, send an email to license@arduino.cc. -package commands +package service import ( "context" "github.com/arduino/arduino-flasher-cli/internal/updater" - rpc "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/cli/commands/v1" + flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" ) -func (s *flasherServerImpl) List(ctx context.Context, req *rpc.ListRequest) (*rpc.ListResponse, error) { +func (s *flasherServerImpl) List(ctx context.Context, req *flasher.ListRequest) (*flasher.ListResponse, error) { client := updater.NewClient() manifest, err := client.GetInfoManifest(ctx) @@ -30,13 +30,13 @@ func (s *flasherServerImpl) List(ctx context.Context, req *rpc.ListRequest) (*rp return nil, err } - resp := &rpc.ListResponse{} + resp := &flasher.ListResponse{} for i := len(manifest.Releases) - 1; i >= 0; i-- { latest := false if manifest.Releases[i].Version == manifest.Latest.Version { latest = true } - resp.Releases = append(resp.Releases, &rpc.Release{BuildId: manifest.Releases[i].Version, Latest: latest}) + resp.Releases = append(resp.Releases, &flasher.Release{BuildId: manifest.Releases[i].Version, Latest: latest}) } return resp, nil From ac721bea94eacf92847b65281c34ac6bbe95d142 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 10 Dec 2025 16:27:29 +0100 Subject: [PATCH 7/7] Run task fmt --- buf.gen.yaml | 28 +- buf.yaml | 30 +-- cmd/arduino-flasher-cli/daemon/daemon.go | 249 +++++++++--------- rpc/cc/arduino/flasher/v1/commands.pb.go | 5 +- rpc/cc/arduino/flasher/v1/commands_grpc.pb.go | 1 + service/service.go | 52 ++-- service/service_list.go | 86 +++--- 7 files changed, 227 insertions(+), 224 deletions(-) diff --git a/buf.gen.yaml b/buf.gen.yaml index 555b1dd..b00e81d 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -1,14 +1,14 @@ -version: v2 -plugins: - # Use protoc-gen-go - - remote: buf.build/protocolbuffers/go:v1.34.2 - out: ./rpc - opt: - - paths=source_relative - # Use of protoc-gen-go-grpc - - remote: buf.build/grpc/go:v1.5.1 - out: ./rpc - opt: - - paths=source_relative -inputs: - - directory: ./rpc +version: v2 +plugins: + # Use protoc-gen-go + - remote: buf.build/protocolbuffers/go:v1.34.2 + out: ./rpc + opt: + - paths=source_relative + # Use of protoc-gen-go-grpc + - remote: buf.build/grpc/go:v1.5.1 + out: ./rpc + opt: + - paths=source_relative +inputs: + - directory: ./rpc diff --git a/buf.yaml b/buf.yaml index d2ee8be..55b5b39 100644 --- a/buf.yaml +++ b/buf.yaml @@ -1,15 +1,15 @@ -version: v2 -breaking: - use: - - FILE -lint: - use: - - STANDARD - - COMMENT_ENUM - - COMMENT_ENUM_VALUE - - COMMENT_FIELD - - COMMENT_RPC - - COMMENT_SERVICE -modules: - - path: rpc - name: buf.build/arduino/arduino-flasher-cli +version: v2 +breaking: + use: + - FILE +lint: + use: + - STANDARD + - COMMENT_ENUM + - COMMENT_ENUM_VALUE + - COMMENT_FIELD + - COMMENT_RPC + - COMMENT_SERVICE +modules: + - path: rpc + name: buf.build/arduino/arduino-flasher-cli diff --git a/cmd/arduino-flasher-cli/daemon/daemon.go b/cmd/arduino-flasher-cli/daemon/daemon.go index f9e252f..1fef1ec 100644 --- a/cmd/arduino-flasher-cli/daemon/daemon.go +++ b/cmd/arduino-flasher-cli/daemon/daemon.go @@ -1,124 +1,125 @@ -// This file is part of arduino-flasher-cli. -// -// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-flasher-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package daemon - -import ( - "encoding/json" - "errors" - "fmt" - "net" - "os" - "strings" - "syscall" - - "github.com/arduino/arduino-flasher-cli/cmd/feedback" - "github.com/arduino/arduino-flasher-cli/cmd/i18n" - "github.com/spf13/cobra" - "google.golang.org/grpc" - - flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" -) - -func NewDaemonCommand(srv flasher.FlasherServer) *cobra.Command { - var daemonPort string - var maxGRPCRecvMsgSize int - daemonCommand := &cobra.Command{ - Use: "daemon", - Short: i18n.Tr("Run the Arduino Flasher CLI as a gRPC daemon."), - Example: " " + os.Args[0] + " daemon", - Args: cobra.NoArgs, - Run: func(cmd *cobra.Command, args []string) { - runDaemonCommand(srv, daemonPort, maxGRPCRecvMsgSize) - }, - } - - daemonCommand.Flags().StringVar(&daemonPort, - "port", "50052", - i18n.Tr("The TCP port the daemon will listen to")) - - daemonCommand.Flags().IntVar(&maxGRPCRecvMsgSize, - "max-grpc-recv-message-size", 16*1024*1024, - i18n.Tr("Sets the maximum message size in bytes the daemon can receive")) - - return daemonCommand -} - -func runDaemonCommand(srv flasher.FlasherServer, daemonPort string, maxGRPCRecvMsgSize int) { - gRPCOptions := []grpc.ServerOption{} - gRPCOptions = append(gRPCOptions, grpc.MaxRecvMsgSize(maxGRPCRecvMsgSize)) - s := grpc.NewServer(gRPCOptions...) - - // register the commands service - flasher.RegisterFlasherServer(s, srv) - - daemonIP := "127.0.0.1" - lis, err := net.Listen("tcp", fmt.Sprintf("%s:%s", daemonIP, daemonPort)) - if err != nil { - // Invalid port, such as "Foo" - var dnsError *net.DNSError - if errors.As(err, &dnsError) { - feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %[1]s. %[2]s is unknown name.", daemonPort, dnsError.Name), feedback.ErrBadTCPPortArgument) - } - // Invalid port number, such as -1 - var addrError *net.AddrError - if errors.As(err, &addrError) { - feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %[1]s. %[2]s is an invalid port.", daemonPort, addrError.Addr), feedback.ErrBadTCPPortArgument) - } - // Port is already in use - var syscallErr *os.SyscallError - if errors.As(err, &syscallErr) && errors.Is(syscallErr.Err, syscall.EADDRINUSE) { - feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %s. Address already in use.", daemonPort), feedback.ErrFailedToListenToTCPPort) - } - feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %[1]s. Unexpected error: %[2]v", daemonPort, err), feedback.ErrFailedToListenToTCPPort) - } - - // We need to retrieve the port used only if the user did not specify it - // and let the OS choose it randomly, in all other cases we already know - // which port is used. - if daemonPort == "0" { - address := lis.Addr() - split := strings.Split(address.String(), ":") - - if len(split) <= 1 { - feedback.Fatal(i18n.Tr("Invalid TCP address: port is missing"), feedback.ErrBadTCPPortArgument) - } - - daemonPort = split[1] - } - - feedback.PrintResult(daemonResult{ - IP: daemonIP, - Port: daemonPort, - }) - - if err := s.Serve(lis); err != nil { - feedback.Fatal(fmt.Sprintf("Failed to serve: %v", err), feedback.ErrFailedToListenToTCPPort) - } -} - -type daemonResult struct { - IP string - Port string -} - -func (r daemonResult) Data() interface{} { - return r -} - -func (r daemonResult) String() string { - j, _ := json.Marshal(r) - return fmt.Sprintln(i18n.Tr("Daemon is now listening on %s:%s", r.IP, r.Port)) + fmt.Sprintln(string(j)) -} +// This file is part of arduino-flasher-cli. +// +// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-flasher-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package daemon + +import ( + "encoding/json" + "errors" + "fmt" + "net" + "os" + "strings" + "syscall" + + "github.com/spf13/cobra" + "google.golang.org/grpc" + + "github.com/arduino/arduino-flasher-cli/cmd/feedback" + "github.com/arduino/arduino-flasher-cli/cmd/i18n" + + flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" +) + +func NewDaemonCommand(srv flasher.FlasherServer) *cobra.Command { + var daemonPort string + var maxGRPCRecvMsgSize int + daemonCommand := &cobra.Command{ + Use: "daemon", + Short: i18n.Tr("Run the Arduino Flasher CLI as a gRPC daemon."), + Example: " " + os.Args[0] + " daemon", + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + runDaemonCommand(srv, daemonPort, maxGRPCRecvMsgSize) + }, + } + + daemonCommand.Flags().StringVar(&daemonPort, + "port", "50052", + i18n.Tr("The TCP port the daemon will listen to")) + + daemonCommand.Flags().IntVar(&maxGRPCRecvMsgSize, + "max-grpc-recv-message-size", 16*1024*1024, + i18n.Tr("Sets the maximum message size in bytes the daemon can receive")) + + return daemonCommand +} + +func runDaemonCommand(srv flasher.FlasherServer, daemonPort string, maxGRPCRecvMsgSize int) { + gRPCOptions := []grpc.ServerOption{} + gRPCOptions = append(gRPCOptions, grpc.MaxRecvMsgSize(maxGRPCRecvMsgSize)) + s := grpc.NewServer(gRPCOptions...) + + // register the commands service + flasher.RegisterFlasherServer(s, srv) + + daemonIP := "127.0.0.1" + lis, err := net.Listen("tcp", fmt.Sprintf("%s:%s", daemonIP, daemonPort)) + if err != nil { + // Invalid port, such as "Foo" + var dnsError *net.DNSError + if errors.As(err, &dnsError) { + feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %[1]s. %[2]s is unknown name.", daemonPort, dnsError.Name), feedback.ErrBadTCPPortArgument) + } + // Invalid port number, such as -1 + var addrError *net.AddrError + if errors.As(err, &addrError) { + feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %[1]s. %[2]s is an invalid port.", daemonPort, addrError.Addr), feedback.ErrBadTCPPortArgument) + } + // Port is already in use + var syscallErr *os.SyscallError + if errors.As(err, &syscallErr) && errors.Is(syscallErr.Err, syscall.EADDRINUSE) { + feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %s. Address already in use.", daemonPort), feedback.ErrFailedToListenToTCPPort) + } + feedback.Fatal(i18n.Tr("Failed to listen on TCP port: %[1]s. Unexpected error: %[2]v", daemonPort, err), feedback.ErrFailedToListenToTCPPort) + } + + // We need to retrieve the port used only if the user did not specify it + // and let the OS choose it randomly, in all other cases we already know + // which port is used. + if daemonPort == "0" { + address := lis.Addr() + split := strings.Split(address.String(), ":") + + if len(split) <= 1 { + feedback.Fatal(i18n.Tr("Invalid TCP address: port is missing"), feedback.ErrBadTCPPortArgument) + } + + daemonPort = split[1] + } + + feedback.PrintResult(daemonResult{ + IP: daemonIP, + Port: daemonPort, + }) + + if err := s.Serve(lis); err != nil { + feedback.Fatal(fmt.Sprintf("Failed to serve: %v", err), feedback.ErrFailedToListenToTCPPort) + } +} + +type daemonResult struct { + IP string + Port string +} + +func (r daemonResult) Data() interface{} { + return r +} + +func (r daemonResult) String() string { + j, _ := json.Marshal(r) + return fmt.Sprintln(i18n.Tr("Daemon is now listening on %s:%s", r.IP, r.Port)) + fmt.Sprintln(string(j)) +} diff --git a/rpc/cc/arduino/flasher/v1/commands.pb.go b/rpc/cc/arduino/flasher/v1/commands.pb.go index eae743f..494ac7e 100644 --- a/rpc/cc/arduino/flasher/v1/commands.pb.go +++ b/rpc/cc/arduino/flasher/v1/commands.pb.go @@ -22,10 +22,11 @@ package flasher import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/rpc/cc/arduino/flasher/v1/commands_grpc.pb.go b/rpc/cc/arduino/flasher/v1/commands_grpc.pb.go index 37de904..9ed20e7 100644 --- a/rpc/cc/arduino/flasher/v1/commands_grpc.pb.go +++ b/rpc/cc/arduino/flasher/v1/commands_grpc.pb.go @@ -23,6 +23,7 @@ package flasher import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/service/service.go b/service/service.go index fcbdc3b..bd9ba05 100644 --- a/service/service.go +++ b/service/service.go @@ -1,26 +1,26 @@ -// This file is part of arduino-flasher-cli. -// -// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-flasher-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package service - -import flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" - -type flasherServerImpl struct { - flasher.UnsafeFlasherServer // Force compile error for unimplemented methods -} - -func NewFlasherServer() flasher.FlasherServer { - return &flasherServerImpl{} -} +// This file is part of arduino-flasher-cli. +// +// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-flasher-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package service + +import flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" + +type flasherServerImpl struct { + flasher.UnsafeFlasherServer // Force compile error for unimplemented methods +} + +func NewFlasherServer() flasher.FlasherServer { + return &flasherServerImpl{} +} diff --git a/service/service_list.go b/service/service_list.go index f1dba3b..6b69576 100644 --- a/service/service_list.go +++ b/service/service_list.go @@ -1,43 +1,43 @@ -// This file is part of arduino-flasher-cli. -// -// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-flasher-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package service - -import ( - "context" - - "github.com/arduino/arduino-flasher-cli/internal/updater" - flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" -) - -func (s *flasherServerImpl) List(ctx context.Context, req *flasher.ListRequest) (*flasher.ListResponse, error) { - client := updater.NewClient() - - manifest, err := client.GetInfoManifest(ctx) - if err != nil { - return nil, err - } - - resp := &flasher.ListResponse{} - for i := len(manifest.Releases) - 1; i >= 0; i-- { - latest := false - if manifest.Releases[i].Version == manifest.Latest.Version { - latest = true - } - resp.Releases = append(resp.Releases, &flasher.Release{BuildId: manifest.Releases[i].Version, Latest: latest}) - } - - return resp, nil -} +// This file is part of arduino-flasher-cli. +// +// Copyright 2025 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-flasher-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package service + +import ( + "context" + + "github.com/arduino/arduino-flasher-cli/internal/updater" + flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" +) + +func (s *flasherServerImpl) List(ctx context.Context, req *flasher.ListRequest) (*flasher.ListResponse, error) { + client := updater.NewClient() + + manifest, err := client.GetInfoManifest(ctx) + if err != nil { + return nil, err + } + + resp := &flasher.ListResponse{} + for i := len(manifest.Releases) - 1; i >= 0; i-- { + latest := false + if manifest.Releases[i].Version == manifest.Latest.Version { + latest = true + } + resp.Releases = append(resp.Releases, &flasher.Release{BuildId: manifest.Releases[i].Version, Latest: latest}) + } + + return resp, nil +}