Skip to content

Commit 1754772

Browse files
authored
feat(proto): Add unspecified to enum fields (#98)
* style(test): Sort halconfig file It's easier to find fields if it's sorted. Also while making trivial changes, format the markdown files with prettier. * feat(security): Remove unused enum This enum was only used by Halyard to track they type of OAuth provider you had configured; it used this to set other fields when you ran hal commands. A while back I updated the documentation on spinnaker.io to show users how to set the required fields themselves (which is useful both for directly editing your hal config with Halyard, or for early adopters of kleat). We can remove this field as it is not used. I'll add a note to the changelog about this. Existing Halyard users would already have had the other fields filled out based on that field when they ran hal commands, so I'm not including this as a breaking change. New users will need to set their config fields themselves using the documentation on spinnaker.io. * feat(proto): Add unspecified to enum fields We want to distinguish unspecified enums from enums set to their default value. Let's do this by making the default value in each enum be a sentinel UNSPECIFIED value. This means that when the field is not specified, it will be deseriazlied as UNSPECIFIED, and will be omitted from re-serialization. Any valid value will be included in serialization.
1 parent cdf3dee commit 1754772

File tree

22 files changed

+963
-1014
lines changed

22 files changed

+963
-1014
lines changed

CONTRIBUTING.md

+14
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ that has been omitted from the config and a field that has has been explicitly
9494
set to its default value. The output config will include the field even when it
9595
has been set to its default value (`""`, `0`, `false`).
9696

97+
In the case of `enum` fields, the absence of a value is treated the same as the
98+
value assigned to constant `0` (which is required and must be the first value in
99+
the enum). In particular, this means that an enum set to its zero value will not
100+
be included in serialization.
101+
102+
In order to distinguish enum fields that are unset from those set to their
103+
default value, a value `UNSPECIFIED` can be added as the first enum constant. In
104+
this way, configs that don't specify the value will be deserialized to
105+
`UNSPECIFIED` and will omit the field on re-serialization.
106+
97107
#### General rules
98108

99109
The general rule is that `string` and `int32` fields should rarely be wrapped,
@@ -105,3 +115,7 @@ On the other hand, it generally is meaningful to distinguish between omitting a
105115
something to `false` is meaningful and distinct from not setting it at all (even
106116
if the consuming code currently defaults the field to `false`). For this reason,
107117
all `bool` fields should be wrapped as `BoolValue`.
118+
119+
Likewise, it is generally meaningful to distinguish an unset enum field from one
120+
that has been set. Thus `enum`s should always have `UNSPECIFIED = 0` as their
121+
first value.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ replace Halyard. Please see the
77
[RFC](https://github.com/spinnaker/governance/blob/master/rfc/halyard-lite.md)
88
for an overview of what this tool will do.
99

10-
It is currently under active development, but is ready for early adopters
11-
to try in development clusters! Please share any feedback in the #kleat
12-
channel in [Spinnaker slack](join.spinnaker.io).
10+
It is currently under active development, but is ready for early adopters to try
11+
in development clusters! Please share any feedback in the #kleat channel in
12+
[Spinnaker slack](join.spinnaker.io).
1313

1414
### Migrating from Halyard
1515

api/client/canary/supported_type.pb.go

+24-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/client/cloudprovider/appengine.pb.go

+23-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/client/pubsub/google.pb.go

+26-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)