Skip to content

Commit

Permalink
Replace with reserved
Browse files Browse the repository at this point in the history
  • Loading branch information
vapopov committed Oct 15, 2024
1 parent 401d2a3 commit 1b4e023
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 113 deletions.
151 changes: 64 additions & 87 deletions api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 10 additions & 16 deletions api/proto/teleport/autoupdate/v1/autoupdate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,24 @@ message AutoUpdateConfig {

// AutoUpdateConfigSpec encodes the parameters of the autoupdate config object.
message AutoUpdateConfigSpec {

Check failure on line 35 in api/proto/teleport/autoupdate/v1/autoupdate.proto

View workflow job for this annotation

GitHub Actions / Lint (Proto)

Previously present field "1" with name "tools_autoupdate" on message "AutoUpdateConfigSpec" was deleted without reserving the name "tools_autoupdate".
// ToolsAutoupdate encodes the feature flag to enable/disable tools autoupdates.
// Deprecated: use AutoUpdateConfigTools instead.
bool tools_autoupdate = 1;

reserved 1; // ToolsAutoupdate is replaced by tools.mode.
AutoUpdateConfigTools tools = 2;
}

// AutoUpdateConfigTools encodes the parameters for client tools auto updates.
message AutoUpdateConfigTools {
// Mode defines state of the client tools auto update.
ToolsMode mode = 1;
ToolsUpdateMode mode = 1;
}

// ToolsMode type for client tools enabling state.
enum ToolsMode {
// TOOLS_MODE_UNSPECIFIED is undefined mode.
TOOLS_MODE_UNSPECIFIED = 0;
// TOOLS_MODE_ENABLED client tools auto update is enabled.
TOOLS_MODE_ENABLED = 1;
// TOOLS_MODE_DISABLED client tools auto update is disabled.
TOOLS_MODE_DISABLED = 2;
enum ToolsUpdateMode {
// TOOLS_UPDATE_MODE_UNSPECIFIED is undefined mode.
TOOLS_UPDATE_MODE_UNSPECIFIED = 0;
// TOOLS_UPDATE_MODE_ENABLED client tools auto update is enabled.
TOOLS_UPDATE_MODE_ENABLED = 1;
// TOOLS_UPDATE_MODE_DISABLED client tools auto update is disabled.
TOOLS_UPDATE_MODE_DISABLED = 2;
}

// AutoUpdateVersion is a resource singleton with version required for
Expand All @@ -69,10 +66,7 @@ message AutoUpdateVersion {

// AutoUpdateVersionSpec encodes the parameters of the autoupdate versions.
message AutoUpdateVersionSpec {

Check failure on line 68 in api/proto/teleport/autoupdate/v1/autoupdate.proto

View workflow job for this annotation

GitHub Actions / Lint (Proto)

Previously present field "1" with name "tools_version" on message "AutoUpdateVersionSpec" was deleted without reserving the name "tools_version".
// ToolsVersion is the semantic version required for tools autoupdates.
// Deprecated: use AutoUpdateVersionTools instead.
string tools_version = 1;

reserved 1; // ToolsVersion is replaced by tools.target_version.
AutoUpdateVersionTools tools = 2;
}

Expand Down
6 changes: 3 additions & 3 deletions api/types/autoupdate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ func ValidateAutoUpdateConfig(c *autoupdate.AutoUpdateConfig) error {
}

// ToolsModeToAPI transforms client tools mode enum to API string representation.
func ToolsModeToAPI(mode autoupdate.ToolsMode) string {
func ToolsModeToAPI(mode autoupdate.ToolsUpdateMode) string {
switch mode {
case autoupdate.ToolsMode_TOOLS_MODE_ENABLED:
case autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED:
return "enabled"
case autoupdate.ToolsMode_TOOLS_MODE_DISABLED:
case autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED:
return "disabled"
default:
return ""
Expand Down
16 changes: 12 additions & 4 deletions api/types/autoupdate/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ func TestNewAutoUpdateConfig(t *testing.T) {
{
name: "success tools autoupdate disabled",
spec: &autoupdate.AutoUpdateConfigSpec{
ToolsAutoupdate: false,
Tools: &autoupdate.AutoUpdateConfigTools{
Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED,
},
},
assertErr: func(t *testing.T, err error, a ...any) {
require.NoError(t, err)
Expand All @@ -53,14 +55,18 @@ func TestNewAutoUpdateConfig(t *testing.T) {
Name: types.MetaNameAutoUpdateConfig,
},
Spec: &autoupdate.AutoUpdateConfigSpec{
ToolsAutoupdate: false,
Tools: &autoupdate.AutoUpdateConfigTools{
Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED,
},
},
},
},
{
name: "success tools autoupdate enabled",
spec: &autoupdate.AutoUpdateConfigSpec{
ToolsAutoupdate: true,
Tools: &autoupdate.AutoUpdateConfigTools{
Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED,
},
},
assertErr: func(t *testing.T, err error, a ...any) {
require.NoError(t, err)
Expand All @@ -72,7 +78,9 @@ func TestNewAutoUpdateConfig(t *testing.T) {
Name: types.MetaNameAutoUpdateConfig,
},
Spec: &autoupdate.AutoUpdateConfigSpec{
ToolsAutoupdate: true,
Tools: &autoupdate.AutoUpdateConfigTools{
Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED,
},
},
},
},
Expand Down
Loading

0 comments on commit 1b4e023

Please sign in to comment.