From 401d2a308cbf5e920f79b7f3237eaf48a361dc28 Mon Sep 17 00:00:00 2001 From: Vadym Popov Date: Fri, 11 Oct 2024 21:02:34 -0400 Subject: [PATCH 1/6] Update client autoupdate proto structure --- api/client/webclient/webclient.go | 4 +- .../teleport/autoupdate/v1/autoupdate.pb.go | 305 ++++++++++++++---- .../teleport/autoupdate/v1/autoupdate.proto | 28 ++ api/types/autoupdate/config.go | 12 + api/types/autoupdate/version.go | 12 +- api/types/autoupdate/version_test.go | 20 +- lib/web/apiserver.go | 5 +- lib/web/apiserver_ping_test.go | 50 ++- 8 files changed, 354 insertions(+), 82 deletions(-) diff --git a/api/client/webclient/webclient.go b/api/client/webclient/webclient.go index d1f11a5a48304..95ae0ea9747c3 100644 --- a/api/client/webclient/webclient.go +++ b/api/client/webclient/webclient.go @@ -334,8 +334,8 @@ type ProxySettings struct { type AutoUpdateSettings struct { // ToolsVersion defines the version of {tsh, tctl} for client auto update. ToolsVersion string `json:"tools_version"` - // ToolsAutoUpdate enables client auto update feature. - ToolsAutoUpdate bool `json:"tools_auto_update"` + // ToolsMode defines mode client auto update feature `enabled|disabled`. + ToolsMode string `json:"tools_mode"` } // KubeProxySettings is kubernetes proxy settings diff --git a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go index 2b608e5b5b472..3a42d1fd5edb6 100644 --- a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go +++ b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go @@ -35,6 +35,59 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// ToolsMode type for client tools enabling state. +type ToolsMode int32 + +const ( + // TOOLS_MODE_UNSPECIFIED is undefined mode. + ToolsMode_TOOLS_MODE_UNSPECIFIED ToolsMode = 0 + // TOOLS_MODE_ENABLED client tools auto update is enabled. + ToolsMode_TOOLS_MODE_ENABLED ToolsMode = 1 + // TOOLS_MODE_DISABLED client tools auto update is disabled. + ToolsMode_TOOLS_MODE_DISABLED ToolsMode = 2 +) + +// Enum value maps for ToolsMode. +var ( + ToolsMode_name = map[int32]string{ + 0: "TOOLS_MODE_UNSPECIFIED", + 1: "TOOLS_MODE_ENABLED", + 2: "TOOLS_MODE_DISABLED", + } + ToolsMode_value = map[string]int32{ + "TOOLS_MODE_UNSPECIFIED": 0, + "TOOLS_MODE_ENABLED": 1, + "TOOLS_MODE_DISABLED": 2, + } +) + +func (x ToolsMode) Enum() *ToolsMode { + p := new(ToolsMode) + *p = x + return p +} + +func (x ToolsMode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ToolsMode) Descriptor() protoreflect.EnumDescriptor { + return file_teleport_autoupdate_v1_autoupdate_proto_enumTypes[0].Descriptor() +} + +func (ToolsMode) Type() protoreflect.EnumType { + return &file_teleport_autoupdate_v1_autoupdate_proto_enumTypes[0] +} + +func (x ToolsMode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ToolsMode.Descriptor instead. +func (ToolsMode) EnumDescriptor() ([]byte, []int) { + return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{0} +} + // AutoUpdateConfig is a config singleton used to configure cluster // autoupdate settings. type AutoUpdateConfig struct { @@ -121,7 +174,9 @@ type AutoUpdateConfigSpec struct { unknownFields protoimpl.UnknownFields // ToolsAutoupdate encodes the feature flag to enable/disable tools autoupdates. - ToolsAutoupdate bool `protobuf:"varint,1,opt,name=tools_autoupdate,json=toolsAutoupdate,proto3" json:"tools_autoupdate,omitempty"` + // Deprecated: use AutoUpdateConfigTools instead. + ToolsAutoupdate bool `protobuf:"varint,1,opt,name=tools_autoupdate,json=toolsAutoupdate,proto3" json:"tools_autoupdate,omitempty"` + Tools *AutoUpdateConfigTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` } func (x *AutoUpdateConfigSpec) Reset() { @@ -161,6 +216,60 @@ func (x *AutoUpdateConfigSpec) GetToolsAutoupdate() bool { return false } +func (x *AutoUpdateConfigSpec) GetTools() *AutoUpdateConfigTools { + if x != nil { + return x.Tools + } + return nil +} + +// AutoUpdateConfigTools encodes the parameters for client tools auto updates. +type AutoUpdateConfigTools struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Mode defines state of the client tools auto update. + Mode ToolsMode `protobuf:"varint,1,opt,name=mode,proto3,enum=teleport.autoupdate.v1.ToolsMode" json:"mode,omitempty"` +} + +func (x *AutoUpdateConfigTools) Reset() { + *x = AutoUpdateConfigTools{} + mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AutoUpdateConfigTools) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AutoUpdateConfigTools) ProtoMessage() {} + +func (x *AutoUpdateConfigTools) ProtoReflect() protoreflect.Message { + mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AutoUpdateConfigTools.ProtoReflect.Descriptor instead. +func (*AutoUpdateConfigTools) Descriptor() ([]byte, []int) { + return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{2} +} + +func (x *AutoUpdateConfigTools) GetMode() ToolsMode { + if x != nil { + return x.Mode + } + return ToolsMode_TOOLS_MODE_UNSPECIFIED +} + // AutoUpdateVersion is a resource singleton with version required for // tools autoupdate. type AutoUpdateVersion struct { @@ -177,7 +286,7 @@ type AutoUpdateVersion struct { func (x *AutoUpdateVersion) Reset() { *x = AutoUpdateVersion{} - mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[2] + mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -189,7 +298,7 @@ func (x *AutoUpdateVersion) String() string { func (*AutoUpdateVersion) ProtoMessage() {} func (x *AutoUpdateVersion) ProtoReflect() protoreflect.Message { - mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[2] + mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -202,7 +311,7 @@ func (x *AutoUpdateVersion) ProtoReflect() protoreflect.Message { // Deprecated: Use AutoUpdateVersion.ProtoReflect.Descriptor instead. func (*AutoUpdateVersion) Descriptor() ([]byte, []int) { - return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{2} + return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{3} } func (x *AutoUpdateVersion) GetKind() string { @@ -247,12 +356,14 @@ type AutoUpdateVersionSpec struct { unknownFields protoimpl.UnknownFields // ToolsVersion is the semantic version required for tools autoupdates. - ToolsVersion string `protobuf:"bytes,1,opt,name=tools_version,json=toolsVersion,proto3" json:"tools_version,omitempty"` + // Deprecated: use AutoUpdateVersionTools instead. + ToolsVersion string `protobuf:"bytes,1,opt,name=tools_version,json=toolsVersion,proto3" json:"tools_version,omitempty"` + Tools *AutoUpdateVersionTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` } func (x *AutoUpdateVersionSpec) Reset() { *x = AutoUpdateVersionSpec{} - mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[3] + mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -264,7 +375,7 @@ func (x *AutoUpdateVersionSpec) String() string { func (*AutoUpdateVersionSpec) ProtoMessage() {} func (x *AutoUpdateVersionSpec) ProtoReflect() protoreflect.Message { - mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[3] + mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -277,7 +388,7 @@ func (x *AutoUpdateVersionSpec) ProtoReflect() protoreflect.Message { // Deprecated: Use AutoUpdateVersionSpec.ProtoReflect.Descriptor instead. func (*AutoUpdateVersionSpec) Descriptor() ([]byte, []int) { - return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{3} + return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{4} } func (x *AutoUpdateVersionSpec) GetToolsVersion() string { @@ -287,6 +398,60 @@ func (x *AutoUpdateVersionSpec) GetToolsVersion() string { return "" } +func (x *AutoUpdateVersionSpec) GetTools() *AutoUpdateVersionTools { + if x != nil { + return x.Tools + } + return nil +} + +// AutoUpdateVersionTools encodes the parameters for client tools auto updates. +type AutoUpdateVersionTools struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // TargetVersion is the semantic version required for tools autoupdates. + TargetVersion string `protobuf:"bytes,1,opt,name=target_version,json=targetVersion,proto3" json:"target_version,omitempty"` +} + +func (x *AutoUpdateVersionTools) Reset() { + *x = AutoUpdateVersionTools{} + mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AutoUpdateVersionTools) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AutoUpdateVersionTools) ProtoMessage() {} + +func (x *AutoUpdateVersionTools) ProtoReflect() protoreflect.Message { + mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AutoUpdateVersionTools.ProtoReflect.Descriptor instead. +func (*AutoUpdateVersionTools) Descriptor() ([]byte, []int) { + return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{5} +} + +func (x *AutoUpdateVersionTools) GetTargetVersion() string { + if x != nil { + return x.TargetVersion + } + return "" +} + var File_teleport_autoupdate_v1_autoupdate_proto protoreflect.FileDescriptor var file_teleport_autoupdate_v1_autoupdate_proto_rawDesc = []byte{ @@ -309,35 +474,59 @@ var file_teleport_autoupdate_v1_autoupdate_proto_rawDesc = []byte{ 0x73, 0x70, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x41, - 0x0a, 0x14, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x12, 0x29, 0x0a, 0x10, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, - 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0f, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x11, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, - 0x75, 0x62, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, - 0x75, 0x62, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x38, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x68, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x41, 0x0a, 0x04, 0x73, 0x70, - 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x3c, 0x0a, - 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, - 0x6f, 0x6f, 0x6c, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x56, 0x5a, 0x54, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69, 0x74, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, - 0x6f, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x75, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x86, + 0x01, 0x0a, 0x14, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x12, 0x29, 0x0a, 0x10, 0x74, 0x6f, 0x6f, 0x6c, 0x73, + 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x0f, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x12, 0x43, 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, + 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x54, 0x6f, 0x6f, 0x6c, 0x73, + 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x22, 0x4e, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x54, 0x6f, 0x6f, 0x6c, 0x73, + 0x12, 0x35, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, + 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x4d, 0x6f, 0x64, + 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x11, 0x41, 0x75, 0x74, 0x6f, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, + 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, + 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x12, 0x41, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, + 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, + 0x70, 0x65, 0x63, 0x22, 0x82, 0x01, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x12, 0x23, 0x0a, + 0x0d, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x44, 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2e, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, + 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6f, 0x6c, + 0x73, 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x22, 0x3f, 0x0a, 0x16, 0x41, 0x75, 0x74, 0x6f, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6f, + 0x6c, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2a, 0x58, 0x0a, 0x09, 0x54, 0x6f, 0x6f, + 0x6c, 0x73, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, + 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, + 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, 0x4d, 0x4f, 0x44, 0x45, + 0x5f, 0x45, 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x4f, + 0x4f, 0x4c, 0x53, 0x5f, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, + 0x44, 0x10, 0x02, 0x42, 0x56, 0x5a, 0x54, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, + 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, + 0x3b, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -352,24 +541,31 @@ func file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP() []byte { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescData } -var file_teleport_autoupdate_v1_autoupdate_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_teleport_autoupdate_v1_autoupdate_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_teleport_autoupdate_v1_autoupdate_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_teleport_autoupdate_v1_autoupdate_proto_goTypes = []any{ - (*AutoUpdateConfig)(nil), // 0: teleport.autoupdate.v1.AutoUpdateConfig - (*AutoUpdateConfigSpec)(nil), // 1: teleport.autoupdate.v1.AutoUpdateConfigSpec - (*AutoUpdateVersion)(nil), // 2: teleport.autoupdate.v1.AutoUpdateVersion - (*AutoUpdateVersionSpec)(nil), // 3: teleport.autoupdate.v1.AutoUpdateVersionSpec - (*v1.Metadata)(nil), // 4: teleport.header.v1.Metadata + (ToolsMode)(0), // 0: teleport.autoupdate.v1.ToolsMode + (*AutoUpdateConfig)(nil), // 1: teleport.autoupdate.v1.AutoUpdateConfig + (*AutoUpdateConfigSpec)(nil), // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec + (*AutoUpdateConfigTools)(nil), // 3: teleport.autoupdate.v1.AutoUpdateConfigTools + (*AutoUpdateVersion)(nil), // 4: teleport.autoupdate.v1.AutoUpdateVersion + (*AutoUpdateVersionSpec)(nil), // 5: teleport.autoupdate.v1.AutoUpdateVersionSpec + (*AutoUpdateVersionTools)(nil), // 6: teleport.autoupdate.v1.AutoUpdateVersionTools + (*v1.Metadata)(nil), // 7: teleport.header.v1.Metadata } var file_teleport_autoupdate_v1_autoupdate_proto_depIdxs = []int32{ - 4, // 0: teleport.autoupdate.v1.AutoUpdateConfig.metadata:type_name -> teleport.header.v1.Metadata - 1, // 1: teleport.autoupdate.v1.AutoUpdateConfig.spec:type_name -> teleport.autoupdate.v1.AutoUpdateConfigSpec - 4, // 2: teleport.autoupdate.v1.AutoUpdateVersion.metadata:type_name -> teleport.header.v1.Metadata - 3, // 3: teleport.autoupdate.v1.AutoUpdateVersion.spec:type_name -> teleport.autoupdate.v1.AutoUpdateVersionSpec - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 7, // 0: teleport.autoupdate.v1.AutoUpdateConfig.metadata:type_name -> teleport.header.v1.Metadata + 2, // 1: teleport.autoupdate.v1.AutoUpdateConfig.spec:type_name -> teleport.autoupdate.v1.AutoUpdateConfigSpec + 3, // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateConfigTools + 0, // 3: teleport.autoupdate.v1.AutoUpdateConfigTools.mode:type_name -> teleport.autoupdate.v1.ToolsMode + 7, // 4: teleport.autoupdate.v1.AutoUpdateVersion.metadata:type_name -> teleport.header.v1.Metadata + 5, // 5: teleport.autoupdate.v1.AutoUpdateVersion.spec:type_name -> teleport.autoupdate.v1.AutoUpdateVersionSpec + 6, // 6: teleport.autoupdate.v1.AutoUpdateVersionSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateVersionTools + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_teleport_autoupdate_v1_autoupdate_proto_init() } @@ -382,13 +578,14 @@ func file_teleport_autoupdate_v1_autoupdate_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_teleport_autoupdate_v1_autoupdate_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, + NumEnums: 1, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, GoTypes: file_teleport_autoupdate_v1_autoupdate_proto_goTypes, DependencyIndexes: file_teleport_autoupdate_v1_autoupdate_proto_depIdxs, + EnumInfos: file_teleport_autoupdate_v1_autoupdate_proto_enumTypes, MessageInfos: file_teleport_autoupdate_v1_autoupdate_proto_msgTypes, }.Build() File_teleport_autoupdate_v1_autoupdate_proto = out.File diff --git a/api/proto/teleport/autoupdate/v1/autoupdate.proto b/api/proto/teleport/autoupdate/v1/autoupdate.proto index 1987407fe7d81..180490072d753 100644 --- a/api/proto/teleport/autoupdate/v1/autoupdate.proto +++ b/api/proto/teleport/autoupdate/v1/autoupdate.proto @@ -34,7 +34,26 @@ message AutoUpdateConfig { // AutoUpdateConfigSpec encodes the parameters of the autoupdate config object. message AutoUpdateConfigSpec { // ToolsAutoupdate encodes the feature flag to enable/disable tools autoupdates. + // Deprecated: use AutoUpdateConfigTools instead. bool tools_autoupdate = 1; + + 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; +} + +// 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; } // AutoUpdateVersion is a resource singleton with version required for @@ -51,5 +70,14 @@ message AutoUpdateVersion { // AutoUpdateVersionSpec encodes the parameters of the autoupdate versions. message AutoUpdateVersionSpec { // ToolsVersion is the semantic version required for tools autoupdates. + // Deprecated: use AutoUpdateVersionTools instead. string tools_version = 1; + + AutoUpdateVersionTools tools = 2; +} + +// AutoUpdateVersionTools encodes the parameters for client tools auto updates. +message AutoUpdateVersionTools { + // TargetVersion is the semantic version required for tools autoupdates. + string target_version = 1; } diff --git a/api/types/autoupdate/config.go b/api/types/autoupdate/config.go index 5be3db89fd0c5..6bf3563fb1c7e 100644 --- a/api/types/autoupdate/config.go +++ b/api/types/autoupdate/config.go @@ -61,3 +61,15 @@ func ValidateAutoUpdateConfig(c *autoupdate.AutoUpdateConfig) error { return nil } + +// ToolsModeToAPI transforms client tools mode enum to API string representation. +func ToolsModeToAPI(mode autoupdate.ToolsMode) string { + switch mode { + case autoupdate.ToolsMode_TOOLS_MODE_ENABLED: + return "enabled" + case autoupdate.ToolsMode_TOOLS_MODE_DISABLED: + return "disabled" + default: + return "" + } +} diff --git a/api/types/autoupdate/version.go b/api/types/autoupdate/version.go index 088171a072ae3..ad2d12f265949 100644 --- a/api/types/autoupdate/version.go +++ b/api/types/autoupdate/version.go @@ -60,11 +60,13 @@ func ValidateAutoUpdateVersion(v *autoupdate.AutoUpdateVersion) error { return trace.BadParameter("Spec is nil") } - if v.Spec.ToolsVersion == "" { - return trace.BadParameter("ToolsVersion is unset") - } - if _, err := semver.NewVersion(v.Spec.ToolsVersion); err != nil { - return trace.BadParameter("ToolsVersion is not a valid semantic version") + if v.Spec.Tools != nil { + if v.Spec.Tools.TargetVersion == "" { + return trace.BadParameter("TargetVersion is unset") + } + if _, err := semver.NewVersion(v.Spec.Tools.TargetVersion); err != nil { + return trace.BadParameter("TargetVersion is not a valid semantic version") + } } return nil diff --git a/api/types/autoupdate/version_test.go b/api/types/autoupdate/version_test.go index 5fe4f167a037e..a08f03c934d0f 100644 --- a/api/types/autoupdate/version_test.go +++ b/api/types/autoupdate/version_test.go @@ -41,7 +41,9 @@ func TestNewAutoUpdateVersion(t *testing.T) { { name: "success tools autoupdate version", spec: &autoupdate.AutoUpdateVersionSpec{ - ToolsVersion: "1.2.3-dev", + Tools: &autoupdate.AutoUpdateVersionTools{ + TargetVersion: "1.2.3-dev", + }, }, assertErr: func(t *testing.T, err error, a ...any) { require.NoError(t, err) @@ -53,26 +55,32 @@ func TestNewAutoUpdateVersion(t *testing.T) { Name: types.MetaNameAutoUpdateVersion, }, Spec: &autoupdate.AutoUpdateVersionSpec{ - ToolsVersion: "1.2.3-dev", + Tools: &autoupdate.AutoUpdateVersionTools{ + TargetVersion: "1.2.3-dev", + }, }, }, }, { name: "invalid empty tools version", spec: &autoupdate.AutoUpdateVersionSpec{ - ToolsVersion: "", + Tools: &autoupdate.AutoUpdateVersionTools{ + TargetVersion: "", + }, }, assertErr: func(t *testing.T, err error, a ...any) { - require.ErrorContains(t, err, "ToolsVersion is unset") + require.ErrorContains(t, err, "TargetVersion is unset") }, }, { name: "invalid semantic tools version", spec: &autoupdate.AutoUpdateVersionSpec{ - ToolsVersion: "17-0-0", + Tools: &autoupdate.AutoUpdateVersionTools{ + TargetVersion: "17-0-0", + }, }, assertErr: func(t *testing.T, err error, a ...any) { - require.ErrorContains(t, err, "ToolsVersion is not a valid semantic version") + require.ErrorContains(t, err, "TargetVersion is not a valid semantic version") }, }, { diff --git a/lib/web/apiserver.go b/lib/web/apiserver.go index 8087b5e216194..23bb10c0c80e8 100644 --- a/lib/web/apiserver.go +++ b/lib/web/apiserver.go @@ -69,6 +69,7 @@ import ( "github.com/gravitational/teleport/api/mfa" apitracing "github.com/gravitational/teleport/api/observability/tracing" "github.com/gravitational/teleport/api/types" + "github.com/gravitational/teleport/api/types/autoupdate" apievents "github.com/gravitational/teleport/api/types/events" "github.com/gravitational/teleport/api/types/installers" "github.com/gravitational/teleport/api/utils/keys" @@ -1545,7 +1546,7 @@ func (h *Handler) find(w http.ResponseWriter, r *http.Request, p httprouter.Para if err != nil && !trace.IsNotFound(err) && !trace.IsNotImplemented(err) { h.logger.ErrorContext(r.Context(), "failed to receive AutoUpdateConfig", "error", err) } else if err == nil { - response.AutoUpdate.ToolsAutoUpdate = autoUpdateConfig.GetSpec().GetToolsAutoupdate() + response.AutoUpdate.ToolsMode = autoupdate.ToolsModeToAPI(autoUpdateConfig.GetSpec().GetTools().GetMode()) } autoUpdateVersion, err := h.cfg.AccessPoint.GetAutoUpdateVersion(r.Context()) @@ -1553,7 +1554,7 @@ func (h *Handler) find(w http.ResponseWriter, r *http.Request, p httprouter.Para if err != nil && !trace.IsNotFound(err) && !trace.IsNotImplemented(err) { h.logger.ErrorContext(r.Context(), "failed to receive AutoUpdateVersion", "error", err) } else if err == nil { - response.AutoUpdate.ToolsVersion = autoUpdateVersion.GetSpec().GetToolsVersion() + response.AutoUpdate.ToolsVersion = autoUpdateVersion.GetSpec().GetTools().GetTargetVersion() } return response, nil diff --git a/lib/web/apiserver_ping_test.go b/lib/web/apiserver_ping_test.go index 5a54fd2407555..971971cf0cf3c 100644 --- a/lib/web/apiserver_ping_test.go +++ b/lib/web/apiserver_ping_test.go @@ -275,28 +275,52 @@ func TestPing_autoUpdateResources(t *testing.T) { expected: webclient.AutoUpdateSettings{}, }, { - name: "enable auto update", - config: &autoupdatev1pb.AutoUpdateConfigSpec{ToolsAutoupdate: true}, - expected: webclient.AutoUpdateSettings{ToolsAutoUpdate: true}, + name: "enable auto update", + config: &autoupdatev1pb.AutoUpdateConfigSpec{ + Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Mode: autoupdatev1pb.ToolsMode_TOOLS_MODE_ENABLED, + }, + }, + expected: webclient.AutoUpdateSettings{ToolsMode: "enabled"}, cleanup: true, }, { - name: "set auto update version", - version: &autoupdatev1pb.AutoUpdateVersionSpec{ToolsVersion: "1.2.3"}, + name: "set auto update version", + version: &autoupdatev1pb.AutoUpdateVersionSpec{ + Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + TargetVersion: "1.2.3", + }, + }, expected: webclient.AutoUpdateSettings{ToolsVersion: "1.2.3"}, cleanup: true, }, { - name: "enable auto update and set version", - config: &autoupdatev1pb.AutoUpdateConfigSpec{ToolsAutoupdate: true}, - version: &autoupdatev1pb.AutoUpdateVersionSpec{ToolsVersion: "1.2.3"}, - expected: webclient.AutoUpdateSettings{ToolsAutoUpdate: true, ToolsVersion: "1.2.3"}, + name: "enable auto update and set version", + config: &autoupdatev1pb.AutoUpdateConfigSpec{ + Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Mode: autoupdatev1pb.ToolsMode_TOOLS_MODE_ENABLED, + }, + }, + version: &autoupdatev1pb.AutoUpdateVersionSpec{ + Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + TargetVersion: "1.2.3", + }, + }, + expected: webclient.AutoUpdateSettings{ToolsMode: "enabled", ToolsVersion: "1.2.3"}, }, { - name: "modify auto update config and version", - config: &autoupdatev1pb.AutoUpdateConfigSpec{ToolsAutoupdate: false}, - version: &autoupdatev1pb.AutoUpdateVersionSpec{ToolsVersion: "3.2.1"}, - expected: webclient.AutoUpdateSettings{ToolsAutoUpdate: false, ToolsVersion: "3.2.1"}, + name: "modify auto update config and version", + config: &autoupdatev1pb.AutoUpdateConfigSpec{ + Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Mode: autoupdatev1pb.ToolsMode_TOOLS_MODE_DISABLED, + }, + }, + version: &autoupdatev1pb.AutoUpdateVersionSpec{ + Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + TargetVersion: "3.2.1", + }, + }, + expected: webclient.AutoUpdateSettings{ToolsMode: "disabled", ToolsVersion: "3.2.1"}, }, } for _, tc := range tests { From b9449c9d537f0f296eb121afd9c797571725bfbc Mon Sep 17 00:00:00 2001 From: Vadym Popov Date: Tue, 15 Oct 2024 13:45:46 -0400 Subject: [PATCH 2/6] Replace with reserved --- .../teleport/autoupdate/v1/autoupdate.pb.go | 187 ++++++++---------- .../teleport/autoupdate/v1/autoupdate.proto | 28 ++- api/types/autoupdate/config.go | 6 +- api/types/autoupdate/config_test.go | 16 +- lib/web/apiserver_ping_test.go | 6 +- 5 files changed, 113 insertions(+), 130 deletions(-) diff --git a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go index 3a42d1fd5edb6..f96b39d417b69 100644 --- a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go +++ b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go @@ -36,55 +36,55 @@ const ( ) // ToolsMode type for client tools enabling state. -type ToolsMode int32 +type ToolsUpdateMode int32 const ( - // TOOLS_MODE_UNSPECIFIED is undefined mode. - ToolsMode_TOOLS_MODE_UNSPECIFIED ToolsMode = 0 - // TOOLS_MODE_ENABLED client tools auto update is enabled. - ToolsMode_TOOLS_MODE_ENABLED ToolsMode = 1 - // TOOLS_MODE_DISABLED client tools auto update is disabled. - ToolsMode_TOOLS_MODE_DISABLED ToolsMode = 2 + // TOOLS_UPDATE_MODE_UNSPECIFIED is undefined mode. + ToolsUpdateMode_TOOLS_UPDATE_MODE_UNSPECIFIED ToolsUpdateMode = 0 + // TOOLS_UPDATE_MODE_ENABLED client tools auto update is enabled. + ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED ToolsUpdateMode = 1 + // TOOLS_UPDATE_MODE_DISABLED client tools auto update is disabled. + ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED ToolsUpdateMode = 2 ) -// Enum value maps for ToolsMode. +// Enum value maps for ToolsUpdateMode. var ( - ToolsMode_name = map[int32]string{ - 0: "TOOLS_MODE_UNSPECIFIED", - 1: "TOOLS_MODE_ENABLED", - 2: "TOOLS_MODE_DISABLED", + ToolsUpdateMode_name = map[int32]string{ + 0: "TOOLS_UPDATE_MODE_UNSPECIFIED", + 1: "TOOLS_UPDATE_MODE_ENABLED", + 2: "TOOLS_UPDATE_MODE_DISABLED", } - ToolsMode_value = map[string]int32{ - "TOOLS_MODE_UNSPECIFIED": 0, - "TOOLS_MODE_ENABLED": 1, - "TOOLS_MODE_DISABLED": 2, + ToolsUpdateMode_value = map[string]int32{ + "TOOLS_UPDATE_MODE_UNSPECIFIED": 0, + "TOOLS_UPDATE_MODE_ENABLED": 1, + "TOOLS_UPDATE_MODE_DISABLED": 2, } ) -func (x ToolsMode) Enum() *ToolsMode { - p := new(ToolsMode) +func (x ToolsUpdateMode) Enum() *ToolsUpdateMode { + p := new(ToolsUpdateMode) *p = x return p } -func (x ToolsMode) String() string { +func (x ToolsUpdateMode) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (ToolsMode) Descriptor() protoreflect.EnumDescriptor { +func (ToolsUpdateMode) Descriptor() protoreflect.EnumDescriptor { return file_teleport_autoupdate_v1_autoupdate_proto_enumTypes[0].Descriptor() } -func (ToolsMode) Type() protoreflect.EnumType { +func (ToolsUpdateMode) Type() protoreflect.EnumType { return &file_teleport_autoupdate_v1_autoupdate_proto_enumTypes[0] } -func (x ToolsMode) Number() protoreflect.EnumNumber { +func (x ToolsUpdateMode) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use ToolsMode.Descriptor instead. -func (ToolsMode) EnumDescriptor() ([]byte, []int) { +// Deprecated: Use ToolsUpdateMode.Descriptor instead. +func (ToolsUpdateMode) EnumDescriptor() ([]byte, []int) { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{0} } @@ -173,10 +173,7 @@ type AutoUpdateConfigSpec struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // ToolsAutoupdate encodes the feature flag to enable/disable tools autoupdates. - // Deprecated: use AutoUpdateConfigTools instead. - ToolsAutoupdate bool `protobuf:"varint,1,opt,name=tools_autoupdate,json=toolsAutoupdate,proto3" json:"tools_autoupdate,omitempty"` - Tools *AutoUpdateConfigTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` + Tools *AutoUpdateConfigTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` } func (x *AutoUpdateConfigSpec) Reset() { @@ -209,13 +206,6 @@ func (*AutoUpdateConfigSpec) Descriptor() ([]byte, []int) { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{1} } -func (x *AutoUpdateConfigSpec) GetToolsAutoupdate() bool { - if x != nil { - return x.ToolsAutoupdate - } - return false -} - func (x *AutoUpdateConfigSpec) GetTools() *AutoUpdateConfigTools { if x != nil { return x.Tools @@ -230,7 +220,7 @@ type AutoUpdateConfigTools struct { unknownFields protoimpl.UnknownFields // Mode defines state of the client tools auto update. - Mode ToolsMode `protobuf:"varint,1,opt,name=mode,proto3,enum=teleport.autoupdate.v1.ToolsMode" json:"mode,omitempty"` + Mode ToolsUpdateMode `protobuf:"varint,1,opt,name=mode,proto3,enum=teleport.autoupdate.v1.ToolsUpdateMode" json:"mode,omitempty"` } func (x *AutoUpdateConfigTools) Reset() { @@ -263,11 +253,11 @@ func (*AutoUpdateConfigTools) Descriptor() ([]byte, []int) { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{2} } -func (x *AutoUpdateConfigTools) GetMode() ToolsMode { +func (x *AutoUpdateConfigTools) GetMode() ToolsUpdateMode { if x != nil { return x.Mode } - return ToolsMode_TOOLS_MODE_UNSPECIFIED + return ToolsUpdateMode_TOOLS_UPDATE_MODE_UNSPECIFIED } // AutoUpdateVersion is a resource singleton with version required for @@ -355,10 +345,7 @@ type AutoUpdateVersionSpec struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // ToolsVersion is the semantic version required for tools autoupdates. - // Deprecated: use AutoUpdateVersionTools instead. - ToolsVersion string `protobuf:"bytes,1,opt,name=tools_version,json=toolsVersion,proto3" json:"tools_version,omitempty"` - Tools *AutoUpdateVersionTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` + Tools *AutoUpdateVersionTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` } func (x *AutoUpdateVersionSpec) Reset() { @@ -391,13 +378,6 @@ func (*AutoUpdateVersionSpec) Descriptor() ([]byte, []int) { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{4} } -func (x *AutoUpdateVersionSpec) GetToolsVersion() string { - if x != nil { - return x.ToolsVersion - } - return "" -} - func (x *AutoUpdateVersionSpec) GetTools() *AutoUpdateVersionTools { if x != nil { return x.Tools @@ -474,59 +454,58 @@ var file_teleport_autoupdate_v1_autoupdate_proto_rawDesc = []byte{ 0x73, 0x70, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x86, - 0x01, 0x0a, 0x14, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x12, 0x29, 0x0a, 0x10, 0x74, 0x6f, 0x6f, 0x6c, 0x73, - 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0f, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x12, 0x43, 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, - 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x54, 0x6f, 0x6f, 0x6c, 0x73, - 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x22, 0x4e, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x54, 0x6f, 0x6f, 0x6c, 0x73, - 0x12, 0x35, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, - 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x4d, 0x6f, 0x64, - 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x11, 0x41, 0x75, 0x74, 0x6f, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, - 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, - 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x12, 0x41, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, - 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, - 0x70, 0x65, 0x63, 0x22, 0x82, 0x01, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x12, 0x23, 0x0a, - 0x0d, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x44, 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2e, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, - 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6f, 0x6c, - 0x73, 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x22, 0x3f, 0x0a, 0x16, 0x41, 0x75, 0x74, 0x6f, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6f, - 0x6c, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, - 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2a, 0x58, 0x0a, 0x09, 0x54, 0x6f, 0x6f, - 0x6c, 0x73, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, - 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, - 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, 0x4d, 0x4f, 0x44, 0x45, - 0x5f, 0x45, 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x4f, - 0x4f, 0x4c, 0x53, 0x5f, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, - 0x44, 0x10, 0x02, 0x42, 0x56, 0x5a, 0x54, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, - 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, - 0x3b, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x6e, 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x73, + 0x0a, 0x14, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x12, 0x43, 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, + 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x54, + 0x6f, 0x6f, 0x6c, 0x73, 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, + 0x02, 0x52, 0x10, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x22, 0x54, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x12, 0x3b, 0x0a, 0x04, + 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x74, 0x65, 0x6c, + 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, + 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x11, 0x41, 0x75, + 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, + 0x69, 0x6e, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6c, + 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x41, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x52, + 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x72, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x12, 0x44, + 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, + 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x52, 0x05, 0x74, + 0x6f, 0x6f, 0x6c, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x52, 0x0d, 0x74, 0x6f, 0x6f, 0x6c, + 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3f, 0x0a, 0x16, 0x41, 0x75, 0x74, + 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, + 0x6f, 0x6c, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2a, 0x73, 0x0a, 0x0f, 0x54, 0x6f, + 0x6f, 0x6c, 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x21, 0x0a, + 0x1d, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x4d, 0x4f, + 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x1d, 0x0a, 0x19, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, + 0x5f, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x45, 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x12, + 0x1e, 0x0a, 0x1a, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, + 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x02, 0x42, + 0x56, 0x5a, 0x54, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, + 0x61, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, + 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x61, + 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x75, 0x74, + 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -544,7 +523,7 @@ func file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP() []byte { var file_teleport_autoupdate_v1_autoupdate_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_teleport_autoupdate_v1_autoupdate_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_teleport_autoupdate_v1_autoupdate_proto_goTypes = []any{ - (ToolsMode)(0), // 0: teleport.autoupdate.v1.ToolsMode + (ToolsUpdateMode)(0), // 0: teleport.autoupdate.v1.ToolsUpdateMode (*AutoUpdateConfig)(nil), // 1: teleport.autoupdate.v1.AutoUpdateConfig (*AutoUpdateConfigSpec)(nil), // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec (*AutoUpdateConfigTools)(nil), // 3: teleport.autoupdate.v1.AutoUpdateConfigTools @@ -557,7 +536,7 @@ var file_teleport_autoupdate_v1_autoupdate_proto_depIdxs = []int32{ 7, // 0: teleport.autoupdate.v1.AutoUpdateConfig.metadata:type_name -> teleport.header.v1.Metadata 2, // 1: teleport.autoupdate.v1.AutoUpdateConfig.spec:type_name -> teleport.autoupdate.v1.AutoUpdateConfigSpec 3, // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateConfigTools - 0, // 3: teleport.autoupdate.v1.AutoUpdateConfigTools.mode:type_name -> teleport.autoupdate.v1.ToolsMode + 0, // 3: teleport.autoupdate.v1.AutoUpdateConfigTools.mode:type_name -> teleport.autoupdate.v1.ToolsUpdateMode 7, // 4: teleport.autoupdate.v1.AutoUpdateVersion.metadata:type_name -> teleport.header.v1.Metadata 5, // 5: teleport.autoupdate.v1.AutoUpdateVersion.spec:type_name -> teleport.autoupdate.v1.AutoUpdateVersionSpec 6, // 6: teleport.autoupdate.v1.AutoUpdateVersionSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateVersionTools diff --git a/api/proto/teleport/autoupdate/v1/autoupdate.proto b/api/proto/teleport/autoupdate/v1/autoupdate.proto index 180490072d753..b20b8c390bc6a 100644 --- a/api/proto/teleport/autoupdate/v1/autoupdate.proto +++ b/api/proto/teleport/autoupdate/v1/autoupdate.proto @@ -33,27 +33,25 @@ message AutoUpdateConfig { // AutoUpdateConfigSpec encodes the parameters of the autoupdate config object. message AutoUpdateConfigSpec { - // ToolsAutoupdate encodes the feature flag to enable/disable tools autoupdates. - // Deprecated: use AutoUpdateConfigTools instead. - bool tools_autoupdate = 1; - + reserved 1; + reserved "tools_autoupdate"; // 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 @@ -69,10 +67,8 @@ message AutoUpdateVersion { // AutoUpdateVersionSpec encodes the parameters of the autoupdate versions. message AutoUpdateVersionSpec { - // ToolsVersion is the semantic version required for tools autoupdates. - // Deprecated: use AutoUpdateVersionTools instead. - string tools_version = 1; - + reserved 1; + reserved "tools_version"; // ToolsVersion is replaced by tools.target_version. AutoUpdateVersionTools tools = 2; } diff --git a/api/types/autoupdate/config.go b/api/types/autoupdate/config.go index 6bf3563fb1c7e..5330fc8f33b09 100644 --- a/api/types/autoupdate/config.go +++ b/api/types/autoupdate/config.go @@ -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 "" diff --git a/api/types/autoupdate/config_test.go b/api/types/autoupdate/config_test.go index 2ee33dc5bf2b3..bdd1766f3a73f 100644 --- a/api/types/autoupdate/config_test.go +++ b/api/types/autoupdate/config_test.go @@ -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) @@ -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) @@ -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, + }, }, }, }, diff --git a/lib/web/apiserver_ping_test.go b/lib/web/apiserver_ping_test.go index 971971cf0cf3c..9b973667b4856 100644 --- a/lib/web/apiserver_ping_test.go +++ b/lib/web/apiserver_ping_test.go @@ -278,7 +278,7 @@ func TestPing_autoUpdateResources(t *testing.T) { name: "enable auto update", config: &autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigTools{ - Mode: autoupdatev1pb.ToolsMode_TOOLS_MODE_ENABLED, + Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }, expected: webclient.AutoUpdateSettings{ToolsMode: "enabled"}, @@ -298,7 +298,7 @@ func TestPing_autoUpdateResources(t *testing.T) { name: "enable auto update and set version", config: &autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigTools{ - Mode: autoupdatev1pb.ToolsMode_TOOLS_MODE_ENABLED, + Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }, version: &autoupdatev1pb.AutoUpdateVersionSpec{ @@ -312,7 +312,7 @@ func TestPing_autoUpdateResources(t *testing.T) { name: "modify auto update config and version", config: &autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigTools{ - Mode: autoupdatev1pb.ToolsMode_TOOLS_MODE_DISABLED, + Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, }, }, version: &autoupdatev1pb.AutoUpdateVersionSpec{ From 324813e2eb1df3066948dee813bd1f89e0c18e2b Mon Sep 17 00:00:00 2001 From: Vadym Popov Date: Tue, 15 Oct 2024 18:14:52 -0400 Subject: [PATCH 3/6] Fix unit tests --- lib/cache/cache_test.go | 8 +++- lib/services/local/autoupdate_test.go | 48 ++++++++++++++++++----- tool/tctl/common/collection.go | 5 ++- tool/tctl/common/edit_command_test.go | 32 +++++++++++---- tool/tctl/common/resource_command_test.go | 6 ++- 5 files changed, 75 insertions(+), 24 deletions(-) diff --git a/lib/cache/cache_test.go b/lib/cache/cache_test.go index d633a2548ad5b..e738f7f9fb5ea 100644 --- a/lib/cache/cache_test.go +++ b/lib/cache/cache_test.go @@ -3981,7 +3981,9 @@ func newAutoUpdateConfig(t *testing.T) *autoupdate.AutoUpdateConfig { t.Helper() r, err := update.NewAutoUpdateConfig(&autoupdate.AutoUpdateConfigSpec{ - ToolsAutoupdate: true, + Tools: &autoupdate.AutoUpdateConfigTools{ + Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + }, }) require.NoError(t, err) return r @@ -3991,7 +3993,9 @@ func newAutoUpdateVersion(t *testing.T) *autoupdate.AutoUpdateVersion { t.Helper() r, err := update.NewAutoUpdateVersion(&autoupdate.AutoUpdateVersionSpec{ - ToolsVersion: "1.2.3", + Tools: &autoupdate.AutoUpdateVersionTools{ + TargetVersion: "1.2.3", + }, }) require.NoError(t, err) return r diff --git a/lib/services/local/autoupdate_test.go b/lib/services/local/autoupdate_test.go index 77e13937ac47a..28334a6440807 100644 --- a/lib/services/local/autoupdate_test.go +++ b/lib/services/local/autoupdate_test.go @@ -51,7 +51,11 @@ func TestAutoUpdateServiceConfigCRUD(t *testing.T) { Kind: types.KindAutoUpdateConfig, Version: types.V1, Metadata: &headerv1.Metadata{Name: types.MetaNameAutoUpdateConfig}, - Spec: &autoupdatev1pb.AutoUpdateConfigSpec{ToolsAutoupdate: true}, + Spec: &autoupdatev1pb.AutoUpdateConfigSpec{ + Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + }, + }, } created, err := service.CreateAutoUpdateConfig(ctx, config) @@ -72,10 +76,12 @@ func TestAutoUpdateServiceConfigCRUD(t *testing.T) { require.Empty(t, diff) require.Equal(t, created.GetMetadata().GetRevision(), got.GetMetadata().GetRevision()) - config.Spec.ToolsAutoupdate = false + config.Spec.Tools = &autoupdatev1pb.AutoUpdateConfigTools{ + Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, + } updated, err := service.UpdateAutoUpdateConfig(ctx, config) require.NoError(t, err) - require.NotEqual(t, got.GetSpec().GetToolsAutoupdate(), updated.GetSpec().GetToolsAutoupdate()) + require.NotEqual(t, got.GetSpec().GetTools(), updated.GetSpec().GetTools()) _, err = service.UpsertAutoUpdateConfig(ctx, config) require.NoError(t, err) @@ -107,7 +113,11 @@ func TestAutoUpdateServiceVersionCRUD(t *testing.T) { Kind: types.KindAutoUpdateVersion, Version: types.V1, Metadata: &headerv1.Metadata{Name: types.MetaNameAutoUpdateVersion}, - Spec: &autoupdatev1pb.AutoUpdateVersionSpec{ToolsVersion: "1.2.3"}, + Spec: &autoupdatev1pb.AutoUpdateVersionSpec{ + Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + TargetVersion: "1.2.3", + }, + }, } created, err := service.CreateAutoUpdateVersion(ctx, version) @@ -128,10 +138,12 @@ func TestAutoUpdateServiceVersionCRUD(t *testing.T) { require.Empty(t, diff) require.Equal(t, created.GetMetadata().GetRevision(), got.GetMetadata().GetRevision()) - version.Spec.ToolsVersion = "3.2.1" + version.Spec.Tools = &autoupdatev1pb.AutoUpdateVersionTools{ + TargetVersion: "3.2.1", + } updated, err := service.UpdateAutoUpdateVersion(ctx, version) require.NoError(t, err) - require.NotEqual(t, got.GetSpec().GetToolsVersion(), updated.GetSpec().GetToolsVersion()) + require.NotEqual(t, got.GetSpec().GetTools().GetTargetVersion(), updated.GetSpec().GetTools().GetTargetVersion()) _, err = service.UpsertAutoUpdateVersion(ctx, version) require.NoError(t, err) @@ -163,7 +175,11 @@ func TestAutoUpdateServiceInvalidNameCreate(t *testing.T) { Kind: types.KindAutoUpdateConfig, Version: types.V1, Metadata: &headerv1.Metadata{Name: "invalid-auto-update-config-name"}, - Spec: &autoupdatev1pb.AutoUpdateConfigSpec{ToolsAutoupdate: true}, + Spec: &autoupdatev1pb.AutoUpdateConfigSpec{ + Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + }, + }, } createdConfig, err := service.CreateAutoUpdateConfig(ctx, config) @@ -174,7 +190,11 @@ func TestAutoUpdateServiceInvalidNameCreate(t *testing.T) { Kind: types.KindAutoUpdateVersion, Version: types.V1, Metadata: &headerv1.Metadata{Name: "invalid-auto-update-version-name"}, - Spec: &autoupdatev1pb.AutoUpdateVersionSpec{ToolsVersion: "1.2.3"}, + Spec: &autoupdatev1pb.AutoUpdateVersionSpec{ + Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + TargetVersion: "1.2.3", + }, + }, } createdVersion, err := service.CreateAutoUpdateVersion(ctx, version) @@ -196,7 +216,11 @@ func TestAutoUpdateServiceInvalidNameUpdate(t *testing.T) { ctx := context.Background() // Validate the config update restriction. - config, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ToolsAutoupdate: true}) + config, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ + Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + }, + }) require.NoError(t, err) createdConfig, err := service.UpsertAutoUpdateConfig(ctx, config) @@ -209,7 +233,11 @@ func TestAutoUpdateServiceInvalidNameUpdate(t *testing.T) { require.Nil(t, createdConfig) // Validate the version update restriction. - version, err := autoupdate.NewAutoUpdateVersion(&autoupdatev1pb.AutoUpdateVersionSpec{ToolsVersion: "1.2.3"}) + version, err := autoupdate.NewAutoUpdateVersion(&autoupdatev1pb.AutoUpdateVersionSpec{ + Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + TargetVersion: "1.2.3", + }, + }) require.NoError(t, err) createdVersion, err := service.UpsertAutoUpdateVersion(ctx, version) diff --git a/tool/tctl/common/collection.go b/tool/tctl/common/collection.go index d74bd31ceba2f..cb4b858fdaa27 100644 --- a/tool/tctl/common/collection.go +++ b/tool/tctl/common/collection.go @@ -44,6 +44,7 @@ import ( "github.com/gravitational/teleport/api/gen/proto/go/teleport/vnet/v1" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/api/types/accesslist" + "github.com/gravitational/teleport/api/types/autoupdate" "github.com/gravitational/teleport/api/types/discoveryconfig" "github.com/gravitational/teleport/api/types/externalauditstorage" "github.com/gravitational/teleport/api/types/label" @@ -1842,7 +1843,7 @@ func (c *autoUpdateConfigCollection) writeText(w io.Writer, verbose bool) error t := asciitable.MakeTable([]string{"Name", "Tools AutoUpdate Enabled"}) t.AddRow([]string{ c.config.GetMetadata().GetName(), - fmt.Sprintf("%v", c.config.GetSpec().GetToolsAutoupdate()), + fmt.Sprintf("%v", autoupdate.ToolsModeToAPI(c.config.GetSpec().GetTools().GetMode())), }) _, err := t.AsBuffer().WriteTo(w) return trace.Wrap(err) @@ -1860,7 +1861,7 @@ func (c *autoUpdateVersionCollection) writeText(w io.Writer, verbose bool) error t := asciitable.MakeTable([]string{"Name", "Tools AutoUpdate Version"}) t.AddRow([]string{ c.version.GetMetadata().GetName(), - fmt.Sprintf("%v", c.version.GetSpec().GetToolsVersion()), + fmt.Sprintf("%v", c.version.GetSpec().GetTools().TargetVersion), }) _, err := t.AsBuffer().WriteTo(w) return trace.Wrap(err) diff --git a/tool/tctl/common/edit_command_test.go b/tool/tctl/common/edit_command_test.go index c587080d33d86..d0a3901246cf1 100644 --- a/tool/tctl/common/edit_command_test.go +++ b/tool/tctl/common/edit_command_test.go @@ -556,10 +556,18 @@ func testEditStaticHostUser(t *testing.T, clt *authclient.Client) { func testEditAutoUpdateConfig(t *testing.T, clt *authclient.Client) { ctx := context.Background() - expected, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ToolsAutoupdate: true}) + expected, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ + Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + }, + }) require.NoError(t, err) - initial, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ToolsAutoupdate: false}) + initial, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ + Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, + }, + }) require.NoError(t, err) serviceClient := autoupdatev1pb.NewAutoUpdateServiceClient(clt.GetConnection()) @@ -582,18 +590,26 @@ func testEditAutoUpdateConfig(t *testing.T, clt *authclient.Client) { actual, err := clt.GetAutoUpdateConfig(ctx) require.NoError(t, err, "failed to get autoupdate config after edit") - assert.NotEqual(t, initial.GetSpec().GetToolsAutoupdate(), actual.GetSpec().GetToolsAutoupdate(), + assert.NotEqual(t, initial.GetSpec().GetTools().Mode, actual.GetSpec().GetTools().GetMode(), "tools_autoupdate should have been modified by edit") - assert.Equal(t, expected.GetSpec().GetToolsAutoupdate(), actual.GetSpec().GetToolsAutoupdate()) + assert.Equal(t, expected.GetSpec().GetTools().GetMode(), actual.GetSpec().GetTools().GetMode()) } func testEditAutoUpdateVersion(t *testing.T, clt *authclient.Client) { ctx := context.Background() - expected, err := autoupdate.NewAutoUpdateVersion(&autoupdatev1pb.AutoUpdateVersionSpec{ToolsVersion: "3.2.1"}) + expected, err := autoupdate.NewAutoUpdateVersion(&autoupdatev1pb.AutoUpdateVersionSpec{ + Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + TargetVersion: "3.2.1", + }, + }) require.NoError(t, err) - initial, err := autoupdate.NewAutoUpdateVersion(&autoupdatev1pb.AutoUpdateVersionSpec{ToolsVersion: "1.2.3"}) + initial, err := autoupdate.NewAutoUpdateVersion(&autoupdatev1pb.AutoUpdateVersionSpec{ + Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + TargetVersion: "1.2.3", + }, + }) require.NoError(t, err) serviceClient := autoupdatev1pb.NewAutoUpdateServiceClient(clt.GetConnection()) @@ -616,7 +632,7 @@ func testEditAutoUpdateVersion(t *testing.T, clt *authclient.Client) { actual, err := clt.GetAutoUpdateVersion(ctx) require.NoError(t, err, "failed to get autoupdate version after edit") - assert.NotEqual(t, initial.GetSpec().GetToolsVersion(), actual.GetSpec().GetToolsVersion(), + assert.NotEqual(t, initial.GetSpec().GetTools().GetTargetVersion(), actual.GetSpec().GetTools().GetTargetVersion(), "tools_autoupdate should have been modified by edit") - assert.Equal(t, expected.GetSpec().GetToolsVersion(), actual.GetSpec().GetToolsVersion()) + assert.Equal(t, expected.GetSpec().GetTools().GetTargetVersion(), actual.GetSpec().GetTools().GetTargetVersion()) } diff --git a/tool/tctl/common/resource_command_test.go b/tool/tctl/common/resource_command_test.go index 6ec25abb1507d..43a40f75bff65 100644 --- a/tool/tctl/common/resource_command_test.go +++ b/tool/tctl/common/resource_command_test.go @@ -2291,7 +2291,8 @@ metadata: name: autoupdate-config revision: 3a43b44a-201e-4d7f-aef1-ae2f6d9811ed spec: - tools_autoupdate: true + tools: + mode: 1 version: v1 ` _, err := runResourceCommand(t, clt, []string{"get", types.KindAutoUpdateConfig, "--format=json"}) @@ -2326,7 +2327,8 @@ metadata: name: autoupdate-version revision: 3a43b44a-201e-4d7f-aef1-ae2f6d9811ed spec: - tools_version: 1.2.3 + tools: + target_version: 1.2.3 version: v1 ` _, err := runResourceCommand(t, clt, []string{"get", types.KindAutoUpdateVersion, "--format=json"}) From ca422aa51dd8340edd2f7d37358ee52331fab5ad Mon Sep 17 00:00:00 2001 From: Vadym Popov Date: Wed, 16 Oct 2024 11:17:42 -0400 Subject: [PATCH 4/6] Add more info in proto --- api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go | 3 ++- api/proto/teleport/autoupdate/v1/autoupdate.proto | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go index f96b39d417b69..9740b774b4eb7 100644 --- a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go +++ b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go @@ -391,7 +391,8 @@ type AutoUpdateVersionTools struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // TargetVersion is the semantic version required for tools autoupdates. + // TargetVersion specifies the semantic version required for tools to establish a connection with the cluster. + // Client tools after connection to the cluster going to be updated to this version automatically. TargetVersion string `protobuf:"bytes,1,opt,name=target_version,json=targetVersion,proto3" json:"target_version,omitempty"` } diff --git a/api/proto/teleport/autoupdate/v1/autoupdate.proto b/api/proto/teleport/autoupdate/v1/autoupdate.proto index b20b8c390bc6a..2977c7fba9ea6 100644 --- a/api/proto/teleport/autoupdate/v1/autoupdate.proto +++ b/api/proto/teleport/autoupdate/v1/autoupdate.proto @@ -74,6 +74,7 @@ message AutoUpdateVersionSpec { // AutoUpdateVersionTools encodes the parameters for client tools auto updates. message AutoUpdateVersionTools { - // TargetVersion is the semantic version required for tools autoupdates. + // TargetVersion specifies the semantic version required for tools to establish a connection with the cluster. + // Client tools after connection to the cluster going to be updated to this version automatically. string target_version = 1; } From 1e3b6a4e5e1e7ef63455a6aad62674275235a5c0 Mon Sep 17 00:00:00 2001 From: Vadym Popov Date: Wed, 16 Oct 2024 15:16:06 -0400 Subject: [PATCH 5/6] Rename proto to be aligned RFD namings --- .../teleport/autoupdate/v1/autoupdate.pb.go | 139 +++++++++--------- .../teleport/autoupdate/v1/autoupdate.proto | 12 +- api/types/autoupdate/config_test.go | 8 +- api/types/autoupdate/version_test.go | 8 +- lib/cache/cache_test.go | 4 +- lib/services/local/autoupdate_test.go | 16 +- lib/web/apiserver_ping_test.go | 12 +- tool/tctl/common/edit_command_test.go | 8 +- 8 files changed, 104 insertions(+), 103 deletions(-) diff --git a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go index 9740b774b4eb7..8ffe6fbe9c170 100644 --- a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go +++ b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go @@ -173,7 +173,7 @@ type AutoUpdateConfigSpec struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Tools *AutoUpdateConfigTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` + Tools *AutoUpdateConfigSpecTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` } func (x *AutoUpdateConfigSpec) Reset() { @@ -206,15 +206,15 @@ func (*AutoUpdateConfigSpec) Descriptor() ([]byte, []int) { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{1} } -func (x *AutoUpdateConfigSpec) GetTools() *AutoUpdateConfigTools { +func (x *AutoUpdateConfigSpec) GetTools() *AutoUpdateConfigSpecTools { if x != nil { return x.Tools } return nil } -// AutoUpdateConfigTools encodes the parameters for client tools auto updates. -type AutoUpdateConfigTools struct { +// AutoUpdateConfigSpecTools encodes the parameters for client tools auto updates. +type AutoUpdateConfigSpecTools struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -223,20 +223,20 @@ type AutoUpdateConfigTools struct { Mode ToolsUpdateMode `protobuf:"varint,1,opt,name=mode,proto3,enum=teleport.autoupdate.v1.ToolsUpdateMode" json:"mode,omitempty"` } -func (x *AutoUpdateConfigTools) Reset() { - *x = AutoUpdateConfigTools{} +func (x *AutoUpdateConfigSpecTools) Reset() { + *x = AutoUpdateConfigSpecTools{} mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *AutoUpdateConfigTools) String() string { +func (x *AutoUpdateConfigSpecTools) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AutoUpdateConfigTools) ProtoMessage() {} +func (*AutoUpdateConfigSpecTools) ProtoMessage() {} -func (x *AutoUpdateConfigTools) ProtoReflect() protoreflect.Message { +func (x *AutoUpdateConfigSpecTools) ProtoReflect() protoreflect.Message { mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -248,12 +248,12 @@ func (x *AutoUpdateConfigTools) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AutoUpdateConfigTools.ProtoReflect.Descriptor instead. -func (*AutoUpdateConfigTools) Descriptor() ([]byte, []int) { +// Deprecated: Use AutoUpdateConfigSpecTools.ProtoReflect.Descriptor instead. +func (*AutoUpdateConfigSpecTools) Descriptor() ([]byte, []int) { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{2} } -func (x *AutoUpdateConfigTools) GetMode() ToolsUpdateMode { +func (x *AutoUpdateConfigSpecTools) GetMode() ToolsUpdateMode { if x != nil { return x.Mode } @@ -345,7 +345,7 @@ type AutoUpdateVersionSpec struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Tools *AutoUpdateVersionTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` + Tools *AutoUpdateVersionSpecTools `protobuf:"bytes,2,opt,name=tools,proto3" json:"tools,omitempty"` } func (x *AutoUpdateVersionSpec) Reset() { @@ -378,15 +378,15 @@ func (*AutoUpdateVersionSpec) Descriptor() ([]byte, []int) { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{4} } -func (x *AutoUpdateVersionSpec) GetTools() *AutoUpdateVersionTools { +func (x *AutoUpdateVersionSpec) GetTools() *AutoUpdateVersionSpecTools { if x != nil { return x.Tools } return nil } -// AutoUpdateVersionTools encodes the parameters for client tools auto updates. -type AutoUpdateVersionTools struct { +// AutoUpdateVersionSpecTools encodes the parameters for client tools auto updates. +type AutoUpdateVersionSpecTools struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -396,20 +396,20 @@ type AutoUpdateVersionTools struct { TargetVersion string `protobuf:"bytes,1,opt,name=target_version,json=targetVersion,proto3" json:"target_version,omitempty"` } -func (x *AutoUpdateVersionTools) Reset() { - *x = AutoUpdateVersionTools{} +func (x *AutoUpdateVersionSpecTools) Reset() { + *x = AutoUpdateVersionSpecTools{} mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *AutoUpdateVersionTools) String() string { +func (x *AutoUpdateVersionSpecTools) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AutoUpdateVersionTools) ProtoMessage() {} +func (*AutoUpdateVersionSpecTools) ProtoMessage() {} -func (x *AutoUpdateVersionTools) ProtoReflect() protoreflect.Message { +func (x *AutoUpdateVersionSpecTools) ProtoReflect() protoreflect.Message { mi := &file_teleport_autoupdate_v1_autoupdate_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -421,12 +421,12 @@ func (x *AutoUpdateVersionTools) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AutoUpdateVersionTools.ProtoReflect.Descriptor instead. -func (*AutoUpdateVersionTools) Descriptor() ([]byte, []int) { +// Deprecated: Use AutoUpdateVersionSpecTools.ProtoReflect.Descriptor instead. +func (*AutoUpdateVersionSpecTools) Descriptor() ([]byte, []int) { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{5} } -func (x *AutoUpdateVersionTools) GetTargetVersion() string { +func (x *AutoUpdateVersionSpecTools) GetTargetVersion() string { if x != nil { return x.TargetVersion } @@ -455,42 +455,43 @@ var file_teleport_autoupdate_v1_autoupdate_proto_rawDesc = []byte{ 0x73, 0x70, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x73, + 0x6e, 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x77, 0x0a, 0x14, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x12, 0x43, 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x12, 0x47, 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, - 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x54, - 0x6f, 0x6f, 0x6c, 0x73, 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, - 0x02, 0x52, 0x10, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x22, 0x54, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x12, 0x3b, 0x0a, 0x04, - 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x74, 0x65, 0x6c, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, - 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x11, 0x41, 0x75, - 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, - 0x69, 0x6e, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6c, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x12, 0x41, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x52, - 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x72, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x12, 0x44, - 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, - 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x52, 0x05, 0x74, - 0x6f, 0x6f, 0x6c, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x52, 0x0d, 0x74, 0x6f, 0x6f, 0x6c, - 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3f, 0x0a, 0x16, 0x41, 0x75, 0x74, - 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, + 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, + 0x70, 0x65, 0x63, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x4a, + 0x04, 0x08, 0x01, 0x10, 0x02, 0x52, 0x10, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, 0x61, 0x75, 0x74, + 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x58, 0x0a, 0x19, 0x41, 0x75, 0x74, 0x6f, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x54, + 0x6f, 0x6f, 0x6c, 0x73, 0x12, 0x3b, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, + 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6f, 0x6c, + 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, + 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x11, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, + 0x75, 0x62, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, + 0x75, 0x62, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x38, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x68, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x41, 0x0a, 0x04, 0x73, 0x70, + 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x76, 0x0a, + 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x12, 0x48, 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, + 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x53, 0x70, 0x65, 0x63, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, + 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x52, 0x0d, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x43, 0x0a, 0x1a, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2a, 0x73, 0x0a, 0x0f, 0x54, 0x6f, @@ -524,23 +525,23 @@ func file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP() []byte { var file_teleport_autoupdate_v1_autoupdate_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_teleport_autoupdate_v1_autoupdate_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_teleport_autoupdate_v1_autoupdate_proto_goTypes = []any{ - (ToolsUpdateMode)(0), // 0: teleport.autoupdate.v1.ToolsUpdateMode - (*AutoUpdateConfig)(nil), // 1: teleport.autoupdate.v1.AutoUpdateConfig - (*AutoUpdateConfigSpec)(nil), // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec - (*AutoUpdateConfigTools)(nil), // 3: teleport.autoupdate.v1.AutoUpdateConfigTools - (*AutoUpdateVersion)(nil), // 4: teleport.autoupdate.v1.AutoUpdateVersion - (*AutoUpdateVersionSpec)(nil), // 5: teleport.autoupdate.v1.AutoUpdateVersionSpec - (*AutoUpdateVersionTools)(nil), // 6: teleport.autoupdate.v1.AutoUpdateVersionTools - (*v1.Metadata)(nil), // 7: teleport.header.v1.Metadata + (ToolsUpdateMode)(0), // 0: teleport.autoupdate.v1.ToolsUpdateMode + (*AutoUpdateConfig)(nil), // 1: teleport.autoupdate.v1.AutoUpdateConfig + (*AutoUpdateConfigSpec)(nil), // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec + (*AutoUpdateConfigSpecTools)(nil), // 3: teleport.autoupdate.v1.AutoUpdateConfigSpecTools + (*AutoUpdateVersion)(nil), // 4: teleport.autoupdate.v1.AutoUpdateVersion + (*AutoUpdateVersionSpec)(nil), // 5: teleport.autoupdate.v1.AutoUpdateVersionSpec + (*AutoUpdateVersionSpecTools)(nil), // 6: teleport.autoupdate.v1.AutoUpdateVersionSpecTools + (*v1.Metadata)(nil), // 7: teleport.header.v1.Metadata } var file_teleport_autoupdate_v1_autoupdate_proto_depIdxs = []int32{ 7, // 0: teleport.autoupdate.v1.AutoUpdateConfig.metadata:type_name -> teleport.header.v1.Metadata 2, // 1: teleport.autoupdate.v1.AutoUpdateConfig.spec:type_name -> teleport.autoupdate.v1.AutoUpdateConfigSpec - 3, // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateConfigTools - 0, // 3: teleport.autoupdate.v1.AutoUpdateConfigTools.mode:type_name -> teleport.autoupdate.v1.ToolsUpdateMode + 3, // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateConfigSpecTools + 0, // 3: teleport.autoupdate.v1.AutoUpdateConfigSpecTools.mode:type_name -> teleport.autoupdate.v1.ToolsUpdateMode 7, // 4: teleport.autoupdate.v1.AutoUpdateVersion.metadata:type_name -> teleport.header.v1.Metadata 5, // 5: teleport.autoupdate.v1.AutoUpdateVersion.spec:type_name -> teleport.autoupdate.v1.AutoUpdateVersionSpec - 6, // 6: teleport.autoupdate.v1.AutoUpdateVersionSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateVersionTools + 6, // 6: teleport.autoupdate.v1.AutoUpdateVersionSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateVersionSpecTools 7, // [7:7] is the sub-list for method output_type 7, // [7:7] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name diff --git a/api/proto/teleport/autoupdate/v1/autoupdate.proto b/api/proto/teleport/autoupdate/v1/autoupdate.proto index 2977c7fba9ea6..1f42f27f55163 100644 --- a/api/proto/teleport/autoupdate/v1/autoupdate.proto +++ b/api/proto/teleport/autoupdate/v1/autoupdate.proto @@ -35,11 +35,11 @@ message AutoUpdateConfig { message AutoUpdateConfigSpec { reserved 1; reserved "tools_autoupdate"; // ToolsAutoupdate is replaced by tools.mode. - AutoUpdateConfigTools tools = 2; + AutoUpdateConfigSpecTools tools = 2; } -// AutoUpdateConfigTools encodes the parameters for client tools auto updates. -message AutoUpdateConfigTools { +// AutoUpdateConfigSpecTools encodes the parameters for client tools auto updates. +message AutoUpdateConfigSpecTools { // Mode defines state of the client tools auto update. ToolsUpdateMode mode = 1; } @@ -69,11 +69,11 @@ message AutoUpdateVersion { message AutoUpdateVersionSpec { reserved 1; reserved "tools_version"; // ToolsVersion is replaced by tools.target_version. - AutoUpdateVersionTools tools = 2; + AutoUpdateVersionSpecTools tools = 2; } -// AutoUpdateVersionTools encodes the parameters for client tools auto updates. -message AutoUpdateVersionTools { +// AutoUpdateVersionSpecTools encodes the parameters for client tools auto updates. +message AutoUpdateVersionSpecTools { // TargetVersion specifies the semantic version required for tools to establish a connection with the cluster. // Client tools after connection to the cluster going to be updated to this version automatically. string target_version = 1; diff --git a/api/types/autoupdate/config_test.go b/api/types/autoupdate/config_test.go index bdd1766f3a73f..d23a03741393b 100644 --- a/api/types/autoupdate/config_test.go +++ b/api/types/autoupdate/config_test.go @@ -41,7 +41,7 @@ func TestNewAutoUpdateConfig(t *testing.T) { { name: "success tools autoupdate disabled", spec: &autoupdate.AutoUpdateConfigSpec{ - Tools: &autoupdate.AutoUpdateConfigTools{ + Tools: &autoupdate.AutoUpdateConfigSpecTools{ Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, }, }, @@ -55,7 +55,7 @@ func TestNewAutoUpdateConfig(t *testing.T) { Name: types.MetaNameAutoUpdateConfig, }, Spec: &autoupdate.AutoUpdateConfigSpec{ - Tools: &autoupdate.AutoUpdateConfigTools{ + Tools: &autoupdate.AutoUpdateConfigSpecTools{ Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, }, }, @@ -64,7 +64,7 @@ func TestNewAutoUpdateConfig(t *testing.T) { { name: "success tools autoupdate enabled", spec: &autoupdate.AutoUpdateConfigSpec{ - Tools: &autoupdate.AutoUpdateConfigTools{ + Tools: &autoupdate.AutoUpdateConfigSpecTools{ Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }, @@ -78,7 +78,7 @@ func TestNewAutoUpdateConfig(t *testing.T) { Name: types.MetaNameAutoUpdateConfig, }, Spec: &autoupdate.AutoUpdateConfigSpec{ - Tools: &autoupdate.AutoUpdateConfigTools{ + Tools: &autoupdate.AutoUpdateConfigSpecTools{ Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }, diff --git a/api/types/autoupdate/version_test.go b/api/types/autoupdate/version_test.go index a08f03c934d0f..70790a204b219 100644 --- a/api/types/autoupdate/version_test.go +++ b/api/types/autoupdate/version_test.go @@ -41,7 +41,7 @@ func TestNewAutoUpdateVersion(t *testing.T) { { name: "success tools autoupdate version", spec: &autoupdate.AutoUpdateVersionSpec{ - Tools: &autoupdate.AutoUpdateVersionTools{ + Tools: &autoupdate.AutoUpdateVersionSpecTools{ TargetVersion: "1.2.3-dev", }, }, @@ -55,7 +55,7 @@ func TestNewAutoUpdateVersion(t *testing.T) { Name: types.MetaNameAutoUpdateVersion, }, Spec: &autoupdate.AutoUpdateVersionSpec{ - Tools: &autoupdate.AutoUpdateVersionTools{ + Tools: &autoupdate.AutoUpdateVersionSpecTools{ TargetVersion: "1.2.3-dev", }, }, @@ -64,7 +64,7 @@ func TestNewAutoUpdateVersion(t *testing.T) { { name: "invalid empty tools version", spec: &autoupdate.AutoUpdateVersionSpec{ - Tools: &autoupdate.AutoUpdateVersionTools{ + Tools: &autoupdate.AutoUpdateVersionSpecTools{ TargetVersion: "", }, }, @@ -75,7 +75,7 @@ func TestNewAutoUpdateVersion(t *testing.T) { { name: "invalid semantic tools version", spec: &autoupdate.AutoUpdateVersionSpec{ - Tools: &autoupdate.AutoUpdateVersionTools{ + Tools: &autoupdate.AutoUpdateVersionSpecTools{ TargetVersion: "17-0-0", }, }, diff --git a/lib/cache/cache_test.go b/lib/cache/cache_test.go index e738f7f9fb5ea..f0efc34c45805 100644 --- a/lib/cache/cache_test.go +++ b/lib/cache/cache_test.go @@ -3981,7 +3981,7 @@ func newAutoUpdateConfig(t *testing.T) *autoupdate.AutoUpdateConfig { t.Helper() r, err := update.NewAutoUpdateConfig(&autoupdate.AutoUpdateConfigSpec{ - Tools: &autoupdate.AutoUpdateConfigTools{ + Tools: &autoupdate.AutoUpdateConfigSpecTools{ Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }) @@ -3993,7 +3993,7 @@ func newAutoUpdateVersion(t *testing.T) *autoupdate.AutoUpdateVersion { t.Helper() r, err := update.NewAutoUpdateVersion(&autoupdate.AutoUpdateVersionSpec{ - Tools: &autoupdate.AutoUpdateVersionTools{ + Tools: &autoupdate.AutoUpdateVersionSpecTools{ TargetVersion: "1.2.3", }, }) diff --git a/lib/services/local/autoupdate_test.go b/lib/services/local/autoupdate_test.go index 28334a6440807..9bbfef2b37abd 100644 --- a/lib/services/local/autoupdate_test.go +++ b/lib/services/local/autoupdate_test.go @@ -52,7 +52,7 @@ func TestAutoUpdateServiceConfigCRUD(t *testing.T) { Version: types.V1, Metadata: &headerv1.Metadata{Name: types.MetaNameAutoUpdateConfig}, Spec: &autoupdatev1pb.AutoUpdateConfigSpec{ - Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }, @@ -76,7 +76,7 @@ func TestAutoUpdateServiceConfigCRUD(t *testing.T) { require.Empty(t, diff) require.Equal(t, created.GetMetadata().GetRevision(), got.GetMetadata().GetRevision()) - config.Spec.Tools = &autoupdatev1pb.AutoUpdateConfigTools{ + config.Spec.Tools = &autoupdatev1pb.AutoUpdateConfigSpecTools{ Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, } updated, err := service.UpdateAutoUpdateConfig(ctx, config) @@ -114,7 +114,7 @@ func TestAutoUpdateServiceVersionCRUD(t *testing.T) { Version: types.V1, Metadata: &headerv1.Metadata{Name: types.MetaNameAutoUpdateVersion}, Spec: &autoupdatev1pb.AutoUpdateVersionSpec{ - Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + Tools: &autoupdatev1pb.AutoUpdateVersionSpecTools{ TargetVersion: "1.2.3", }, }, @@ -138,7 +138,7 @@ func TestAutoUpdateServiceVersionCRUD(t *testing.T) { require.Empty(t, diff) require.Equal(t, created.GetMetadata().GetRevision(), got.GetMetadata().GetRevision()) - version.Spec.Tools = &autoupdatev1pb.AutoUpdateVersionTools{ + version.Spec.Tools = &autoupdatev1pb.AutoUpdateVersionSpecTools{ TargetVersion: "3.2.1", } updated, err := service.UpdateAutoUpdateVersion(ctx, version) @@ -176,7 +176,7 @@ func TestAutoUpdateServiceInvalidNameCreate(t *testing.T) { Version: types.V1, Metadata: &headerv1.Metadata{Name: "invalid-auto-update-config-name"}, Spec: &autoupdatev1pb.AutoUpdateConfigSpec{ - Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }, @@ -191,7 +191,7 @@ func TestAutoUpdateServiceInvalidNameCreate(t *testing.T) { Version: types.V1, Metadata: &headerv1.Metadata{Name: "invalid-auto-update-version-name"}, Spec: &autoupdatev1pb.AutoUpdateVersionSpec{ - Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + Tools: &autoupdatev1pb.AutoUpdateVersionSpecTools{ TargetVersion: "1.2.3", }, }, @@ -217,7 +217,7 @@ func TestAutoUpdateServiceInvalidNameUpdate(t *testing.T) { // Validate the config update restriction. config, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ - Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }) @@ -234,7 +234,7 @@ func TestAutoUpdateServiceInvalidNameUpdate(t *testing.T) { // Validate the version update restriction. version, err := autoupdate.NewAutoUpdateVersion(&autoupdatev1pb.AutoUpdateVersionSpec{ - Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + Tools: &autoupdatev1pb.AutoUpdateVersionSpecTools{ TargetVersion: "1.2.3", }, }) diff --git a/lib/web/apiserver_ping_test.go b/lib/web/apiserver_ping_test.go index 9b973667b4856..dab434f73ca39 100644 --- a/lib/web/apiserver_ping_test.go +++ b/lib/web/apiserver_ping_test.go @@ -277,7 +277,7 @@ func TestPing_autoUpdateResources(t *testing.T) { { name: "enable auto update", config: &autoupdatev1pb.AutoUpdateConfigSpec{ - Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }, @@ -287,7 +287,7 @@ func TestPing_autoUpdateResources(t *testing.T) { { name: "set auto update version", version: &autoupdatev1pb.AutoUpdateVersionSpec{ - Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + Tools: &autoupdatev1pb.AutoUpdateVersionSpecTools{ TargetVersion: "1.2.3", }, }, @@ -297,12 +297,12 @@ func TestPing_autoUpdateResources(t *testing.T) { { name: "enable auto update and set version", config: &autoupdatev1pb.AutoUpdateConfigSpec{ - Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }, version: &autoupdatev1pb.AutoUpdateVersionSpec{ - Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + Tools: &autoupdatev1pb.AutoUpdateVersionSpecTools{ TargetVersion: "1.2.3", }, }, @@ -311,12 +311,12 @@ func TestPing_autoUpdateResources(t *testing.T) { { name: "modify auto update config and version", config: &autoupdatev1pb.AutoUpdateConfigSpec{ - Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, }, }, version: &autoupdatev1pb.AutoUpdateVersionSpec{ - Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + Tools: &autoupdatev1pb.AutoUpdateVersionSpecTools{ TargetVersion: "3.2.1", }, }, diff --git a/tool/tctl/common/edit_command_test.go b/tool/tctl/common/edit_command_test.go index d0a3901246cf1..3bc70555068c8 100644 --- a/tool/tctl/common/edit_command_test.go +++ b/tool/tctl/common/edit_command_test.go @@ -557,14 +557,14 @@ func testEditAutoUpdateConfig(t *testing.T, clt *authclient.Client) { ctx := context.Background() expected, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ - Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, }, }) require.NoError(t, err) initial, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ - Tools: &autoupdatev1pb.AutoUpdateConfigTools{ + Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, }, }) @@ -599,14 +599,14 @@ func testEditAutoUpdateVersion(t *testing.T, clt *authclient.Client) { ctx := context.Background() expected, err := autoupdate.NewAutoUpdateVersion(&autoupdatev1pb.AutoUpdateVersionSpec{ - Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + Tools: &autoupdatev1pb.AutoUpdateVersionSpecTools{ TargetVersion: "3.2.1", }, }) require.NoError(t, err) initial, err := autoupdate.NewAutoUpdateVersion(&autoupdatev1pb.AutoUpdateVersionSpec{ - Tools: &autoupdatev1pb.AutoUpdateVersionTools{ + Tools: &autoupdatev1pb.AutoUpdateVersionSpecTools{ TargetVersion: "1.2.3", }, }) From 4544f499d51ebffe3e769cdd947e11603a496913 Mon Sep 17 00:00:00 2001 From: Vadym Popov Date: Wed, 16 Oct 2024 20:11:55 -0400 Subject: [PATCH 6/6] Replace enum type for ToolsMode to string --- .../teleport/autoupdate/v1/autoupdate.pb.go | 180 ++++++------------ .../teleport/autoupdate/v1/autoupdate.proto | 12 +- api/types/autoupdate/config.go | 24 +-- api/types/autoupdate/config_test.go | 19 +- lib/cache/cache_test.go | 2 +- lib/services/local/autoupdate_test.go | 8 +- lib/web/apiserver.go | 3 +- lib/web/apiserver_ping_test.go | 6 +- tool/tctl/common/collection.go | 3 +- tool/tctl/common/edit_command_test.go | 4 +- tool/tctl/common/resource_command_test.go | 2 +- 11 files changed, 98 insertions(+), 165 deletions(-) diff --git a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go index 8ffe6fbe9c170..be298bcc51b60 100644 --- a/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go +++ b/api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go @@ -35,59 +35,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// ToolsMode type for client tools enabling state. -type ToolsUpdateMode int32 - -const ( - // TOOLS_UPDATE_MODE_UNSPECIFIED is undefined mode. - ToolsUpdateMode_TOOLS_UPDATE_MODE_UNSPECIFIED ToolsUpdateMode = 0 - // TOOLS_UPDATE_MODE_ENABLED client tools auto update is enabled. - ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED ToolsUpdateMode = 1 - // TOOLS_UPDATE_MODE_DISABLED client tools auto update is disabled. - ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED ToolsUpdateMode = 2 -) - -// Enum value maps for ToolsUpdateMode. -var ( - ToolsUpdateMode_name = map[int32]string{ - 0: "TOOLS_UPDATE_MODE_UNSPECIFIED", - 1: "TOOLS_UPDATE_MODE_ENABLED", - 2: "TOOLS_UPDATE_MODE_DISABLED", - } - ToolsUpdateMode_value = map[string]int32{ - "TOOLS_UPDATE_MODE_UNSPECIFIED": 0, - "TOOLS_UPDATE_MODE_ENABLED": 1, - "TOOLS_UPDATE_MODE_DISABLED": 2, - } -) - -func (x ToolsUpdateMode) Enum() *ToolsUpdateMode { - p := new(ToolsUpdateMode) - *p = x - return p -} - -func (x ToolsUpdateMode) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ToolsUpdateMode) Descriptor() protoreflect.EnumDescriptor { - return file_teleport_autoupdate_v1_autoupdate_proto_enumTypes[0].Descriptor() -} - -func (ToolsUpdateMode) Type() protoreflect.EnumType { - return &file_teleport_autoupdate_v1_autoupdate_proto_enumTypes[0] -} - -func (x ToolsUpdateMode) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ToolsUpdateMode.Descriptor instead. -func (ToolsUpdateMode) EnumDescriptor() ([]byte, []int) { - return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{0} -} - // AutoUpdateConfig is a config singleton used to configure cluster // autoupdate settings. type AutoUpdateConfig struct { @@ -220,7 +167,7 @@ type AutoUpdateConfigSpecTools struct { unknownFields protoimpl.UnknownFields // Mode defines state of the client tools auto update. - Mode ToolsUpdateMode `protobuf:"varint,1,opt,name=mode,proto3,enum=teleport.autoupdate.v1.ToolsUpdateMode" json:"mode,omitempty"` + Mode string `protobuf:"bytes,1,opt,name=mode,proto3" json:"mode,omitempty"` } func (x *AutoUpdateConfigSpecTools) Reset() { @@ -253,11 +200,11 @@ func (*AutoUpdateConfigSpecTools) Descriptor() ([]byte, []int) { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP(), []int{2} } -func (x *AutoUpdateConfigSpecTools) GetMode() ToolsUpdateMode { +func (x *AutoUpdateConfigSpecTools) GetMode() string { if x != nil { return x.Mode } - return ToolsUpdateMode_TOOLS_UPDATE_MODE_UNSPECIFIED + return "" } // AutoUpdateVersion is a resource singleton with version required for @@ -463,51 +410,42 @@ var file_teleport_autoupdate_v1_autoupdate_proto_rawDesc = []byte{ 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x52, 0x10, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, 0x61, 0x75, 0x74, - 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x58, 0x0a, 0x19, 0x41, 0x75, 0x74, 0x6f, 0x55, + 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x2f, 0x0a, 0x19, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x70, 0x65, 0x63, 0x54, - 0x6f, 0x6f, 0x6c, 0x73, 0x12, 0x3b, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, - 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6f, 0x6c, - 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, - 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x11, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, - 0x75, 0x62, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, - 0x75, 0x62, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x38, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x68, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x41, 0x0a, 0x04, 0x73, 0x70, - 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x76, 0x0a, - 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x12, 0x48, 0x0a, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, - 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x53, 0x70, 0x65, 0x63, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, - 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x52, 0x0d, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x5f, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x43, 0x0a, 0x1a, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x54, 0x6f, - 0x6f, 0x6c, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2a, 0x73, 0x0a, 0x0f, 0x54, 0x6f, - 0x6f, 0x6c, 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x21, 0x0a, - 0x1d, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x4d, 0x4f, - 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x1d, 0x0a, 0x19, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, - 0x5f, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x45, 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x12, - 0x1e, 0x0a, 0x1a, 0x54, 0x4f, 0x4f, 0x4c, 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, - 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x02, 0x42, - 0x56, 0x5a, 0x54, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, - 0x61, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, - 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x61, - 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x75, 0x74, - 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6f, 0x6c, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x11, 0x41, 0x75, 0x74, + 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, + 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, + 0x6e, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6c, 0x65, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x41, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, + 0x73, 0x70, 0x65, 0x63, 0x22, 0x76, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x12, 0x48, 0x0a, + 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x74, + 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x70, 0x65, 0x63, 0x54, 0x6f, 0x6f, 0x6c, 0x73, + 0x52, 0x05, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x52, 0x0d, 0x74, + 0x6f, 0x6f, 0x6c, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x43, 0x0a, 0x1a, + 0x41, 0x75, 0x74, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x53, 0x70, 0x65, 0x63, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x42, 0x56, 0x5a, 0x54, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x67, 0x72, 0x61, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, + 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x61, + 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -522,31 +460,28 @@ func file_teleport_autoupdate_v1_autoupdate_proto_rawDescGZIP() []byte { return file_teleport_autoupdate_v1_autoupdate_proto_rawDescData } -var file_teleport_autoupdate_v1_autoupdate_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_teleport_autoupdate_v1_autoupdate_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_teleport_autoupdate_v1_autoupdate_proto_goTypes = []any{ - (ToolsUpdateMode)(0), // 0: teleport.autoupdate.v1.ToolsUpdateMode - (*AutoUpdateConfig)(nil), // 1: teleport.autoupdate.v1.AutoUpdateConfig - (*AutoUpdateConfigSpec)(nil), // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec - (*AutoUpdateConfigSpecTools)(nil), // 3: teleport.autoupdate.v1.AutoUpdateConfigSpecTools - (*AutoUpdateVersion)(nil), // 4: teleport.autoupdate.v1.AutoUpdateVersion - (*AutoUpdateVersionSpec)(nil), // 5: teleport.autoupdate.v1.AutoUpdateVersionSpec - (*AutoUpdateVersionSpecTools)(nil), // 6: teleport.autoupdate.v1.AutoUpdateVersionSpecTools - (*v1.Metadata)(nil), // 7: teleport.header.v1.Metadata + (*AutoUpdateConfig)(nil), // 0: teleport.autoupdate.v1.AutoUpdateConfig + (*AutoUpdateConfigSpec)(nil), // 1: teleport.autoupdate.v1.AutoUpdateConfigSpec + (*AutoUpdateConfigSpecTools)(nil), // 2: teleport.autoupdate.v1.AutoUpdateConfigSpecTools + (*AutoUpdateVersion)(nil), // 3: teleport.autoupdate.v1.AutoUpdateVersion + (*AutoUpdateVersionSpec)(nil), // 4: teleport.autoupdate.v1.AutoUpdateVersionSpec + (*AutoUpdateVersionSpecTools)(nil), // 5: teleport.autoupdate.v1.AutoUpdateVersionSpecTools + (*v1.Metadata)(nil), // 6: teleport.header.v1.Metadata } var file_teleport_autoupdate_v1_autoupdate_proto_depIdxs = []int32{ - 7, // 0: teleport.autoupdate.v1.AutoUpdateConfig.metadata:type_name -> teleport.header.v1.Metadata - 2, // 1: teleport.autoupdate.v1.AutoUpdateConfig.spec:type_name -> teleport.autoupdate.v1.AutoUpdateConfigSpec - 3, // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateConfigSpecTools - 0, // 3: teleport.autoupdate.v1.AutoUpdateConfigSpecTools.mode:type_name -> teleport.autoupdate.v1.ToolsUpdateMode - 7, // 4: teleport.autoupdate.v1.AutoUpdateVersion.metadata:type_name -> teleport.header.v1.Metadata - 5, // 5: teleport.autoupdate.v1.AutoUpdateVersion.spec:type_name -> teleport.autoupdate.v1.AutoUpdateVersionSpec - 6, // 6: teleport.autoupdate.v1.AutoUpdateVersionSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateVersionSpecTools - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 6, // 0: teleport.autoupdate.v1.AutoUpdateConfig.metadata:type_name -> teleport.header.v1.Metadata + 1, // 1: teleport.autoupdate.v1.AutoUpdateConfig.spec:type_name -> teleport.autoupdate.v1.AutoUpdateConfigSpec + 2, // 2: teleport.autoupdate.v1.AutoUpdateConfigSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateConfigSpecTools + 6, // 3: teleport.autoupdate.v1.AutoUpdateVersion.metadata:type_name -> teleport.header.v1.Metadata + 4, // 4: teleport.autoupdate.v1.AutoUpdateVersion.spec:type_name -> teleport.autoupdate.v1.AutoUpdateVersionSpec + 5, // 5: teleport.autoupdate.v1.AutoUpdateVersionSpec.tools:type_name -> teleport.autoupdate.v1.AutoUpdateVersionSpecTools + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_teleport_autoupdate_v1_autoupdate_proto_init() } @@ -559,14 +494,13 @@ func file_teleport_autoupdate_v1_autoupdate_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_teleport_autoupdate_v1_autoupdate_proto_rawDesc, - NumEnums: 1, + NumEnums: 0, NumMessages: 6, NumExtensions: 0, NumServices: 0, }, GoTypes: file_teleport_autoupdate_v1_autoupdate_proto_goTypes, DependencyIndexes: file_teleport_autoupdate_v1_autoupdate_proto_depIdxs, - EnumInfos: file_teleport_autoupdate_v1_autoupdate_proto_enumTypes, MessageInfos: file_teleport_autoupdate_v1_autoupdate_proto_msgTypes, }.Build() File_teleport_autoupdate_v1_autoupdate_proto = out.File diff --git a/api/proto/teleport/autoupdate/v1/autoupdate.proto b/api/proto/teleport/autoupdate/v1/autoupdate.proto index 1f42f27f55163..b4e557549b316 100644 --- a/api/proto/teleport/autoupdate/v1/autoupdate.proto +++ b/api/proto/teleport/autoupdate/v1/autoupdate.proto @@ -41,17 +41,7 @@ message AutoUpdateConfigSpec { // AutoUpdateConfigSpecTools encodes the parameters for client tools auto updates. message AutoUpdateConfigSpecTools { // Mode defines state of the client tools auto update. - ToolsUpdateMode mode = 1; -} - -// ToolsMode type for client tools enabling state. -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; + string mode = 1; } // AutoUpdateVersion is a resource singleton with version required for diff --git a/api/types/autoupdate/config.go b/api/types/autoupdate/config.go index 5330fc8f33b09..d61c35eccf0c2 100644 --- a/api/types/autoupdate/config.go +++ b/api/types/autoupdate/config.go @@ -26,6 +26,13 @@ import ( "github.com/gravitational/teleport/api/types" ) +const ( + // ToolsUpdateModeEnabled enables client tools automatic updates. + ToolsUpdateModeEnabled = "enabled" + // ToolsUpdateModeDisabled disables client tools automatic updates. + ToolsUpdateModeDisabled = "disabled" +) + // NewAutoUpdateConfig creates a new auto update configuration resource. func NewAutoUpdateConfig(spec *autoupdate.AutoUpdateConfigSpec) (*autoupdate.AutoUpdateConfig, error) { config := &autoupdate.AutoUpdateConfig{ @@ -58,18 +65,11 @@ func ValidateAutoUpdateConfig(c *autoupdate.AutoUpdateConfig) error { if c.Spec == nil { return trace.BadParameter("Spec is nil") } + if c.Spec.Tools != nil { + if c.Spec.Tools.Mode != ToolsUpdateModeDisabled && c.Spec.Tools.Mode != ToolsUpdateModeEnabled { + return trace.BadParameter("ToolsMode is not valid") + } + } return nil } - -// ToolsModeToAPI transforms client tools mode enum to API string representation. -func ToolsModeToAPI(mode autoupdate.ToolsUpdateMode) string { - switch mode { - case autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED: - return "enabled" - case autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED: - return "disabled" - default: - return "" - } -} diff --git a/api/types/autoupdate/config_test.go b/api/types/autoupdate/config_test.go index d23a03741393b..443d6f246fa56 100644 --- a/api/types/autoupdate/config_test.go +++ b/api/types/autoupdate/config_test.go @@ -42,7 +42,7 @@ func TestNewAutoUpdateConfig(t *testing.T) { name: "success tools autoupdate disabled", spec: &autoupdate.AutoUpdateConfigSpec{ Tools: &autoupdate.AutoUpdateConfigSpecTools{ - Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, + Mode: ToolsUpdateModeDisabled, }, }, assertErr: func(t *testing.T, err error, a ...any) { @@ -56,7 +56,7 @@ func TestNewAutoUpdateConfig(t *testing.T) { }, Spec: &autoupdate.AutoUpdateConfigSpec{ Tools: &autoupdate.AutoUpdateConfigSpecTools{ - Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, + Mode: ToolsUpdateModeDisabled, }, }, }, @@ -65,7 +65,7 @@ func TestNewAutoUpdateConfig(t *testing.T) { name: "success tools autoupdate enabled", spec: &autoupdate.AutoUpdateConfigSpec{ Tools: &autoupdate.AutoUpdateConfigSpecTools{ - Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + Mode: ToolsUpdateModeEnabled, }, }, assertErr: func(t *testing.T, err error, a ...any) { @@ -79,7 +79,7 @@ func TestNewAutoUpdateConfig(t *testing.T) { }, Spec: &autoupdate.AutoUpdateConfigSpec{ Tools: &autoupdate.AutoUpdateConfigSpecTools{ - Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + Mode: ToolsUpdateModeEnabled, }, }, }, @@ -91,6 +91,17 @@ func TestNewAutoUpdateConfig(t *testing.T) { require.ErrorContains(t, err, "Spec is nil") }, }, + { + name: "invalid tools mode", + spec: &autoupdate.AutoUpdateConfigSpec{ + Tools: &autoupdate.AutoUpdateConfigSpecTools{ + Mode: "invalid-mode", + }, + }, + assertErr: func(t *testing.T, err error, a ...any) { + require.ErrorContains(t, err, "ToolsMode is not valid") + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/lib/cache/cache_test.go b/lib/cache/cache_test.go index f0efc34c45805..3eb514c79e1ad 100644 --- a/lib/cache/cache_test.go +++ b/lib/cache/cache_test.go @@ -3982,7 +3982,7 @@ func newAutoUpdateConfig(t *testing.T) *autoupdate.AutoUpdateConfig { r, err := update.NewAutoUpdateConfig(&autoupdate.AutoUpdateConfigSpec{ Tools: &autoupdate.AutoUpdateConfigSpecTools{ - Mode: autoupdate.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + Mode: update.ToolsUpdateModeEnabled, }, }) require.NoError(t, err) diff --git a/lib/services/local/autoupdate_test.go b/lib/services/local/autoupdate_test.go index 9bbfef2b37abd..ae858d65cc47c 100644 --- a/lib/services/local/autoupdate_test.go +++ b/lib/services/local/autoupdate_test.go @@ -53,7 +53,7 @@ func TestAutoUpdateServiceConfigCRUD(t *testing.T) { Metadata: &headerv1.Metadata{Name: types.MetaNameAutoUpdateConfig}, Spec: &autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ - Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + Mode: autoupdate.ToolsUpdateModeEnabled, }, }, } @@ -77,7 +77,7 @@ func TestAutoUpdateServiceConfigCRUD(t *testing.T) { require.Equal(t, created.GetMetadata().GetRevision(), got.GetMetadata().GetRevision()) config.Spec.Tools = &autoupdatev1pb.AutoUpdateConfigSpecTools{ - Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, + Mode: autoupdate.ToolsUpdateModeDisabled, } updated, err := service.UpdateAutoUpdateConfig(ctx, config) require.NoError(t, err) @@ -177,7 +177,7 @@ func TestAutoUpdateServiceInvalidNameCreate(t *testing.T) { Metadata: &headerv1.Metadata{Name: "invalid-auto-update-config-name"}, Spec: &autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ - Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + Mode: autoupdate.ToolsUpdateModeEnabled, }, }, } @@ -218,7 +218,7 @@ func TestAutoUpdateServiceInvalidNameUpdate(t *testing.T) { // Validate the config update restriction. config, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ - Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + Mode: autoupdate.ToolsUpdateModeEnabled, }, }) require.NoError(t, err) diff --git a/lib/web/apiserver.go b/lib/web/apiserver.go index 23bb10c0c80e8..90ab76eafee2a 100644 --- a/lib/web/apiserver.go +++ b/lib/web/apiserver.go @@ -69,7 +69,6 @@ import ( "github.com/gravitational/teleport/api/mfa" apitracing "github.com/gravitational/teleport/api/observability/tracing" "github.com/gravitational/teleport/api/types" - "github.com/gravitational/teleport/api/types/autoupdate" apievents "github.com/gravitational/teleport/api/types/events" "github.com/gravitational/teleport/api/types/installers" "github.com/gravitational/teleport/api/utils/keys" @@ -1546,7 +1545,7 @@ func (h *Handler) find(w http.ResponseWriter, r *http.Request, p httprouter.Para if err != nil && !trace.IsNotFound(err) && !trace.IsNotImplemented(err) { h.logger.ErrorContext(r.Context(), "failed to receive AutoUpdateConfig", "error", err) } else if err == nil { - response.AutoUpdate.ToolsMode = autoupdate.ToolsModeToAPI(autoUpdateConfig.GetSpec().GetTools().GetMode()) + response.AutoUpdate.ToolsMode = autoUpdateConfig.GetSpec().GetTools().GetMode() } autoUpdateVersion, err := h.cfg.AccessPoint.GetAutoUpdateVersion(r.Context()) diff --git a/lib/web/apiserver_ping_test.go b/lib/web/apiserver_ping_test.go index dab434f73ca39..9da34384b4ea5 100644 --- a/lib/web/apiserver_ping_test.go +++ b/lib/web/apiserver_ping_test.go @@ -278,7 +278,7 @@ func TestPing_autoUpdateResources(t *testing.T) { name: "enable auto update", config: &autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ - Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + Mode: autoupdate.ToolsUpdateModeEnabled, }, }, expected: webclient.AutoUpdateSettings{ToolsMode: "enabled"}, @@ -298,7 +298,7 @@ func TestPing_autoUpdateResources(t *testing.T) { name: "enable auto update and set version", config: &autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ - Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + Mode: autoupdate.ToolsUpdateModeEnabled, }, }, version: &autoupdatev1pb.AutoUpdateVersionSpec{ @@ -312,7 +312,7 @@ func TestPing_autoUpdateResources(t *testing.T) { name: "modify auto update config and version", config: &autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ - Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, + Mode: autoupdate.ToolsUpdateModeDisabled, }, }, version: &autoupdatev1pb.AutoUpdateVersionSpec{ diff --git a/tool/tctl/common/collection.go b/tool/tctl/common/collection.go index cb4b858fdaa27..0d10de79c610b 100644 --- a/tool/tctl/common/collection.go +++ b/tool/tctl/common/collection.go @@ -44,7 +44,6 @@ import ( "github.com/gravitational/teleport/api/gen/proto/go/teleport/vnet/v1" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/api/types/accesslist" - "github.com/gravitational/teleport/api/types/autoupdate" "github.com/gravitational/teleport/api/types/discoveryconfig" "github.com/gravitational/teleport/api/types/externalauditstorage" "github.com/gravitational/teleport/api/types/label" @@ -1843,7 +1842,7 @@ func (c *autoUpdateConfigCollection) writeText(w io.Writer, verbose bool) error t := asciitable.MakeTable([]string{"Name", "Tools AutoUpdate Enabled"}) t.AddRow([]string{ c.config.GetMetadata().GetName(), - fmt.Sprintf("%v", autoupdate.ToolsModeToAPI(c.config.GetSpec().GetTools().GetMode())), + fmt.Sprintf("%v", c.config.GetSpec().GetTools().GetMode()), }) _, err := t.AsBuffer().WriteTo(w) return trace.Wrap(err) diff --git a/tool/tctl/common/edit_command_test.go b/tool/tctl/common/edit_command_test.go index 3bc70555068c8..869508b9e674d 100644 --- a/tool/tctl/common/edit_command_test.go +++ b/tool/tctl/common/edit_command_test.go @@ -558,14 +558,14 @@ func testEditAutoUpdateConfig(t *testing.T, clt *authclient.Client) { expected, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ - Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_ENABLED, + Mode: autoupdate.ToolsUpdateModeEnabled, }, }) require.NoError(t, err) initial, err := autoupdate.NewAutoUpdateConfig(&autoupdatev1pb.AutoUpdateConfigSpec{ Tools: &autoupdatev1pb.AutoUpdateConfigSpecTools{ - Mode: autoupdatev1pb.ToolsUpdateMode_TOOLS_UPDATE_MODE_DISABLED, + Mode: autoupdate.ToolsUpdateModeDisabled, }, }) require.NoError(t, err) diff --git a/tool/tctl/common/resource_command_test.go b/tool/tctl/common/resource_command_test.go index 43a40f75bff65..31eb14f62bbea 100644 --- a/tool/tctl/common/resource_command_test.go +++ b/tool/tctl/common/resource_command_test.go @@ -2292,7 +2292,7 @@ metadata: revision: 3a43b44a-201e-4d7f-aef1-ae2f6d9811ed spec: tools: - mode: 1 + mode: enabled version: v1 ` _, err := runResourceCommand(t, clt, []string{"get", types.KindAutoUpdateConfig, "--format=json"})