From e4451ccd2629530ece87b4c542904ca4973a040e Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 13:31:01 -0800 Subject: [PATCH 01/15] testing ci --- .gitlab-ci.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 49b8824..939c2b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ variables: CARGO_HOME: $CI_PROJECT_DIR/.cargo CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 + TOOLCHAIN_IMAGE: $CI_REGISTRY_IMAGE/toolchain:latest # Cache dependencies between builds cache: @@ -13,10 +14,37 @@ cache: # Define stages stages: + - build-toolchain - check - test - build +.runner: &runner + tags: + - linux-x64 + +build-toolchain: + <<: *runner + stage: build-toolchain + image: docker:latest + + script: + - | + if [ "$GITLAB_CI" != "false" ]; then + echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin + docker pull $TOOLCHAIN_IMAGE:latest || true + fi + - docker build --progress=plain --cache-from $TOOLCHAIN_IMAGE:latest -t $TOOLCHAIN_IMAGE:latest -f toolchain/Dockerfile . + - | + if [ "$GITLAB_CI" != "false" ]; then + docker push $TOOLCHAIN_IMAGE:latest + fi + rules: + - if: $CI_PIPELINE_SOURCE == "push" + changes: + - toolchain/**/* + - .gitlab-ci.yml + # Check formatting and run clippy on all branches format: stage: check From 6ca450e48ae56a5f168776e6e953821ea2f9be8e Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 13:38:38 -0800 Subject: [PATCH 02/15] fixed image name --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 939c2b4..69599ab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ variables: CARGO_HOME: $CI_PROJECT_DIR/.cargo CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 - TOOLCHAIN_IMAGE: $CI_REGISTRY_IMAGE/toolchain:latest + TOOLCHAIN_IMAGE: $CI_REGISTRY_IMAGE/toolchain # Cache dependencies between builds cache: From b1a92da60af85f51804d329491c06a445a58cbda Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 13:42:30 -0800 Subject: [PATCH 03/15] fixed image name for cargo --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 69599ab..9a6285a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,11 @@ -image: kos-builder:latest - variables: CARGO_HOME: $CI_PROJECT_DIR/.cargo CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 TOOLCHAIN_IMAGE: $CI_REGISTRY_IMAGE/toolchain +image: $TOOLCHAIN_IMAGE:latest + # Cache dependencies between builds cache: paths: From 26015424af9a2124f81fd96afb61401b132b3c2e Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 13:44:15 -0800 Subject: [PATCH 04/15] recursive strategy for submodules --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a6285a..2ed7236 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ variables: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 TOOLCHAIN_IMAGE: $CI_REGISTRY_IMAGE/toolchain + GIT_SUBMODULE_STRATEGY: recursive image: $TOOLCHAIN_IMAGE:latest From 1520edd51e97e0a6025f3945f8a8b6f02430b93a Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 13:51:05 -0800 Subject: [PATCH 05/15] Pulled required google protos out of submodule --- .gitmodules | 3 - proto/googleapis | 1 - proto/googleapis/google/api/annotations.proto | 31 ++ proto/googleapis/google/api/client.proto | 462 ++++++++++++++++++ proto/googleapis/google/api/http.proto | 371 ++++++++++++++ .../googleapis/google/api/launch_stage.proto | 72 +++ .../google/longrunning/operations.proto | 247 ++++++++++ proto/googleapis/google/rpc/status.proto | 49 ++ 8 files changed, 1232 insertions(+), 4 deletions(-) delete mode 160000 proto/googleapis create mode 100644 proto/googleapis/google/api/annotations.proto create mode 100644 proto/googleapis/google/api/client.proto create mode 100644 proto/googleapis/google/api/http.proto create mode 100644 proto/googleapis/google/api/launch_stage.proto create mode 100644 proto/googleapis/google/longrunning/operations.proto create mode 100644 proto/googleapis/google/rpc/status.proto diff --git a/.gitmodules b/.gitmodules index c59ad0d..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "protos/googleapis"] - path = proto/googleapis - url = https://github.com/googleapis/googleapis.git diff --git a/proto/googleapis b/proto/googleapis deleted file mode 160000 index c72f219..0000000 --- a/proto/googleapis +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c72f219fedbb57d3f83c10550e135c4824b670eb diff --git a/proto/googleapis/google/api/annotations.proto b/proto/googleapis/google/api/annotations.proto new file mode 100644 index 0000000..84c4816 --- /dev/null +++ b/proto/googleapis/google/api/annotations.proto @@ -0,0 +1,31 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/api/http.proto"; +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "AnnotationsProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.MethodOptions { + // See `HttpRule`. + HttpRule http = 72295728; +} diff --git a/proto/googleapis/google/api/client.proto b/proto/googleapis/google/api/client.proto new file mode 100644 index 0000000..6003be5 --- /dev/null +++ b/proto/googleapis/google/api/client.proto @@ -0,0 +1,462 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/api/launch_stage.proto"; +import "google/protobuf/descriptor.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "ClientProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.MethodOptions { + // A definition of a client library method signature. + // + // In client libraries, each proto RPC corresponds to one or more methods + // which the end user is able to call, and calls the underlying RPC. + // Normally, this method receives a single argument (a struct or instance + // corresponding to the RPC request object). Defining this field will + // add one or more overloads providing flattened or simpler method signatures + // in some languages. + // + // The fields on the method signature are provided as a comma-separated + // string. + // + // For example, the proto RPC and annotation: + // + // rpc CreateSubscription(CreateSubscriptionRequest) + // returns (Subscription) { + // option (google.api.method_signature) = "name,topic"; + // } + // + // Would add the following Java overload (in addition to the method accepting + // the request object): + // + // public final Subscription createSubscription(String name, String topic) + // + // The following backwards-compatibility guidelines apply: + // + // * Adding this annotation to an unannotated method is backwards + // compatible. + // * Adding this annotation to a method which already has existing + // method signature annotations is backwards compatible if and only if + // the new method signature annotation is last in the sequence. + // * Modifying or removing an existing method signature annotation is + // a breaking change. + // * Re-ordering existing method signature annotations is a breaking + // change. + repeated string method_signature = 1051; +} + +extend google.protobuf.ServiceOptions { + // The hostname for this service. + // This should be specified with no prefix or protocol. + // + // Example: + // + // service Foo { + // option (google.api.default_host) = "foo.googleapi.com"; + // ... + // } + string default_host = 1049; + + // OAuth scopes needed for the client. + // + // Example: + // + // service Foo { + // option (google.api.oauth_scopes) = \ + // "https://www.googleapis.com/auth/cloud-platform"; + // ... + // } + // + // If there is more than one scope, use a comma-separated string: + // + // Example: + // + // service Foo { + // option (google.api.oauth_scopes) = \ + // "https://www.googleapis.com/auth/cloud-platform," + // "https://www.googleapis.com/auth/monitoring"; + // ... + // } + string oauth_scopes = 1050; + + // The API version of this service, which should be sent by version-aware + // clients to the service. This allows services to abide by the schema and + // behavior of the service at the time this API version was deployed. + // The format of the API version must be treated as opaque by clients. + // Services may use a format with an apparent structure, but clients must + // not rely on this to determine components within an API version, or attempt + // to construct other valid API versions. Note that this is for upcoming + // functionality and may not be implemented for all services. + // + // Example: + // + // service Foo { + // option (google.api.api_version) = "v1_20230821_preview"; + // } + string api_version = 525000001; +} + +// Required information for every language. +message CommonLanguageSettings { + // Link to automatically generated reference documentation. Example: + // https://cloud.google.com/nodejs/docs/reference/asset/latest + string reference_docs_uri = 1 [deprecated = true]; + + // The destination where API teams want this client library to be published. + repeated ClientLibraryDestination destinations = 2; + + // Configuration for which RPCs should be generated in the GAPIC client. + SelectiveGapicGeneration selective_gapic_generation = 3; +} + +// Details about how and where to publish client libraries. +message ClientLibrarySettings { + // Version of the API to apply these settings to. This is the full protobuf + // package for the API, ending in the version element. + // Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1". + string version = 1; + + // Launch stage of this version of the API. + LaunchStage launch_stage = 2; + + // When using transport=rest, the client request will encode enums as + // numbers rather than strings. + bool rest_numeric_enums = 3; + + // Settings for legacy Java features, supported in the Service YAML. + JavaSettings java_settings = 21; + + // Settings for C++ client libraries. + CppSettings cpp_settings = 22; + + // Settings for PHP client libraries. + PhpSettings php_settings = 23; + + // Settings for Python client libraries. + PythonSettings python_settings = 24; + + // Settings for Node client libraries. + NodeSettings node_settings = 25; + + // Settings for .NET client libraries. + DotnetSettings dotnet_settings = 26; + + // Settings for Ruby client libraries. + RubySettings ruby_settings = 27; + + // Settings for Go client libraries. + GoSettings go_settings = 28; +} + +// This message configures the settings for publishing [Google Cloud Client +// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries) +// generated from the service config. +message Publishing { + // A list of API method settings, e.g. the behavior for methods that use the + // long-running operation pattern. + repeated MethodSettings method_settings = 2; + + // Link to a *public* URI where users can report issues. Example: + // https://issuetracker.google.com/issues/new?component=190865&template=1161103 + string new_issue_uri = 101; + + // Link to product home page. Example: + // https://cloud.google.com/asset-inventory/docs/overview + string documentation_uri = 102; + + // Used as a tracking tag when collecting data about the APIs developer + // relations artifacts like docs, packages delivered to package managers, + // etc. Example: "speech". + string api_short_name = 103; + + // GitHub label to apply to issues and pull requests opened for this API. + string github_label = 104; + + // GitHub teams to be added to CODEOWNERS in the directory in GitHub + // containing source code for the client libraries for this API. + repeated string codeowner_github_teams = 105; + + // A prefix used in sample code when demarking regions to be included in + // documentation. + string doc_tag_prefix = 106; + + // For whom the client library is being published. + ClientLibraryOrganization organization = 107; + + // Client library settings. If the same version string appears multiple + // times in this list, then the last one wins. Settings from earlier + // settings with the same version string are discarded. + repeated ClientLibrarySettings library_settings = 109; + + // Optional link to proto reference documentation. Example: + // https://cloud.google.com/pubsub/lite/docs/reference/rpc + string proto_reference_documentation_uri = 110; + + // Optional link to REST reference documentation. Example: + // https://cloud.google.com/pubsub/lite/docs/reference/rest + string rest_reference_documentation_uri = 111; +} + +// Settings for Java client libraries. +message JavaSettings { + // The package name to use in Java. Clobbers the java_package option + // set in the protobuf. This should be used **only** by APIs + // who have already set the language_settings.java.package_name" field + // in gapic.yaml. API teams should use the protobuf java_package option + // where possible. + // + // Example of a YAML configuration:: + // + // publishing: + // java_settings: + // library_package: com.google.cloud.pubsub.v1 + string library_package = 1; + + // Configure the Java class name to use instead of the service's for its + // corresponding generated GAPIC client. Keys are fully-qualified + // service names as they appear in the protobuf (including the full + // the language_settings.java.interface_names" field in gapic.yaml. API + // teams should otherwise use the service name as it appears in the + // protobuf. + // + // Example of a YAML configuration:: + // + // publishing: + // java_settings: + // service_class_names: + // - google.pubsub.v1.Publisher: TopicAdmin + // - google.pubsub.v1.Subscriber: SubscriptionAdmin + map service_class_names = 2; + + // Some settings. + CommonLanguageSettings common = 3; +} + +// Settings for C++ client libraries. +message CppSettings { + // Some settings. + CommonLanguageSettings common = 1; +} + +// Settings for Php client libraries. +message PhpSettings { + // Some settings. + CommonLanguageSettings common = 1; +} + +// Settings for Python client libraries. +message PythonSettings { + // Experimental features to be included during client library generation. + // These fields will be deprecated once the feature graduates and is enabled + // by default. + message ExperimentalFeatures { + // Enables generation of asynchronous REST clients if `rest` transport is + // enabled. By default, asynchronous REST clients will not be generated. + // This feature will be enabled by default 1 month after launching the + // feature in preview packages. + bool rest_async_io_enabled = 1; + + // Enables generation of protobuf code using new types that are more + // Pythonic which are included in `protobuf>=5.29.x`. This feature will be + // enabled by default 1 month after launching the feature in preview + // packages. + bool protobuf_pythonic_types_enabled = 2; + } + + // Some settings. + CommonLanguageSettings common = 1; + + // Experimental features to be included during client library generation. + ExperimentalFeatures experimental_features = 2; +} + +// Settings for Node client libraries. +message NodeSettings { + // Some settings. + CommonLanguageSettings common = 1; +} + +// Settings for Dotnet client libraries. +message DotnetSettings { + // Some settings. + CommonLanguageSettings common = 1; + + // Map from original service names to renamed versions. + // This is used when the default generated types + // would cause a naming conflict. (Neither name is + // fully-qualified.) + // Example: Subscriber to SubscriberServiceApi. + map renamed_services = 2; + + // Map from full resource types to the effective short name + // for the resource. This is used when otherwise resource + // named from different services would cause naming collisions. + // Example entry: + // "datalabeling.googleapis.com/Dataset": "DataLabelingDataset" + map renamed_resources = 3; + + // List of full resource types to ignore during generation. + // This is typically used for API-specific Location resources, + // which should be handled by the generator as if they were actually + // the common Location resources. + // Example entry: "documentai.googleapis.com/Location" + repeated string ignored_resources = 4; + + // Namespaces which must be aliased in snippets due to + // a known (but non-generator-predictable) naming collision + repeated string forced_namespace_aliases = 5; + + // Method signatures (in the form "service.method(signature)") + // which are provided separately, so shouldn't be generated. + // Snippets *calling* these methods are still generated, however. + repeated string handwritten_signatures = 6; +} + +// Settings for Ruby client libraries. +message RubySettings { + // Some settings. + CommonLanguageSettings common = 1; +} + +// Settings for Go client libraries. +message GoSettings { + // Some settings. + CommonLanguageSettings common = 1; +} + +// Describes the generator configuration for a method. +message MethodSettings { + // Describes settings to use when generating API methods that use the + // long-running operation pattern. + // All default values below are from those used in the client library + // generators (e.g. + // [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)). + message LongRunning { + // Initial delay after which the first poll request will be made. + // Default value: 5 seconds. + google.protobuf.Duration initial_poll_delay = 1; + + // Multiplier to gradually increase delay between subsequent polls until it + // reaches max_poll_delay. + // Default value: 1.5. + float poll_delay_multiplier = 2; + + // Maximum time between two subsequent poll requests. + // Default value: 45 seconds. + google.protobuf.Duration max_poll_delay = 3; + + // Total polling timeout. + // Default value: 5 minutes. + google.protobuf.Duration total_poll_timeout = 4; + } + + // The fully qualified name of the method, for which the options below apply. + // This is used to find the method to apply the options. + // + // Example: + // + // publishing: + // method_settings: + // - selector: google.storage.control.v2.StorageControl.CreateFolder + // # method settings for CreateFolder... + string selector = 1; + + // Describes settings to use for long-running operations when generating + // API methods for RPCs. Complements RPCs that use the annotations in + // google/longrunning/operations.proto. + // + // Example of a YAML configuration:: + // + // publishing: + // method_settings: + // - selector: google.cloud.speech.v2.Speech.BatchRecognize + // long_running: + // initial_poll_delay: 60s # 1 minute + // poll_delay_multiplier: 1.5 + // max_poll_delay: 360s # 6 minutes + // total_poll_timeout: 54000s # 90 minutes + LongRunning long_running = 2; + + // List of top-level fields of the request message, that should be + // automatically populated by the client libraries based on their + // (google.api.field_info).format. Currently supported format: UUID4. + // + // Example of a YAML configuration: + // + // publishing: + // method_settings: + // - selector: google.example.v1.ExampleService.CreateExample + // auto_populated_fields: + // - request_id + repeated string auto_populated_fields = 3; +} + +// The organization for which the client libraries are being published. +// Affects the url where generated docs are published, etc. +enum ClientLibraryOrganization { + // Not useful. + CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED = 0; + + // Google Cloud Platform Org. + CLOUD = 1; + + // Ads (Advertising) Org. + ADS = 2; + + // Photos Org. + PHOTOS = 3; + + // Street View Org. + STREET_VIEW = 4; + + // Shopping Org. + SHOPPING = 5; + + // Geo Org. + GEO = 6; + + // Generative AI - https://developers.generativeai.google + GENERATIVE_AI = 7; +} + +// To where should client libraries be published? +enum ClientLibraryDestination { + // Client libraries will neither be generated nor published to package + // managers. + CLIENT_LIBRARY_DESTINATION_UNSPECIFIED = 0; + + // Generate the client library in a repo under github.com/googleapis, + // but don't publish it to package managers. + GITHUB = 10; + + // Publish the library to package managers like nuget.org and npmjs.com. + PACKAGE_MANAGER = 20; +} + +// This message is used to configure the generation of a subset of the RPCs in +// a service for client libraries. +message SelectiveGapicGeneration { + // An allowlist of the fully qualified names of RPCs that should be included + // on public client surfaces. + repeated string methods = 1; +} diff --git a/proto/googleapis/google/api/http.proto b/proto/googleapis/google/api/http.proto new file mode 100644 index 0000000..e327037 --- /dev/null +++ b/proto/googleapis/google/api/http.proto @@ -0,0 +1,371 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "HttpProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// Defines the HTTP configuration for an API service. It contains a list of +// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method +// to one or more HTTP REST API methods. +message Http { + // A list of HTTP configuration rules that apply to individual API methods. + // + // **NOTE:** All service configuration rules follow "last one wins" order. + repeated HttpRule rules = 1; + + // When set to true, URL path parameters will be fully URI-decoded except in + // cases of single segment matches in reserved expansion, where "%2F" will be + // left encoded. + // + // The default behavior is to not decode RFC 6570 reserved characters in multi + // segment matches. + bool fully_decode_reserved_expansion = 2; +} + +// gRPC Transcoding +// +// gRPC Transcoding is a feature for mapping between a gRPC method and one or +// more HTTP REST endpoints. It allows developers to build a single API service +// that supports both gRPC APIs and REST APIs. Many systems, including [Google +// APIs](https://github.com/googleapis/googleapis), +// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC +// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), +// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature +// and use it for large scale production services. +// +// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies +// how different portions of the gRPC request message are mapped to the URL +// path, URL query parameters, and HTTP request body. It also controls how the +// gRPC response message is mapped to the HTTP response body. `HttpRule` is +// typically specified as an `google.api.http` annotation on the gRPC method. +// +// Each mapping specifies a URL path template and an HTTP method. The path +// template may refer to one or more fields in the gRPC request message, as long +// as each field is a non-repeated field with a primitive (non-message) type. +// The path template controls how fields of the request message are mapped to +// the URL path. +// +// Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/{name=messages/*}" +// }; +// } +// } +// message GetMessageRequest { +// string name = 1; // Mapped to URL path. +// } +// message Message { +// string text = 1; // The resource content. +// } +// +// This enables an HTTP REST to gRPC mapping as below: +// +// - HTTP: `GET /v1/messages/123456` +// - gRPC: `GetMessage(name: "messages/123456")` +// +// Any fields in the request message which are not bound by the path template +// automatically become HTTP query parameters if there is no HTTP request body. +// For example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get:"/v1/messages/{message_id}" +// }; +// } +// } +// message GetMessageRequest { +// message SubMessage { +// string subfield = 1; +// } +// string message_id = 1; // Mapped to URL path. +// int64 revision = 2; // Mapped to URL query parameter `revision`. +// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. +// } +// +// This enables a HTTP JSON to RPC mapping as below: +// +// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo` +// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub: +// SubMessage(subfield: "foo"))` +// +// Note that fields which are mapped to URL query parameters must have a +// primitive type or a repeated primitive type or a non-repeated message type. +// In the case of a repeated type, the parameter can be repeated in the URL +// as `...?param=A¶m=B`. In the case of a message type, each field of the +// message is mapped to a separate parameter, such as +// `...?foo.a=A&foo.b=B&foo.c=C`. +// +// For HTTP methods that allow a request body, the `body` field +// specifies the mapping. Consider a REST update method on the +// message resource collection: +// +// service Messaging { +// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "message" +// }; +// } +// } +// message UpdateMessageRequest { +// string message_id = 1; // mapped to the URL +// Message message = 2; // mapped to the body +// } +// +// The following HTTP JSON to RPC mapping is enabled, where the +// representation of the JSON in the request body is determined by +// protos JSON encoding: +// +// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })` +// +// The special name `*` can be used in the body mapping to define that +// every field not bound by the path template should be mapped to the +// request body. This enables the following alternative definition of +// the update method: +// +// service Messaging { +// rpc UpdateMessage(Message) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "*" +// }; +// } +// } +// message Message { +// string message_id = 1; +// string text = 2; +// } +// +// +// The following HTTP JSON to RPC mapping is enabled: +// +// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")` +// +// Note that when using `*` in the body mapping, it is not possible to +// have HTTP parameters, as all fields not bound by the path end in +// the body. This makes this option more rarely used in practice when +// defining REST APIs. The common usage of `*` is in custom methods +// which don't use the URL at all for transferring data. +// +// It is possible to define multiple HTTP methods for one RPC by using +// the `additional_bindings` option. Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/messages/{message_id}" +// additional_bindings { +// get: "/v1/users/{user_id}/messages/{message_id}" +// } +// }; +// } +// } +// message GetMessageRequest { +// string message_id = 1; +// string user_id = 2; +// } +// +// This enables the following two alternative HTTP JSON to RPC mappings: +// +// - HTTP: `GET /v1/messages/123456` +// - gRPC: `GetMessage(message_id: "123456")` +// +// - HTTP: `GET /v1/users/me/messages/123456` +// - gRPC: `GetMessage(user_id: "me" message_id: "123456")` +// +// Rules for HTTP mapping +// +// 1. Leaf request fields (recursive expansion nested messages in the request +// message) are classified into three categories: +// - Fields referred by the path template. They are passed via the URL path. +// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They +// are passed via the HTTP +// request body. +// - All other fields are passed via the URL query parameters, and the +// parameter name is the field path in the request message. A repeated +// field can be represented as multiple query parameters under the same +// name. +// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL +// query parameter, all fields +// are passed via URL path and HTTP request body. +// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP +// request body, all +// fields are passed via URL path and URL query parameters. +// +// Path template syntax +// +// Template = "/" Segments [ Verb ] ; +// Segments = Segment { "/" Segment } ; +// Segment = "*" | "**" | LITERAL | Variable ; +// Variable = "{" FieldPath [ "=" Segments ] "}" ; +// FieldPath = IDENT { "." IDENT } ; +// Verb = ":" LITERAL ; +// +// The syntax `*` matches a single URL path segment. The syntax `**` matches +// zero or more URL path segments, which must be the last part of the URL path +// except the `Verb`. +// +// The syntax `Variable` matches part of the URL path as specified by its +// template. A variable template must not contain other variables. If a variable +// matches a single path segment, its template may be omitted, e.g. `{var}` +// is equivalent to `{var=*}`. +// +// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` +// contains any reserved character, such characters should be percent-encoded +// before the matching. +// +// If a variable contains exactly one path segment, such as `"{var}"` or +// `"{var=*}"`, when such a variable is expanded into a URL path on the client +// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The +// server side does the reverse decoding. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{var}`. +// +// If a variable contains multiple path segments, such as `"{var=foo/*}"` +// or `"{var=**}"`, when such a variable is expanded into a URL path on the +// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. +// The server side does the reverse decoding, except "%2F" and "%2f" are left +// unchanged. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{+var}`. +// +// Using gRPC API Service Configuration +// +// gRPC API Service Configuration (service config) is a configuration language +// for configuring a gRPC service to become a user-facing product. The +// service config is simply the YAML representation of the `google.api.Service` +// proto message. +// +// As an alternative to annotating your proto file, you can configure gRPC +// transcoding in your service config YAML files. You do this by specifying a +// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same +// effect as the proto annotation. This can be particularly useful if you +// have a proto that is reused in multiple services. Note that any transcoding +// specified in the service config will override any matching transcoding +// configuration in the proto. +// +// The following example selects a gRPC method and applies an `HttpRule` to it: +// +// http: +// rules: +// - selector: example.v1.Messaging.GetMessage +// get: /v1/messages/{message_id}/{sub.subfield} +// +// Special notes +// +// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the +// proto to JSON conversion must follow the [proto3 +// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). +// +// While the single segment variable follows the semantics of +// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String +// Expansion, the multi segment variable **does not** follow RFC 6570 Section +// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion +// does not expand special characters like `?` and `#`, which would lead +// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding +// for multi segment variables. +// +// The path variables **must not** refer to any repeated or mapped field, +// because client libraries are not capable of handling such variable expansion. +// +// The path variables **must not** capture the leading "/" character. The reason +// is that the most common use case "{var}" does not capture the leading "/" +// character. For consistency, all path variables must share the same behavior. +// +// Repeated message fields must not be mapped to URL query parameters, because +// no client library can support such complicated mapping. +// +// If an API needs to use a JSON array for request or response body, it can map +// the request or response body to a repeated field. However, some gRPC +// Transcoding implementations may not support this feature. +message HttpRule { + // Selects a method to which this rule applies. + // + // Refer to [selector][google.api.DocumentationRule.selector] for syntax + // details. + string selector = 1; + + // Determines the URL pattern is matched by this rules. This pattern can be + // used with any of the {get|put|post|delete|patch} methods. A custom method + // can be defined using the 'custom' field. + oneof pattern { + // Maps to HTTP GET. Used for listing and getting information about + // resources. + string get = 2; + + // Maps to HTTP PUT. Used for replacing a resource. + string put = 3; + + // Maps to HTTP POST. Used for creating a resource or performing an action. + string post = 4; + + // Maps to HTTP DELETE. Used for deleting a resource. + string delete = 5; + + // Maps to HTTP PATCH. Used for updating a resource. + string patch = 6; + + // The custom pattern is used for specifying an HTTP method that is not + // included in the `pattern` field, such as HEAD, or "*" to leave the + // HTTP method unspecified for this rule. The wild-card rule is useful + // for services that provide content to Web (HTML) clients. + CustomHttpPattern custom = 8; + } + + // The name of the request field whose value is mapped to the HTTP request + // body, or `*` for mapping all request fields not captured by the path + // pattern to the HTTP body, or omitted for not having any HTTP request body. + // + // NOTE: the referred field must be present at the top-level of the request + // message type. + string body = 7; + + // Optional. The name of the response field whose value is mapped to the HTTP + // response body. When omitted, the entire response message will be used + // as the HTTP response body. + // + // NOTE: The referred field must be present at the top-level of the response + // message type. + string response_body = 12; + + // Additional HTTP bindings for the selector. Nested bindings must + // not contain an `additional_bindings` field themselves (that is, + // the nesting may only be one level deep). + repeated HttpRule additional_bindings = 11; +} + +// A custom pattern is used for defining custom HTTP verb. +message CustomHttpPattern { + // The name of this custom HTTP verb. + string kind = 1; + + // The path matched by this custom verb. + string path = 2; +} diff --git a/proto/googleapis/google/api/launch_stage.proto b/proto/googleapis/google/api/launch_stage.proto new file mode 100644 index 0000000..9863fc2 --- /dev/null +++ b/proto/googleapis/google/api/launch_stage.proto @@ -0,0 +1,72 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +option go_package = "google.golang.org/genproto/googleapis/api;api"; +option java_multiple_files = true; +option java_outer_classname = "LaunchStageProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// The launch stage as defined by [Google Cloud Platform +// Launch Stages](https://cloud.google.com/terms/launch-stages). +enum LaunchStage { + // Do not use this default value. + LAUNCH_STAGE_UNSPECIFIED = 0; + + // The feature is not yet implemented. Users can not use it. + UNIMPLEMENTED = 6; + + // Prelaunch features are hidden from users and are only visible internally. + PRELAUNCH = 7; + + // Early Access features are limited to a closed group of testers. To use + // these features, you must sign up in advance and sign a Trusted Tester + // agreement (which includes confidentiality provisions). These features may + // be unstable, changed in backward-incompatible ways, and are not + // guaranteed to be released. + EARLY_ACCESS = 1; + + // Alpha is a limited availability test for releases before they are cleared + // for widespread use. By Alpha, all significant design issues are resolved + // and we are in the process of verifying functionality. Alpha customers + // need to apply for access, agree to applicable terms, and have their + // projects allowlisted. Alpha releases don't have to be feature complete, + // no SLAs are provided, and there are no technical support obligations, but + // they will be far enough along that customers can actually use them in + // test environments or for limited-use tests -- just like they would in + // normal production cases. + ALPHA = 2; + + // Beta is the point at which we are ready to open a release for any + // customer to use. There are no SLA or technical support obligations in a + // Beta release. Products will be complete from a feature perspective, but + // may have some open outstanding issues. Beta releases are suitable for + // limited production use cases. + BETA = 3; + + // GA features are open to all developers and are considered stable and + // fully qualified for production use. + GA = 4; + + // Deprecated features are scheduled to be shut down and removed. For more + // information, see the "Deprecation Policy" section of our [Terms of + // Service](https://cloud.google.com/terms/) + // and the [Google Cloud Platform Subject to the Deprecation + // Policy](https://cloud.google.com/terms/deprecation) documentation. + DEPRECATED = 5; +} diff --git a/proto/googleapis/google/longrunning/operations.proto b/proto/googleapis/google/longrunning/operations.proto new file mode 100644 index 0000000..be8880b --- /dev/null +++ b/proto/googleapis/google/longrunning/operations.proto @@ -0,0 +1,247 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.longrunning; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/rpc/status.proto"; +import "google/protobuf/descriptor.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.LongRunning"; +option go_package = "cloud.google.com/go/longrunning/autogen/longrunningpb;longrunningpb"; +option java_multiple_files = true; +option java_outer_classname = "OperationsProto"; +option java_package = "com.google.longrunning"; +option php_namespace = "Google\\LongRunning"; + +extend google.protobuf.MethodOptions { + // Additional information regarding long-running operations. + // In particular, this specifies the types that are returned from + // long-running operations. + // + // Required for methods that return `google.longrunning.Operation`; invalid + // otherwise. + google.longrunning.OperationInfo operation_info = 1049; +} + +// Manages long-running operations with an API service. +// +// When an API method normally takes long time to complete, it can be designed +// to return [Operation][google.longrunning.Operation] to the client, and the client can use this +// interface to receive the real response asynchronously by polling the +// operation resource, or pass the operation resource to another API (such as +// Google Cloud Pub/Sub API) to receive the response. Any API service that +// returns long-running operations should implement the `Operations` interface +// so developers can have a consistent client experience. +service Operations { + option (google.api.default_host) = "longrunning.googleapis.com"; + + // Lists operations that match the specified filter in the request. If the + // server doesn't support this method, it returns `UNIMPLEMENTED`. + // + // NOTE: the `name` binding allows API services to override the binding + // to use different resource name schemes, such as `users/*/operations`. To + // override the binding, API services can add a binding such as + // `"/v1/{name=users/*}/operations"` to their service configuration. + // For backwards compatibility, the default name includes the operations + // collection id, however overriding users must ensure the name binding + // is the parent resource, without the operations collection id. + rpc ListOperations(ListOperationsRequest) returns (ListOperationsResponse) { + option (google.api.http) = { + get: "/v1/{name=operations}" + }; + option (google.api.method_signature) = "name,filter"; + } + + // Gets the latest state of a long-running operation. Clients can use this + // method to poll the operation result at intervals as recommended by the API + // service. + rpc GetOperation(GetOperationRequest) returns (Operation) { + option (google.api.http) = { + get: "/v1/{name=operations/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes a long-running operation. This method indicates that the client is + // no longer interested in the operation result. It does not cancel the + // operation. If the server doesn't support this method, it returns + // `google.rpc.Code.UNIMPLEMENTED`. + rpc DeleteOperation(DeleteOperationRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=operations/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Starts asynchronous cancellation on a long-running operation. The server + // makes a best effort to cancel the operation, but success is not + // guaranteed. If the server doesn't support this method, it returns + // `google.rpc.Code.UNIMPLEMENTED`. Clients can use + // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + // other methods to check whether the cancellation succeeded or whether the + // operation completed despite cancellation. On successful cancellation, + // the operation is not deleted; instead, it becomes an operation with + // an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + // corresponding to `Code.CANCELLED`. + rpc CancelOperation(CancelOperationRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=operations/**}:cancel" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Waits until the specified long-running operation is done or reaches at most + // a specified timeout, returning the latest state. If the operation is + // already done, the latest state is immediately returned. If the timeout + // specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + // timeout is used. If the server does not support this method, it returns + // `google.rpc.Code.UNIMPLEMENTED`. + // Note that this method is on a best-effort basis. It may return the latest + // state before the specified timeout (including immediately), meaning even an + // immediate response is no guarantee that the operation is done. + rpc WaitOperation(WaitOperationRequest) returns (Operation) { + } +} + +// This resource represents a long-running operation that is the result of a +// network API call. +message Operation { + // The server-assigned name, which is only unique within the same service that + // originally returns it. If you use the default HTTP mapping, the + // `name` should be a resource name ending with `operations/{unique_id}`. + string name = 1; + + // Service-specific metadata associated with the operation. It typically + // contains progress information and common metadata such as create time. + // Some services might not provide such metadata. Any method that returns a + // long-running operation should document the metadata type, if any. + google.protobuf.Any metadata = 2; + + // If the value is `false`, it means the operation is still in progress. + // If `true`, the operation is completed, and either `error` or `response` is + // available. + bool done = 3; + + // The operation result, which can be either an `error` or a valid `response`. + // If `done` == `false`, neither `error` nor `response` is set. + // If `done` == `true`, exactly one of `error` or `response` is set. + oneof result { + // The error result of the operation in case of failure or cancellation. + google.rpc.Status error = 4; + + // The normal response of the operation in case of success. If the original + // method returns no data on success, such as `Delete`, the response is + // `google.protobuf.Empty`. If the original method is standard + // `Get`/`Create`/`Update`, the response should be the resource. For other + // methods, the response should have the type `XxxResponse`, where `Xxx` + // is the original method name. For example, if the original method name + // is `TakeSnapshot()`, the inferred response type is + // `TakeSnapshotResponse`. + google.protobuf.Any response = 5; + } +} + +// The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation]. +message GetOperationRequest { + // The name of the operation resource. + string name = 1; +} + +// The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. +message ListOperationsRequest { + // The name of the operation's parent resource. + string name = 4; + + // The standard list filter. + string filter = 1; + + // The standard list page size. + int32 page_size = 2; + + // The standard list page token. + string page_token = 3; +} + +// The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. +message ListOperationsResponse { + // A list of operations that matches the specified filter in the request. + repeated Operation operations = 1; + + // The standard List next-page token. + string next_page_token = 2; +} + +// The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]. +message CancelOperationRequest { + // The name of the operation resource to be cancelled. + string name = 1; +} + +// The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation]. +message DeleteOperationRequest { + // The name of the operation resource to be deleted. + string name = 1; +} + +// The request message for [Operations.WaitOperation][google.longrunning.Operations.WaitOperation]. +message WaitOperationRequest { + // The name of the operation resource to wait on. + string name = 1; + + // The maximum duration to wait before timing out. If left blank, the wait + // will be at most the time permitted by the underlying HTTP/RPC protocol. + // If RPC context deadline is also specified, the shorter one will be used. + google.protobuf.Duration timeout = 2; +} + +// A message representing the message types used by a long-running operation. +// +// Example: +// +// rpc LongRunningRecognize(LongRunningRecognizeRequest) +// returns (google.longrunning.Operation) { +// option (google.longrunning.operation_info) = { +// response_type: "LongRunningRecognizeResponse" +// metadata_type: "LongRunningRecognizeMetadata" +// }; +// } +message OperationInfo { + // Required. The message name of the primary return type for this + // long-running operation. + // This type will be used to deserialize the LRO's response. + // + // If the response is in a different package from the rpc, a fully-qualified + // message name must be used (e.g. `google.protobuf.Struct`). + // + // Note: Altering this value constitutes a breaking change. + string response_type = 1; + + // Required. The message name of the metadata type for this long-running + // operation. + // + // If the response is in a different package from the rpc, a fully-qualified + // message name must be used (e.g. `google.protobuf.Struct`). + // + // Note: Altering this value constitutes a breaking change. + string metadata_type = 2; +} diff --git a/proto/googleapis/google/rpc/status.proto b/proto/googleapis/google/rpc/status.proto new file mode 100644 index 0000000..90b70dd --- /dev/null +++ b/proto/googleapis/google/rpc/status.proto @@ -0,0 +1,49 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.rpc; + +import "google/protobuf/any.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; +option java_multiple_files = true; +option java_outer_classname = "StatusProto"; +option java_package = "com.google.rpc"; +option objc_class_prefix = "RPC"; + +// The `Status` type defines a logical error model that is suitable for +// different programming environments, including REST APIs and RPC APIs. It is +// used by [gRPC](https://github.com/grpc). Each `Status` message contains +// three pieces of data: error code, error message, and error details. +// +// You can find out more about this error model and how to work with it in the +// [API Design Guide](https://cloud.google.com/apis/design/errors). +message Status { + // The status code, which should be an enum value of + // [google.rpc.Code][google.rpc.Code]. + int32 code = 1; + + // A developer-facing error message, which should be in English. Any + // user-facing error message should be localized and sent in the + // [google.rpc.Status.details][google.rpc.Status.details] field, or localized + // by the client. + string message = 2; + + // A list of messages that carry the error details. There is a common set of + // message types for APIs to use. + repeated google.protobuf.Any details = 3; +} From fb9d6b7a3b0ad9929ff8e5fc5a901a2bde67402d Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 13:52:01 -0800 Subject: [PATCH 06/15] fixed cargo test for now --- .gitlab-ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ed7236..6a84bc7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -67,11 +67,9 @@ test: script: - | if [ "$GITLAB_CI" != "false" ]; then - # CI-specific test commands - cargo test --all-features --verbose + cargo test -F stub --verbose else - # Local test commands - cargo test + cargo test -F stub fi rules: - when: always From cf842269a17d1a61d03e02ff3bc9cf36e3cea089 Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 13:54:41 -0800 Subject: [PATCH 07/15] added manual artifacts build --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6a84bc7..3d7b541 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -86,6 +86,8 @@ test: - target/$TARGET/release/daemon rules: - if: $CI_COMMIT_TAG + when: always + - when: manual # Linux x86_64 build-linux-x86_64-stub-release: From e07089fc45a263e9fc62a537c082910aaf33989b Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 14:03:25 -0800 Subject: [PATCH 08/15] fixing? build for x64 --- Cross.toml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Cross.toml b/Cross.toml index a13245a..01e03c9 100644 --- a/Cross.toml +++ b/Cross.toml @@ -3,4 +3,11 @@ image = "ubuntu:24.04" pre-build = [ "apt-get update", "apt-get install -y protobuf-compiler gcc-aarch64-linux-gnu g++-aarch64-linux-gnu build-essential" -] \ No newline at end of file +] + +[target.x86_64-unknown-linux-gnu] +image = "ubuntu:24.04" +pre-build = [ + "apt-get update", + "apt-get install -y protobuf-compiler build-essential" +] From 74a2b2da58c78b841992c02a2148a81e2a379996 Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 14:36:13 -0800 Subject: [PATCH 09/15] README, rustfmt checks --- .gitlab-ci.yml | 4 +++- README.md | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3d7b541..9c576cd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,9 +50,10 @@ build-toolchain: format: stage: check script: - - cargo fmt -- --check + - cargo fmt --all -- --check rules: - when: always + allow_failure: true clippy: stage: check @@ -60,6 +61,7 @@ clippy: - cargo clippy -- -D warnings rules: - when: always + allow_failure: true # Test all features test: diff --git a/README.md b/README.md index 04d7283..76612ee 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,39 @@ # K-Scale OS Welcome to the K-Scale Operating System! + +## Building + +### Prerequisites + +- `cross` toolchain + +### Native build +Native build with stub features: +```bash +cargo build --features stub +``` + +### Cross build +Cross build for kbot: +```bash +cross build --release --target aarch64-unknown-linux-gnu --features kscale_pro +``` + +## Running + +```bash +RUST_LOG=debug cargo run --features stub +``` + +## Contributing +- Use `cargo fmt --all` to format the code. +- Use `cargo clippy` to check for lint errors. +- Use `cargo test` to run the tests. +- Use `tracing` for logging. +- Use `eyre` to handle errors. +- No `unwrap()` or `expect()`. + +## License + +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. From cb73951db12da40e60bc800f62fbfc5e2937452a Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 14:52:22 -0800 Subject: [PATCH 10/15] preparing for publish --- daemon/Cargo.toml | 29 ++++++++++++++++++----------- kos_core/Cargo.toml | 10 ++++++++-- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index eba39e9..cd89c4a 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -1,11 +1,17 @@ [package] -name = "daemon" -version = "0.1.0" -edition = "2021" +name = "kos" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +description.workspace = true +documentation.workspace = true +readme.workspace = true [dependencies] -kos_core = { path = "../kos_core" } -kscale_micro = { path = "../platforms/kscale_micro", optional = true } +kos_core = { version = "0.1.1", path = "../kos_core" } +kscale_micro = { version = "0.1.0", path = "../platforms/kscale_micro", optional = true } tokio = { version = "1", features = ["full"] } tonic = { version = "0.12", features = ["transport"] } eyre = "0.6" @@ -13,14 +19,11 @@ tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tower = "0.5" -sim = { path = "../platforms/sim", optional = true } -stub = { path = "../platforms/stub", optional = true } +sim = { version = "0.1.0", path = "../platforms/sim", optional = true } +stub = { version = "0.1.0", path = "../platforms/stub", optional = true } [target.'cfg(target_os = "linux")'.dependencies] -kscale_pro = { path = "../platforms/kscale_pro", optional = true } - -# Also can add external platforms here? -# e.g. third_party_platform = { git = "https://github.com/thirdparty/platform", optional = true } +kscale_pro = { version = "0.1.0", path = "../platforms/kscale_pro", optional = true } [features] kscale_micro = ["dep:kscale_micro"] @@ -28,3 +31,7 @@ kscale_pro = ["dep:kscale_pro"] sim = ["dep:sim"] stub = ["dep:stub"] default = ["stub"] + +[[bin]] +name = "kos" +path = "src/main.rs" diff --git a/kos_core/Cargo.toml b/kos_core/Cargo.toml index 50b66ca..9aa8d9d 100644 --- a/kos_core/Cargo.toml +++ b/kos_core/Cargo.toml @@ -1,7 +1,13 @@ [package] name = "kos_core" -version = "0.1.0" -edition = "2021" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +description.workspace = true +documentation.workspace = true +readme.workspace = true build = "build.rs" [dependencies] From 31cd5e00f44f2c235f02536f88bcceba1934aa52 Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 15:00:38 -0800 Subject: [PATCH 11/15] preparing for publish --- kos_core/build.rs | 2 +- .../proto}/googleapis/google/api/annotations.proto | 0 {proto => kos_core/proto}/googleapis/google/api/client.proto | 0 {proto => kos_core/proto}/googleapis/google/api/http.proto | 0 .../proto}/googleapis/google/api/launch_stage.proto | 0 .../proto}/googleapis/google/longrunning/operations.proto | 0 {proto => kos_core/proto}/googleapis/google/rpc/status.proto | 0 {proto => kos_core/proto}/kos/actuator.proto | 0 {proto => kos_core/proto}/kos/common.proto | 0 {proto => kos_core/proto}/kos/imu.proto | 0 {proto => kos_core/proto}/kos/inference.proto | 0 {proto => kos_core/proto}/kos/process_manager.proto | 0 {proto => kos_core/proto}/kos/system.proto | 0 pykos/Makefile | 2 +- 14 files changed, 2 insertions(+), 2 deletions(-) rename {proto => kos_core/proto}/googleapis/google/api/annotations.proto (100%) rename {proto => kos_core/proto}/googleapis/google/api/client.proto (100%) rename {proto => kos_core/proto}/googleapis/google/api/http.proto (100%) rename {proto => kos_core/proto}/googleapis/google/api/launch_stage.proto (100%) rename {proto => kos_core/proto}/googleapis/google/longrunning/operations.proto (100%) rename {proto => kos_core/proto}/googleapis/google/rpc/status.proto (100%) rename {proto => kos_core/proto}/kos/actuator.proto (100%) rename {proto => kos_core/proto}/kos/common.proto (100%) rename {proto => kos_core/proto}/kos/imu.proto (100%) rename {proto => kos_core/proto}/kos/inference.proto (100%) rename {proto => kos_core/proto}/kos/process_manager.proto (100%) rename {proto => kos_core/proto}/kos/system.proto (100%) diff --git a/kos_core/build.rs b/kos_core/build.rs index 8eabab9..4d54993 100644 --- a/kos_core/build.rs +++ b/kos_core/build.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; fn main() { // Path to the Protobuf files - let proto_root = "../proto"; + let proto_root = "proto"; // Where to output the compiled Rust files let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); diff --git a/proto/googleapis/google/api/annotations.proto b/kos_core/proto/googleapis/google/api/annotations.proto similarity index 100% rename from proto/googleapis/google/api/annotations.proto rename to kos_core/proto/googleapis/google/api/annotations.proto diff --git a/proto/googleapis/google/api/client.proto b/kos_core/proto/googleapis/google/api/client.proto similarity index 100% rename from proto/googleapis/google/api/client.proto rename to kos_core/proto/googleapis/google/api/client.proto diff --git a/proto/googleapis/google/api/http.proto b/kos_core/proto/googleapis/google/api/http.proto similarity index 100% rename from proto/googleapis/google/api/http.proto rename to kos_core/proto/googleapis/google/api/http.proto diff --git a/proto/googleapis/google/api/launch_stage.proto b/kos_core/proto/googleapis/google/api/launch_stage.proto similarity index 100% rename from proto/googleapis/google/api/launch_stage.proto rename to kos_core/proto/googleapis/google/api/launch_stage.proto diff --git a/proto/googleapis/google/longrunning/operations.proto b/kos_core/proto/googleapis/google/longrunning/operations.proto similarity index 100% rename from proto/googleapis/google/longrunning/operations.proto rename to kos_core/proto/googleapis/google/longrunning/operations.proto diff --git a/proto/googleapis/google/rpc/status.proto b/kos_core/proto/googleapis/google/rpc/status.proto similarity index 100% rename from proto/googleapis/google/rpc/status.proto rename to kos_core/proto/googleapis/google/rpc/status.proto diff --git a/proto/kos/actuator.proto b/kos_core/proto/kos/actuator.proto similarity index 100% rename from proto/kos/actuator.proto rename to kos_core/proto/kos/actuator.proto diff --git a/proto/kos/common.proto b/kos_core/proto/kos/common.proto similarity index 100% rename from proto/kos/common.proto rename to kos_core/proto/kos/common.proto diff --git a/proto/kos/imu.proto b/kos_core/proto/kos/imu.proto similarity index 100% rename from proto/kos/imu.proto rename to kos_core/proto/kos/imu.proto diff --git a/proto/kos/inference.proto b/kos_core/proto/kos/inference.proto similarity index 100% rename from proto/kos/inference.proto rename to kos_core/proto/kos/inference.proto diff --git a/proto/kos/process_manager.proto b/kos_core/proto/kos/process_manager.proto similarity index 100% rename from proto/kos/process_manager.proto rename to kos_core/proto/kos/process_manager.proto diff --git a/proto/kos/system.proto b/kos_core/proto/kos/system.proto similarity index 100% rename from proto/kos/system.proto rename to kos_core/proto/kos/system.proto diff --git a/pykos/Makefile b/pykos/Makefile index 445baa1..bf29758 100644 --- a/pykos/Makefile +++ b/pykos/Makefile @@ -27,7 +27,7 @@ all: # ------------------------ # generate-proto: - python -m grpc_tools.protoc --python_out=. --grpc_python_out=. --proto_path=../proto --proto_path=../proto/googleapis ../proto/kos/* + python -m grpc_tools.protoc --python_out=. --grpc_python_out=. --proto_path=../kos_core/proto --proto_path=../proto/googleapis ../proto/kos/* .PHONY: generate-proto From 28954be3d93ea01a3591f5806f53f012b75ca5d2 Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 17:01:45 -0800 Subject: [PATCH 12/15] crate.io release --- daemon/Cargo.toml | 17 ++++++++--------- daemon/src/main.rs | 8 ++++---- platforms/kbot/Cargo.toml | 13 +++++++++++++ platforms/{kscale_pro => kbot}/src/actuator.rs | 0 platforms/{kscale_pro => kbot}/src/hexmove.rs | 0 platforms/{kscale_pro => kbot}/src/lib.rs | 0 platforms/kscale_micro/Cargo.toml | 4 ---- platforms/kscale_pro/Cargo.toml | 9 --------- platforms/sim/Cargo.toml | 9 ++++++--- platforms/stub/Cargo.toml | 9 ++++++--- platforms/zeroth-01/Cargo.toml | 12 ++++++++++++ .../{kscale_micro => zeroth-01}/src/lib.rs | 0 12 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 platforms/kbot/Cargo.toml rename platforms/{kscale_pro => kbot}/src/actuator.rs (100%) rename platforms/{kscale_pro => kbot}/src/hexmove.rs (100%) rename platforms/{kscale_pro => kbot}/src/lib.rs (100%) delete mode 100644 platforms/kscale_micro/Cargo.toml delete mode 100644 platforms/kscale_pro/Cargo.toml create mode 100644 platforms/zeroth-01/Cargo.toml rename platforms/{kscale_micro => zeroth-01}/src/lib.rs (100%) diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index cd89c4a..2978ada 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -11,7 +11,6 @@ readme.workspace = true [dependencies] kos_core = { version = "0.1.1", path = "../kos_core" } -kscale_micro = { version = "0.1.0", path = "../platforms/kscale_micro", optional = true } tokio = { version = "1", features = ["full"] } tonic = { version = "0.12", features = ["transport"] } eyre = "0.6" @@ -19,18 +18,18 @@ tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tower = "0.5" -sim = { version = "0.1.0", path = "../platforms/sim", optional = true } -stub = { version = "0.1.0", path = "../platforms/stub", optional = true } +kos-sim = { version = "0.1.0", path = "../platforms/sim", optional = true } +kos-stub = { version = "0.1.0", path = "../platforms/stub", optional = true } +kos-zeroth-01 = { version = "0.1.0", path = "../platforms/zeroth-01", optional = true } [target.'cfg(target_os = "linux")'.dependencies] -kscale_pro = { version = "0.1.0", path = "../platforms/kscale_pro", optional = true } +kos-kbot = { version = "0.1.0", path = "../platforms/kbot", optional = true } [features] -kscale_micro = ["dep:kscale_micro"] -kscale_pro = ["dep:kscale_pro"] -sim = ["dep:sim"] -stub = ["dep:stub"] -default = ["stub"] +kos-zeroth-01 = ["dep:kos-zeroth-01"] +kos-sim = ["dep:kos-sim"] +kos-stub = ["dep:kos-stub"] +default = ["kos-stub"] [[bin]] name = "kos" diff --git a/daemon/src/main.rs b/daemon/src/main.rs index 6bec3a6..f7390f0 100644 --- a/daemon/src/main.rs +++ b/daemon/src/main.rs @@ -15,11 +15,11 @@ use tonic::transport::Server; use tracing::{debug, error, info}; use tracing_subscriber::filter::EnvFilter; -#[cfg(feature = "sim")] -use sim::SimPlatform as PlatformImpl; +#[cfg(feature = "kos-sim")] +use kos_sim::SimPlatform as PlatformImpl; -#[cfg(feature = "stub")] -use stub::StubPlatform as PlatformImpl; +#[cfg(feature = "kos-stub")] +use kos_stub::StubPlatform as PlatformImpl; fn add_service_to_router( router: tonic::transport::server::Router, diff --git a/platforms/kbot/Cargo.toml b/platforms/kbot/Cargo.toml new file mode 100644 index 0000000..6f1c8b8 --- /dev/null +++ b/platforms/kbot/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "kos-kbot" +version = "0.1.1" +authors = ["Wesley Maa "] +edition = "2021" +license = "MIT" +repository = "https://github.com/kscalelabs/kos" + +[dependencies] +kos_core = { version = "0.1.1", path = "../../kos_core" } +eyre = "0.6" +robstride = "0.2.8" +imu = "0.1.4" \ No newline at end of file diff --git a/platforms/kscale_pro/src/actuator.rs b/platforms/kbot/src/actuator.rs similarity index 100% rename from platforms/kscale_pro/src/actuator.rs rename to platforms/kbot/src/actuator.rs diff --git a/platforms/kscale_pro/src/hexmove.rs b/platforms/kbot/src/hexmove.rs similarity index 100% rename from platforms/kscale_pro/src/hexmove.rs rename to platforms/kbot/src/hexmove.rs diff --git a/platforms/kscale_pro/src/lib.rs b/platforms/kbot/src/lib.rs similarity index 100% rename from platforms/kscale_pro/src/lib.rs rename to platforms/kbot/src/lib.rs diff --git a/platforms/kscale_micro/Cargo.toml b/platforms/kscale_micro/Cargo.toml deleted file mode 100644 index bb4543d..0000000 --- a/platforms/kscale_micro/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -name = "kscale_micro" -version = "0.1.0" -edition = "2021" diff --git a/platforms/kscale_pro/Cargo.toml b/platforms/kscale_pro/Cargo.toml deleted file mode 100644 index 1d430a1..0000000 --- a/platforms/kscale_pro/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "kscale_pro" -version = "0.1.0" -edition = "2021" - -[dependencies] -eyre = "0.6" -robstride = "0.2.8" -imu = "0.1.4" \ No newline at end of file diff --git a/platforms/sim/Cargo.toml b/platforms/sim/Cargo.toml index e51f840..eef1bb6 100644 --- a/platforms/sim/Cargo.toml +++ b/platforms/sim/Cargo.toml @@ -1,9 +1,12 @@ [package] -name = "sim" -version = "0.1.0" +name = "kos-sim" +version = "0.1.1" +authors = ["Denys Bezmenov "] edition = "2021" +license = "MIT" +repository = "https://github.com/kscalelabs/kos" [dependencies] -kos_core = { path = "../../kos_core" } +kos_core = { version = "0.1.1", path = "../../kos_core" } async-trait = "0.1" eyre = "0.6" diff --git a/platforms/stub/Cargo.toml b/platforms/stub/Cargo.toml index 85f62d5..6ad5cc1 100644 --- a/platforms/stub/Cargo.toml +++ b/platforms/stub/Cargo.toml @@ -1,10 +1,13 @@ [package] -name = "stub" -version = "0.1.0" +name = "kos-stub" +version = "0.1.1" +authors = ["Denys Bezmenov "] edition = "2021" +license = "MIT" +repository = "https://github.com/kscalelabs/kos" [dependencies] -kos_core = { path = "../../kos_core" } +kos_core = { version = "0.1.1", path = "../../kos_core" } async-trait = "0.1" eyre = "0.6" tokio = { version = "1", features = ["full"] } diff --git a/platforms/zeroth-01/Cargo.toml b/platforms/zeroth-01/Cargo.toml new file mode 100644 index 0000000..576f2d1 --- /dev/null +++ b/platforms/zeroth-01/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "kos-zeroth-01" +version = "0.1.1" +authors = ["Denys Bezmenov ", "Jingxiang Mo "] +edition = "2021" +license = "MIT" +repository = "https://github.com/kscalelabs/kos" + +[dependencies] +kos_core = { version = "0.1.1", path = "../../kos_core" } +async-trait = "0.1" +eyre = "0.6" diff --git a/platforms/kscale_micro/src/lib.rs b/platforms/zeroth-01/src/lib.rs similarity index 100% rename from platforms/kscale_micro/src/lib.rs rename to platforms/zeroth-01/src/lib.rs From aa3615c2960abc317b43004e40c34802f4fe30be Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Wed, 13 Nov 2024 17:04:53 -0800 Subject: [PATCH 13/15] Description for crates.io --- platforms/kbot/Cargo.toml | 1 + platforms/sim/Cargo.toml | 1 + platforms/stub/Cargo.toml | 1 + platforms/zeroth-01/Cargo.toml | 1 + 4 files changed, 4 insertions(+) diff --git a/platforms/kbot/Cargo.toml b/platforms/kbot/Cargo.toml index 6f1c8b8..1034b0d 100644 --- a/platforms/kbot/Cargo.toml +++ b/platforms/kbot/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Wesley Maa "] edition = "2021" license = "MIT" repository = "https://github.com/kscalelabs/kos" +description = "KOS platform for KBot" [dependencies] kos_core = { version = "0.1.1", path = "../../kos_core" } diff --git a/platforms/sim/Cargo.toml b/platforms/sim/Cargo.toml index eef1bb6..f4711be 100644 --- a/platforms/sim/Cargo.toml +++ b/platforms/sim/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Denys Bezmenov "] edition = "2021" license = "MIT" repository = "https://github.com/kscalelabs/kos" +description = "KOS platform for simulation" [dependencies] kos_core = { version = "0.1.1", path = "../../kos_core" } diff --git a/platforms/stub/Cargo.toml b/platforms/stub/Cargo.toml index 6ad5cc1..f38c2aa 100644 --- a/platforms/stub/Cargo.toml +++ b/platforms/stub/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Denys Bezmenov "] edition = "2021" license = "MIT" repository = "https://github.com/kscalelabs/kos" +description = "Stub KOS platform" [dependencies] kos_core = { version = "0.1.1", path = "../../kos_core" } diff --git a/platforms/zeroth-01/Cargo.toml b/platforms/zeroth-01/Cargo.toml index 576f2d1..1af576c 100644 --- a/platforms/zeroth-01/Cargo.toml +++ b/platforms/zeroth-01/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Denys Bezmenov ", "Jingxiang Mo "] edition = "2021" license = "MIT" repository = "https://github.com/kscalelabs/kos" +description = "KOS platform for Zeroth-01" [dependencies] kos_core = { version = "0.1.1", path = "../../kos_core" } From c4b674841bacff05dbc10d6aa5fcfedbafe2eaf3 Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Thu, 14 Nov 2024 11:59:15 -0800 Subject: [PATCH 14/15] better platform selection, field for serial, actuator id change --- daemon/src/main.rs | 21 ++++++++++++++++----- kos_core/proto/kos/actuator.proto | 1 + kos_core/src/lib.rs | 1 + platforms/kbot/src/lib.rs | 20 ++++++++++++-------- platforms/stub/src/lib.rs | 4 ++++ 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/daemon/src/main.rs b/daemon/src/main.rs index f7390f0..bc73893 100644 --- a/daemon/src/main.rs +++ b/daemon/src/main.rs @@ -15,11 +15,17 @@ use tonic::transport::Server; use tracing::{debug, error, info}; use tracing_subscriber::filter::EnvFilter; +#[cfg(not(any(feature = "kos-sim", feature = "kos-zeroth-01", feature = "kos-kbot")))] +use kos_stub::StubPlatform as PlatformImpl; + #[cfg(feature = "kos-sim")] use kos_sim::SimPlatform as PlatformImpl; -#[cfg(feature = "kos-stub")] -use kos_stub::StubPlatform as PlatformImpl; +#[cfg(feature = "kos-zeroth-01")] +use kos_zeroth_01::Zeroth01Platform as PlatformImpl; + +#[cfg(feature = "kos-kbot")] +use kos_kbot::KbotPlatform as PlatformImpl; fn add_service_to_router( router: tonic::transport::server::Router, @@ -69,14 +75,19 @@ async fn main() -> Result<()> { ) .init(); + let mut platform = PlatformImpl::new(); + // telemetry - Telemetry::initialize("test", "localhost", 1883).await?; + Telemetry::initialize( + format!("{}-{}", platform.name(), platform.serial()).as_str(), + "localhost", + 1883, + ) + .await?; let operations_store = Arc::new(Mutex::new(HashMap::new())); let operations_service = Arc::new(OperationsServiceImpl::new(operations_store)); - let mut platform = PlatformImpl::new(); - platform.initialize(operations_service.clone())?; if let Err(e) = run_server(&platform, operations_service).await { diff --git a/kos_core/proto/kos/actuator.proto b/kos_core/proto/kos/actuator.proto index cec6c11..4b55763 100644 --- a/kos_core/proto/kos/actuator.proto +++ b/kos_core/proto/kos/actuator.proto @@ -58,6 +58,7 @@ message ConfigureActuatorRequest { optional double protective_torque = 6; // Protective torque (%) optional float protection_time = 7; // Protection time in seconds optional bool torque_enabled = 8; // Torque enabled flag + optional uint32 new_actuator_id = 9; // New actuator ID } // Request message for CalibrateActuator. diff --git a/kos_core/src/lib.rs b/kos_core/src/lib.rs index f579a02..609979d 100644 --- a/kos_core/src/lib.rs +++ b/kos_core/src/lib.rs @@ -38,6 +38,7 @@ pub enum ServiceEnum { pub trait Platform { fn name(&self) -> &'static str; + fn serial(&self) -> String; fn initialize(&mut self, operations_service: Arc) -> eyre::Result<()>; fn create_services(&self, operations_service: Arc) -> Vec; fn shutdown(&mut self) -> eyre::Result<()>; diff --git a/platforms/kbot/src/lib.rs b/platforms/kbot/src/lib.rs index 0e6898f..d2e0190 100644 --- a/platforms/kbot/src/lib.rs +++ b/platforms/kbot/src/lib.rs @@ -13,23 +13,27 @@ use kos_core::services::{ActuatorServiceImpl, IMUServiceImpl}; use kos_core::{services::OperationsServiceImpl, Platform, ServiceEnum}; use std::sync::Arc; -pub struct KscaleProPlatform {} +pub struct KbotPlatform {} -impl KscaleProPlatform { +impl KbotPlatform { pub fn new() -> Self { Self {} } } -impl Default for KscaleProPlatform { +impl Default for KbotPlatform { fn default() -> Self { - KscaleProPlatform::new() + KbotPlatform::new() } } -impl Platform for KscaleProPlatform { +impl Platform for KbotPlatform { fn name(&self) -> &'static str { - "Kscale Pro" + "KBot" + } + + fn serial(&self) -> String { + "00000000".to_string() } fn initialize(&mut self, _operations_service: Arc) -> eyre::Result<()> { @@ -41,10 +45,10 @@ impl Platform for KscaleProPlatform { // Add available services here vec![ ServiceEnum::Imu(ImuServiceServer::new(IMUServiceImpl::new(Arc::new( - KscaleProIMU::new("can0", 1, 1), + KbotIMU::new("can0", 1, 1), )))), ServiceEnum::Actuator(ActuatorServiceServer::new(ActuatorServiceImpl::new( - Arc::new(KscaleProActuator::new( + Arc::new(KbotActuator::new( "/dev/ttyCH341USB0", HashMap::new() )), diff --git a/platforms/stub/src/lib.rs b/platforms/stub/src/lib.rs index 7276b15..5a3bccd 100644 --- a/platforms/stub/src/lib.rs +++ b/platforms/stub/src/lib.rs @@ -32,6 +32,10 @@ impl Platform for StubPlatform { "Stub" } + fn serial(&self) -> String { + "00000000".to_string() + } + fn initialize(&mut self, _operations_service: Arc) -> eyre::Result<()> { // Initialize the platform Ok(()) From b23547ad0be582eee6e508c2e00d4b54c2700c0c Mon Sep 17 00:00:00 2001 From: Denys Bezmenov Date: Thu, 14 Nov 2024 12:03:07 -0800 Subject: [PATCH 15/15] Added CODEOWNERS --- .github/CODEOWNERS | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..c0f000d --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,17 @@ +# Core components +/kos_core/ @codekansas @hatomist +/daemon/ @codekansas @hatomist + +# Platform-specific code +/platforms/kscale_micro/ @codekansas @hatomist +/platforms/kscale_pro/ @codekansas @hatomist @WT-MM +/platforms/sim/ @codekansas @hatomist +/platforms/stub/ @codekansas @hatomist + +# Python client +/pykos/ @codekansas @hatomist + +# Build and CI configuration +/.github/ @codekansas @hatomist +/toolchain/ @codekansas @hatomist +*.toml @codekansas @hatomist \ No newline at end of file