aconfig: make proto fields optional

Change all required proto fields to optional. While the proto file is
supposed to be a backwards compatible API, and fields are not supposed
to be deprecated, this commit will allow for that option if needed.

Implementation wise this change doesn't matter much: any parsed data
needs additional verification outside what the protobuf crate's parser
provides anyway, so adding checks to verify that all required fields,
even though marked optional in the proto file, were found is a minor
increase in code complexity.

If in the future a proto field should no longer be used:

  - keep the field in the proto, still marked optional and clearly
    document that it is no longer in use
  - change protos.rs from checking struct.has_field() to explicitly
    dropping any value via struct.clear_field()

Bug: 286337317
Test: atest aconfig.test
Change-Id: Iad1ccfe50ecac286ff7a796aec909bec70b9520d
This commit is contained in:
Mårten Kongstad
2023-06-19 16:28:54 +02:00
parent a2e152a139
commit a2e5ab82c7
2 changed files with 50 additions and 23 deletions

View File

@@ -35,21 +35,21 @@ enum flag_permission {
// aconfig input messages: flag declarations and values
message flag_declaration {
required string name = 1;
required string namespace = 2;
required string description = 3;
optional string name = 1;
optional string namespace = 2;
optional string description = 3;
};
message flag_declarations {
required string package = 1;
optional string package = 1;
repeated flag_declaration flag = 2;
};
message flag_value {
required string package = 1;
required string name = 2;
required flag_state state = 3;
required flag_permission permission = 4;
optional string package = 1;
optional string name = 2;
optional flag_state state = 3;
optional flag_permission permission = 4;
};
message flag_values {
@@ -60,18 +60,18 @@ message flag_values {
message tracepoint {
// path to declaration or value file relative to $TOP
required string source = 1;
required flag_state state = 2;
required flag_permission permission = 3;
optional string source = 1;
optional flag_state state = 2;
optional flag_permission permission = 3;
}
message parsed_flag {
required string package = 1;
required string name = 2;
required string namespace = 3;
required string description = 4;
required flag_state state = 5;
required flag_permission permission = 6;
optional string package = 1;
optional string name = 2;
optional string namespace = 3;
optional string description = 4;
optional flag_state state = 5;
optional flag_permission permission = 6;
repeated tracepoint trace = 7;
}