From 5bdd8a46ea294a41b4784b621136d8afd740e273 Mon Sep 17 00:00:00 2001 From: Michael Gaffney Date: Mon, 1 Jun 2020 11:46:50 -0400 Subject: [PATCH] Extract timestamp scanners into reusable package (#91) * Refactor: move Timestamp from static/store to db/timestamp * Refactor: convert remaining Timestamps to timestamp.Timestamp * Use new db timestamp --- internal/db/db_test/db.go | 29 -- internal/db/db_test/db_test.pb.go | 263 ++++++---------- internal/db/read_writer_test.go | 5 +- .../static/store => db/timestamp}/scanners.go | 6 +- .../store => db/timestamp}/scanners_test.go | 2 +- .../store => db/timestamp}/timestamp.pb.go | 73 ++--- internal/host/static/store/static.pb.go | 293 +++++++----------- internal/iam/repository_scope_test.go | 3 +- internal/iam/repository_test.go | 3 +- internal/iam/store/scanners.go | 33 -- internal/iam/store/scanners_test.go | 73 ----- internal/iam/store/scope.pb.go | 26 +- internal/oplog/store/oplog.pb.go | 270 ++++++---------- internal/oplog/store/scanners.go | 33 -- internal/oplog/store/scanners_test.go | 73 ----- .../storage/db/db_test/v1/db_test.proto | 21 +- .../storage/host/static/store/v1/static.proto | 23 +- .../storage/iam/store/v1/scope.proto | 8 +- .../storage/oplog/store/v1/oplog.proto | 21 +- .../store => timestamp}/v1/timestamp.proto | 6 +- 20 files changed, 398 insertions(+), 866 deletions(-) rename internal/{host/static/store => db/timestamp}/scanners.go (81%) rename internal/{host/static/store => db/timestamp}/scanners_test.go (99%) rename internal/{iam/store => db/timestamp}/timestamp.pb.go (63%) delete mode 100644 internal/iam/store/scanners.go delete mode 100644 internal/iam/store/scanners_test.go delete mode 100644 internal/oplog/store/scanners.go delete mode 100644 internal/oplog/store/scanners_test.go rename internal/proto/local/controller/storage/{iam/store => timestamp}/v1/timestamp.proto (61%) diff --git a/internal/db/db_test/db.go b/internal/db/db_test/db.go index bfe7788a7..4933d1653 100644 --- a/internal/db/db_test/db.go +++ b/internal/db/db_test/db.go @@ -2,12 +2,6 @@ package db_test import ( - "database/sql/driver" - "errors" - "fmt" - "time" - - "github.com/golang/protobuf/ptypes" "github.com/hashicorp/vault/sdk/helper/base62" "google.golang.org/protobuf/proto" ) @@ -107,26 +101,3 @@ func (r *TestRental) SetTableName(name string) { r.table = name } } - -// Scan supports Timestamps for oplogs -func (ts *Timestamp) Scan(value interface{}) error { - switch t := value.(type) { - case time.Time: - var err error - ts.Timestamp, err = ptypes.TimestampProto(t) // google proto version - if err != nil { - return fmt.Errorf("error converting the timestamp: %w", err) - } - default: - return errors.New("Not a protobuf Timestamp") - } - return nil -} - -// Value supports Timestamps for oplogs -func (ts *Timestamp) Value() (driver.Value, error) { - if ts == nil { - return nil, nil - } - return ptypes.Timestamp(ts.Timestamp) -} diff --git a/internal/db/db_test/db_test.pb.go b/internal/db/db_test/db_test.pb.go index 31af810c8..3517e35e8 100644 --- a/internal/db/db_test/db_test.pb.go +++ b/internal/db/db_test/db_test.pb.go @@ -12,7 +12,7 @@ package db_test import ( proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" + timestamp "github.com/hashicorp/watchtower/internal/db/timestamp" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -30,54 +30,6 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 -// Timestamp for oplog messages -type Timestamp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamp.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` -} - -func (x *Timestamp) Reset() { - *x = Timestamp{} - if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Timestamp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Timestamp) ProtoMessage() {} - -func (x *Timestamp) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Timestamp.ProtoReflect.Descriptor instead. -func (*Timestamp) Descriptor() ([]byte, []int) { - return file_controller_storage_db_db_test_v1_db_test_proto_rawDescGZIP(), []int{0} -} - -func (x *Timestamp) GetTimestamp() *timestamp.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - // TestUser for gorm test user model type StoreTestUser struct { state protoimpl.MessageState @@ -88,10 +40,10 @@ type StoreTestUser struct { Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` + UpdateTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // public_id is the used to access the AssignablScope via an API PublicId string `protobuf:"bytes,4,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty"` // name is the optional friendly name used to @@ -105,7 +57,7 @@ type StoreTestUser struct { func (x *StoreTestUser) Reset() { *x = StoreTestUser{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[1] + mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -118,7 +70,7 @@ func (x *StoreTestUser) String() string { func (*StoreTestUser) ProtoMessage() {} func (x *StoreTestUser) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[1] + mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -131,7 +83,7 @@ func (x *StoreTestUser) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreTestUser.ProtoReflect.Descriptor instead. func (*StoreTestUser) Descriptor() ([]byte, []int) { - return file_controller_storage_db_db_test_v1_db_test_proto_rawDescGZIP(), []int{1} + return file_controller_storage_db_db_test_v1_db_test_proto_rawDescGZIP(), []int{0} } func (x *StoreTestUser) GetId() uint32 { @@ -141,14 +93,14 @@ func (x *StoreTestUser) GetId() uint32 { return 0 } -func (x *StoreTestUser) GetCreateTime() *Timestamp { +func (x *StoreTestUser) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *StoreTestUser) GetUpdateTime() *Timestamp { +func (x *StoreTestUser) GetUpdateTime() *timestamp.Timestamp { if x != nil { return x.UpdateTime } @@ -193,10 +145,10 @@ type StoreTestCar struct { Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` + UpdateTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // public_id is the used to access the AssignablScope via an API PublicId string `protobuf:"bytes,4,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty"` // name is the optional friendly name used to @@ -210,7 +162,7 @@ type StoreTestCar struct { func (x *StoreTestCar) Reset() { *x = StoreTestCar{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[2] + mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -223,7 +175,7 @@ func (x *StoreTestCar) String() string { func (*StoreTestCar) ProtoMessage() {} func (x *StoreTestCar) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[2] + mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -236,7 +188,7 @@ func (x *StoreTestCar) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreTestCar.ProtoReflect.Descriptor instead. func (*StoreTestCar) Descriptor() ([]byte, []int) { - return file_controller_storage_db_db_test_v1_db_test_proto_rawDescGZIP(), []int{2} + return file_controller_storage_db_db_test_v1_db_test_proto_rawDescGZIP(), []int{1} } func (x *StoreTestCar) GetId() uint32 { @@ -246,14 +198,14 @@ func (x *StoreTestCar) GetId() uint32 { return 0 } -func (x *StoreTestCar) GetCreateTime() *Timestamp { +func (x *StoreTestCar) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *StoreTestCar) GetUpdateTime() *Timestamp { +func (x *StoreTestCar) GetUpdateTime() *timestamp.Timestamp { if x != nil { return x.UpdateTime } @@ -298,10 +250,10 @@ type StoreTestRental struct { Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` + UpdateTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // public_id is the used to access the AssignablScope via an API PublicId string `protobuf:"bytes,4,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty"` // name is the optional friendly name used to @@ -315,7 +267,7 @@ type StoreTestRental struct { func (x *StoreTestRental) Reset() { *x = StoreTestRental{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[3] + mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -328,7 +280,7 @@ func (x *StoreTestRental) String() string { func (*StoreTestRental) ProtoMessage() {} func (x *StoreTestRental) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[3] + mi := &file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -341,7 +293,7 @@ func (x *StoreTestRental) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreTestRental.ProtoReflect.Descriptor instead. func (*StoreTestRental) Descriptor() ([]byte, []int) { - return file_controller_storage_db_db_test_v1_db_test_proto_rawDescGZIP(), []int{3} + return file_controller_storage_db_db_test_v1_db_test_proto_rawDescGZIP(), []int{2} } func (x *StoreTestRental) GetId() uint32 { @@ -351,14 +303,14 @@ func (x *StoreTestRental) GetId() uint32 { return 0 } -func (x *StoreTestRental) GetCreateTime() *Timestamp { +func (x *StoreTestRental) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *StoreTestRental) GetUpdateTime() *Timestamp { +func (x *StoreTestRental) GetUpdateTime() *timestamp.Timestamp { if x != nil { return x.UpdateTime } @@ -401,71 +353,68 @@ var file_controller_storage_db_db_test_v1_db_test_proto_rawDesc = []byte{ 0x76, 0x31, 0x2f, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x62, 0x2e, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, - 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xa5, 0x02, 0x0a, 0x0d, 0x53, - 0x74, 0x6f, 0x72, 0x65, 0x54, 0x65, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4c, 0x0a, 0x0b, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x62, 0x2e, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, - 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4c, 0x0a, 0x0b, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x62, 0x2e, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, - 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x68, 0x6f, - 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, - 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, - 0x69, 0x6c, 0x22, 0x93, 0x02, 0x0a, 0x0c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x54, 0x65, 0x73, 0x74, - 0x43, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x4c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x62, - 0x2e, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, - 0x65, 0x12, 0x4c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x62, 0x2e, 0x64, - 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x76, 0x31, 0x1a, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x02, 0x0a, 0x0d, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x54, 0x65, 0x73, + 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x70, 0x67, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x03, 0x6d, 0x70, 0x67, 0x22, 0x9e, 0x02, 0x0a, 0x0f, 0x53, 0x74, 0x6f, - 0x72, 0x65, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4c, 0x0a, 0x0b, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x62, 0x2e, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, - 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4c, 0x0a, 0x0b, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x62, 0x2e, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, - 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, - 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x63, 0x61, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x05, 0x63, 0x61, 0x72, 0x49, 0x64, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, - 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x64, 0x62, 0x2f, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, - 0x3b, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x91, 0x02, 0x0a, 0x0c, 0x53, 0x74, + 0x6f, 0x72, 0x65, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, + 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, + 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, + 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x6d, + 0x70, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6d, 0x70, 0x67, 0x22, 0x9c, 0x02, + 0x0a, 0x0f, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x6e, 0x74, 0x61, + 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, + 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, + 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, + 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x75, + 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x63, 0x61, 0x72, 0x5f, 0x69, 0x64, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x63, 0x61, 0x72, 0x49, 0x64, 0x42, 0x3d, 0x5a, 0x3b, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, + 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x64, 0x62, 0x2f, 0x64, 0x62, 0x5f, 0x74, + 0x65, 0x73, 0x74, 0x3b, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -480,27 +429,25 @@ func file_controller_storage_db_db_test_v1_db_test_proto_rawDescGZIP() []byte { return file_controller_storage_db_db_test_v1_db_test_proto_rawDescData } -var file_controller_storage_db_db_test_v1_db_test_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_controller_storage_db_db_test_v1_db_test_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_controller_storage_db_db_test_v1_db_test_proto_goTypes = []interface{}{ - (*Timestamp)(nil), // 0: controller.storage.db.db_test.v1.Timestamp - (*StoreTestUser)(nil), // 1: controller.storage.db.db_test.v1.StoreTestUser - (*StoreTestCar)(nil), // 2: controller.storage.db.db_test.v1.StoreTestCar - (*StoreTestRental)(nil), // 3: controller.storage.db.db_test.v1.StoreTestRental - (*timestamp.Timestamp)(nil), // 4: google.protobuf.Timestamp + (*StoreTestUser)(nil), // 0: controller.storage.db.db_test.v1.StoreTestUser + (*StoreTestCar)(nil), // 1: controller.storage.db.db_test.v1.StoreTestCar + (*StoreTestRental)(nil), // 2: controller.storage.db.db_test.v1.StoreTestRental + (*timestamp.Timestamp)(nil), // 3: controller.storage.timestamp.v1.Timestamp } var file_controller_storage_db_db_test_v1_db_test_proto_depIdxs = []int32{ - 4, // 0: controller.storage.db.db_test.v1.Timestamp.timestamp:type_name -> google.protobuf.Timestamp - 0, // 1: controller.storage.db.db_test.v1.StoreTestUser.create_time:type_name -> controller.storage.db.db_test.v1.Timestamp - 0, // 2: controller.storage.db.db_test.v1.StoreTestUser.update_time:type_name -> controller.storage.db.db_test.v1.Timestamp - 0, // 3: controller.storage.db.db_test.v1.StoreTestCar.create_time:type_name -> controller.storage.db.db_test.v1.Timestamp - 0, // 4: controller.storage.db.db_test.v1.StoreTestCar.update_time:type_name -> controller.storage.db.db_test.v1.Timestamp - 0, // 5: controller.storage.db.db_test.v1.StoreTestRental.create_time:type_name -> controller.storage.db.db_test.v1.Timestamp - 0, // 6: controller.storage.db.db_test.v1.StoreTestRental.update_time:type_name -> controller.storage.db.db_test.v1.Timestamp - 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 + 3, // 0: controller.storage.db.db_test.v1.StoreTestUser.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 3, // 1: controller.storage.db.db_test.v1.StoreTestUser.update_time:type_name -> controller.storage.timestamp.v1.Timestamp + 3, // 2: controller.storage.db.db_test.v1.StoreTestCar.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 3, // 3: controller.storage.db.db_test.v1.StoreTestCar.update_time:type_name -> controller.storage.timestamp.v1.Timestamp + 3, // 4: controller.storage.db.db_test.v1.StoreTestRental.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 3, // 5: controller.storage.db.db_test.v1.StoreTestRental.update_time:type_name -> controller.storage.timestamp.v1.Timestamp + 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_controller_storage_db_db_test_v1_db_test_proto_init() } @@ -510,18 +457,6 @@ func file_controller_storage_db_db_test_v1_db_test_proto_init() { } if !protoimpl.UnsafeEnabled { file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Timestamp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StoreTestUser); i { case 0: return &v.state @@ -533,7 +468,7 @@ func file_controller_storage_db_db_test_v1_db_test_proto_init() { return nil } } - file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StoreTestCar); i { case 0: return &v.state @@ -545,7 +480,7 @@ func file_controller_storage_db_db_test_v1_db_test_proto_init() { return nil } } - file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_controller_storage_db_db_test_v1_db_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StoreTestRental); i { case 0: return &v.state @@ -564,7 +499,7 @@ func file_controller_storage_db_db_test_v1_db_test_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_controller_storage_db_db_test_v1_db_test_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/db/read_writer_test.go b/internal/db/read_writer_test.go index 3b634ea3d..090731cb8 100644 --- a/internal/db/read_writer_test.go +++ b/internal/db/read_writer_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/sdk/helper/base62" "github.com/hashicorp/watchtower/internal/db/db_test" + "github.com/hashicorp/watchtower/internal/db/timestamp" "github.com/hashicorp/watchtower/internal/oplog" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ import ( func TestDb_Update(t *testing.T) { cleanup, db, _ := TestSetup(t, "postgres") - now := &db_test.Timestamp{Timestamp: ptypes.TimestampNow()} + now := ×tamp.Timestamp{Timestamp: ptypes.TimestampNow()} publicId, err := NewPublicId("testuser") if err != nil { t.Error(err) @@ -371,7 +372,7 @@ func TestDb_Create(t *testing.T) { assert.NoError(err) user, err := db_test.NewTestUser() assert.NoError(err) - ts := &db_test.Timestamp{Timestamp: ptypes.TimestampNow()} + ts := ×tamp.Timestamp{Timestamp: ptypes.TimestampNow()} user.CreateTime = ts user.UpdateTime = ts user.Name = "foo-" + id diff --git a/internal/host/static/store/scanners.go b/internal/db/timestamp/scanners.go similarity index 81% rename from internal/host/static/store/scanners.go rename to internal/db/timestamp/scanners.go index f438b1e6e..d7cb6784f 100644 --- a/internal/host/static/store/scanners.go +++ b/internal/db/timestamp/scanners.go @@ -1,4 +1,4 @@ -package store +package timestamp import ( "database/sql/driver" @@ -9,7 +9,7 @@ import ( "github.com/golang/protobuf/ptypes" ) -// Scan supports Timestamps for oplogs +// Scan implements sql.Scanner for protobuf Timestamp. func (ts *Timestamp) Scan(value interface{}) error { switch t := value.(type) { case time.Time: @@ -24,7 +24,7 @@ func (ts *Timestamp) Scan(value interface{}) error { return nil } -// Value supports Timestamps for oplogs +// Scan implements driver.Valuer for protobuf Timestamp. func (ts *Timestamp) Value() (driver.Value, error) { if ts == nil { return nil, nil diff --git a/internal/host/static/store/scanners_test.go b/internal/db/timestamp/scanners_test.go similarity index 99% rename from internal/host/static/store/scanners_test.go rename to internal/db/timestamp/scanners_test.go index 3eb4c05cb..8b24ffc74 100644 --- a/internal/host/static/store/scanners_test.go +++ b/internal/db/timestamp/scanners_test.go @@ -1,4 +1,4 @@ -package store +package timestamp import ( "reflect" diff --git a/internal/iam/store/timestamp.pb.go b/internal/db/timestamp/timestamp.pb.go similarity index 63% rename from internal/iam/store/timestamp.pb.go rename to internal/db/timestamp/timestamp.pb.go index 0eaa2a423..fa3d43836 100644 --- a/internal/iam/store/timestamp.pb.go +++ b/internal/db/timestamp/timestamp.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.24.0 // protoc v3.11.4 -// source: controller/storage/iam/store/v1/timestamp.proto +// source: controller/storage/timestamp/v1/timestamp.proto -package store +package timestamp import ( proto "github.com/golang/protobuf/proto" @@ -26,7 +26,7 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 -// Timestamp for iam messages. We've defined a new local type wrapper +// Timestamp for storage messages. We've defined a new local type wrapper // of google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer // interfaces. See: // https://golang.org/pkg/database/sql/#Scanner @@ -42,7 +42,7 @@ type Timestamp struct { func (x *Timestamp) Reset() { *x = Timestamp{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_iam_store_v1_timestamp_proto_msgTypes[0] + mi := &file_controller_storage_timestamp_v1_timestamp_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -55,7 +55,7 @@ func (x *Timestamp) String() string { func (*Timestamp) ProtoMessage() {} func (x *Timestamp) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_iam_store_v1_timestamp_proto_msgTypes[0] + mi := &file_controller_storage_timestamp_v1_timestamp_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -68,7 +68,7 @@ func (x *Timestamp) ProtoReflect() protoreflect.Message { // Deprecated: Use Timestamp.ProtoReflect.Descriptor instead. func (*Timestamp) Descriptor() ([]byte, []int) { - return file_controller_storage_iam_store_v1_timestamp_proto_rawDescGZIP(), []int{0} + return file_controller_storage_timestamp_v1_timestamp_proto_rawDescGZIP(), []int{0} } func (x *Timestamp) GetTimestamp() *timestamp.Timestamp { @@ -78,46 +78,47 @@ func (x *Timestamp) GetTimestamp() *timestamp.Timestamp { return nil } -var File_controller_storage_iam_store_v1_timestamp_proto protoreflect.FileDescriptor +var File_controller_storage_timestamp_v1_timestamp_proto protoreflect.FileDescriptor -var file_controller_storage_iam_store_v1_timestamp_proto_rawDesc = []byte{ +var file_controller_storage_timestamp_v1_timestamp_proto_rawDesc = []byte{ 0x0a, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x2f, 0x69, 0x61, 0x6d, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, + 0x72, 0x61, 0x67, 0x65, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, - 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x69, 0x61, 0x6d, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x41, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x69, 0x61, 0x6d, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, - 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x64, 0x62, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x3b, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_controller_storage_iam_store_v1_timestamp_proto_rawDescOnce sync.Once - file_controller_storage_iam_store_v1_timestamp_proto_rawDescData = file_controller_storage_iam_store_v1_timestamp_proto_rawDesc + file_controller_storage_timestamp_v1_timestamp_proto_rawDescOnce sync.Once + file_controller_storage_timestamp_v1_timestamp_proto_rawDescData = file_controller_storage_timestamp_v1_timestamp_proto_rawDesc ) -func file_controller_storage_iam_store_v1_timestamp_proto_rawDescGZIP() []byte { - file_controller_storage_iam_store_v1_timestamp_proto_rawDescOnce.Do(func() { - file_controller_storage_iam_store_v1_timestamp_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_storage_iam_store_v1_timestamp_proto_rawDescData) +func file_controller_storage_timestamp_v1_timestamp_proto_rawDescGZIP() []byte { + file_controller_storage_timestamp_v1_timestamp_proto_rawDescOnce.Do(func() { + file_controller_storage_timestamp_v1_timestamp_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_storage_timestamp_v1_timestamp_proto_rawDescData) }) - return file_controller_storage_iam_store_v1_timestamp_proto_rawDescData + return file_controller_storage_timestamp_v1_timestamp_proto_rawDescData } -var file_controller_storage_iam_store_v1_timestamp_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_controller_storage_iam_store_v1_timestamp_proto_goTypes = []interface{}{ - (*Timestamp)(nil), // 0: controller.storage.iam.store.v1.Timestamp +var file_controller_storage_timestamp_v1_timestamp_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_controller_storage_timestamp_v1_timestamp_proto_goTypes = []interface{}{ + (*Timestamp)(nil), // 0: controller.storage.timestamp.v1.Timestamp (*timestamp.Timestamp)(nil), // 1: google.protobuf.Timestamp } -var file_controller_storage_iam_store_v1_timestamp_proto_depIdxs = []int32{ - 1, // 0: controller.storage.iam.store.v1.Timestamp.timestamp:type_name -> google.protobuf.Timestamp +var file_controller_storage_timestamp_v1_timestamp_proto_depIdxs = []int32{ + 1, // 0: controller.storage.timestamp.v1.Timestamp.timestamp:type_name -> google.protobuf.Timestamp 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -125,13 +126,13 @@ var file_controller_storage_iam_store_v1_timestamp_proto_depIdxs = []int32{ 0, // [0:1] is the sub-list for field type_name } -func init() { file_controller_storage_iam_store_v1_timestamp_proto_init() } -func file_controller_storage_iam_store_v1_timestamp_proto_init() { - if File_controller_storage_iam_store_v1_timestamp_proto != nil { +func init() { file_controller_storage_timestamp_v1_timestamp_proto_init() } +func file_controller_storage_timestamp_v1_timestamp_proto_init() { + if File_controller_storage_timestamp_v1_timestamp_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_controller_storage_iam_store_v1_timestamp_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_controller_storage_timestamp_v1_timestamp_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Timestamp); i { case 0: return &v.state @@ -148,18 +149,18 @@ func file_controller_storage_iam_store_v1_timestamp_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_controller_storage_iam_store_v1_timestamp_proto_rawDesc, + RawDescriptor: file_controller_storage_timestamp_v1_timestamp_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_controller_storage_iam_store_v1_timestamp_proto_goTypes, - DependencyIndexes: file_controller_storage_iam_store_v1_timestamp_proto_depIdxs, - MessageInfos: file_controller_storage_iam_store_v1_timestamp_proto_msgTypes, + GoTypes: file_controller_storage_timestamp_v1_timestamp_proto_goTypes, + DependencyIndexes: file_controller_storage_timestamp_v1_timestamp_proto_depIdxs, + MessageInfos: file_controller_storage_timestamp_v1_timestamp_proto_msgTypes, }.Build() - File_controller_storage_iam_store_v1_timestamp_proto = out.File - file_controller_storage_iam_store_v1_timestamp_proto_rawDesc = nil - file_controller_storage_iam_store_v1_timestamp_proto_goTypes = nil - file_controller_storage_iam_store_v1_timestamp_proto_depIdxs = nil + File_controller_storage_timestamp_v1_timestamp_proto = out.File + file_controller_storage_timestamp_v1_timestamp_proto_rawDesc = nil + file_controller_storage_timestamp_v1_timestamp_proto_goTypes = nil + file_controller_storage_timestamp_v1_timestamp_proto_depIdxs = nil } diff --git a/internal/host/static/store/static.pb.go b/internal/host/static/store/static.pb.go index 8ed556639..dce39306b 100644 --- a/internal/host/static/store/static.pb.go +++ b/internal/host/static/store/static.pb.go @@ -11,7 +11,7 @@ package store import ( proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" + timestamp "github.com/hashicorp/watchtower/internal/db/timestamp" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -29,58 +29,6 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 -// Timestamp for static host messages. We've defined a new local type wrapper -// of google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer -// interfaces. See: -// https://golang.org/pkg/database/sql/#Scanner -// https://golang.org/pkg/database/sql/driver/#Valuer -type Timestamp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamp.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` -} - -func (x *Timestamp) Reset() { - *x = Timestamp{} - if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Timestamp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Timestamp) ProtoMessage() {} - -func (x *Timestamp) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Timestamp.ProtoReflect.Descriptor instead. -func (*Timestamp) Descriptor() ([]byte, []int) { - return file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP(), []int{0} -} - -func (x *Timestamp) GetTimestamp() *timestamp.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - type HostCatalog struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -91,10 +39,10 @@ type HostCatalog struct { PublicId string `protobuf:"bytes,1,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty" gorm:"primary_key"` // The create_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` // The update_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` + UpdateTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` // name is optional. If set, it must be unique within scope_id. // @inject_tag: `gorm:"default:null"` Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty" gorm:"default:null"` @@ -109,7 +57,7 @@ type HostCatalog struct { func (x *HostCatalog) Reset() { *x = HostCatalog{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[1] + mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -122,7 +70,7 @@ func (x *HostCatalog) String() string { func (*HostCatalog) ProtoMessage() {} func (x *HostCatalog) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[1] + mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -135,7 +83,7 @@ func (x *HostCatalog) ProtoReflect() protoreflect.Message { // Deprecated: Use HostCatalog.ProtoReflect.Descriptor instead. func (*HostCatalog) Descriptor() ([]byte, []int) { - return file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP(), []int{1} + return file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP(), []int{0} } func (x *HostCatalog) GetPublicId() string { @@ -145,14 +93,14 @@ func (x *HostCatalog) GetPublicId() string { return "" } -func (x *HostCatalog) GetCreateTime() *Timestamp { +func (x *HostCatalog) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *HostCatalog) GetUpdateTime() *Timestamp { +func (x *HostCatalog) GetUpdateTime() *timestamp.Timestamp { if x != nil { return x.UpdateTime } @@ -190,10 +138,10 @@ type Host struct { PublicId string `protobuf:"bytes,1,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty" gorm:"primary_key"` // The create_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` // The update_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` + UpdateTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` // name is optional. If set, it must be unique within // static_host_catalog_id. // @inject_tag: `gorm:"default:null"` @@ -214,7 +162,7 @@ type Host struct { func (x *Host) Reset() { *x = Host{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[2] + mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -227,7 +175,7 @@ func (x *Host) String() string { func (*Host) ProtoMessage() {} func (x *Host) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[2] + mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -240,7 +188,7 @@ func (x *Host) ProtoReflect() protoreflect.Message { // Deprecated: Use Host.ProtoReflect.Descriptor instead. func (*Host) Descriptor() ([]byte, []int) { - return file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP(), []int{2} + return file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP(), []int{1} } func (x *Host) GetPublicId() string { @@ -250,14 +198,14 @@ func (x *Host) GetPublicId() string { return "" } -func (x *Host) GetCreateTime() *Timestamp { +func (x *Host) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *Host) GetUpdateTime() *Timestamp { +func (x *Host) GetUpdateTime() *timestamp.Timestamp { if x != nil { return x.UpdateTime } @@ -302,10 +250,10 @@ type HostSet struct { PublicId string `protobuf:"bytes,1,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty" gorm:"primary_key"` // The create_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` // The update_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` + UpdateTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` // name is optional. If set, it must be unique within // static_host_catalog_id. // @inject_tag: `gorm:"default:null"` @@ -322,7 +270,7 @@ type HostSet struct { func (x *HostSet) Reset() { *x = HostSet{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[3] + mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -335,7 +283,7 @@ func (x *HostSet) String() string { func (*HostSet) ProtoMessage() {} func (x *HostSet) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[3] + mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -348,7 +296,7 @@ func (x *HostSet) ProtoReflect() protoreflect.Message { // Deprecated: Use HostSet.ProtoReflect.Descriptor instead. func (*HostSet) Descriptor() ([]byte, []int) { - return file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP(), []int{3} + return file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP(), []int{2} } func (x *HostSet) GetPublicId() string { @@ -358,14 +306,14 @@ func (x *HostSet) GetPublicId() string { return "" } -func (x *HostSet) GetCreateTime() *Timestamp { +func (x *HostSet) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *HostSet) GetUpdateTime() *Timestamp { +func (x *HostSet) GetUpdateTime() *timestamp.Timestamp { if x != nil { return x.UpdateTime } @@ -407,7 +355,7 @@ type HostSetMember struct { func (x *HostSetMember) Reset() { *x = HostSetMember{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[4] + mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -420,7 +368,7 @@ func (x *HostSetMember) String() string { func (*HostSetMember) ProtoMessage() {} func (x *HostSetMember) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[4] + mi := &file_controller_storage_host_static_store_v1_static_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -433,7 +381,7 @@ func (x *HostSetMember) ProtoReflect() protoreflect.Message { // Deprecated: Use HostSetMember.ProtoReflect.Descriptor instead. func (*HostSetMember) Descriptor() ([]byte, []int) { - return file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP(), []int{4} + return file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP(), []int{3} } func (x *HostSetMember) GetStaticHostSetId() string { @@ -459,84 +407,77 @@ var file_controller_storage_host_static_store_v1_static_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x27, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x1a, - 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f, 0x72, + 0x61, 0x67, 0x65, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x45, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x38, 0x0a, - 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xa5, 0x02, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, - 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, - 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x63, 0x49, 0x64, 0x12, 0x53, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x68, - 0x6f, 0x73, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x53, 0x0a, 0x0b, 0x75, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, - 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, - 0x61, 0x67, 0x65, 0x2e, 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x2e, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x64, 0x22, - 0xd2, 0x02, 0x0a, 0x04, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x53, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, - 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, - 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x2e, 0x73, 0x74, 0x6f, 0x72, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x53, 0x0a, 0x0b, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x2e, 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, - 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x0a, 0x16, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, - 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, - 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x22, 0xbb, 0x02, 0x0a, 0x07, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, + 0x22, 0x95, 0x02, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x53, 0x0a, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, - 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x73, 0x74, 0x61, - 0x74, 0x69, 0x63, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x53, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x68, 0x6f, 0x73, - 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, + 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, + 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, + 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x0a, - 0x16, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x61, 0x74, - 0x61, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x73, - 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, - 0x49, 0x64, 0x22, 0x62, 0x0a, 0x0d, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x4d, 0x65, 0x6d, - 0x62, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x12, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, - 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0f, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x49, 0x64, - 0x12, 0x24, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, - 0x48, 0x6f, 0x73, 0x74, 0x49, 0x64, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, - 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x2f, 0x68, 0x6f, 0x73, 0x74, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x2f, 0x73, - 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, + 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x64, 0x22, 0xc2, 0x02, 0x0a, 0x04, 0x48, 0x6f, 0x73, + 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x4b, + 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, + 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, + 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x33, + 0x0a, 0x16, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x61, + 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, + 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, + 0x67, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xab, 0x02, + 0x0a, 0x07, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, + 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x0a, 0x16, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, + 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, + 0x73, 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x22, 0x62, 0x0a, 0x0d, 0x48, + 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x12, + 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, + 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0e, 0x73, 0x74, 0x61, + 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x49, 0x64, 0x42, + 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, + 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, + 0x65, 0x72, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x68, 0x6f, 0x73, 0x74, + 0x2f, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -551,28 +492,26 @@ func file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP() []b return file_controller_storage_host_static_store_v1_static_proto_rawDescData } -var file_controller_storage_host_static_store_v1_static_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_controller_storage_host_static_store_v1_static_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_controller_storage_host_static_store_v1_static_proto_goTypes = []interface{}{ - (*Timestamp)(nil), // 0: controller.storage.host.static.store.v1.Timestamp - (*HostCatalog)(nil), // 1: controller.storage.host.static.store.v1.HostCatalog - (*Host)(nil), // 2: controller.storage.host.static.store.v1.Host - (*HostSet)(nil), // 3: controller.storage.host.static.store.v1.HostSet - (*HostSetMember)(nil), // 4: controller.storage.host.static.store.v1.HostSetMember - (*timestamp.Timestamp)(nil), // 5: google.protobuf.Timestamp + (*HostCatalog)(nil), // 0: controller.storage.host.static.store.v1.HostCatalog + (*Host)(nil), // 1: controller.storage.host.static.store.v1.Host + (*HostSet)(nil), // 2: controller.storage.host.static.store.v1.HostSet + (*HostSetMember)(nil), // 3: controller.storage.host.static.store.v1.HostSetMember + (*timestamp.Timestamp)(nil), // 4: controller.storage.timestamp.v1.Timestamp } var file_controller_storage_host_static_store_v1_static_proto_depIdxs = []int32{ - 5, // 0: controller.storage.host.static.store.v1.Timestamp.timestamp:type_name -> google.protobuf.Timestamp - 0, // 1: controller.storage.host.static.store.v1.HostCatalog.create_time:type_name -> controller.storage.host.static.store.v1.Timestamp - 0, // 2: controller.storage.host.static.store.v1.HostCatalog.update_time:type_name -> controller.storage.host.static.store.v1.Timestamp - 0, // 3: controller.storage.host.static.store.v1.Host.create_time:type_name -> controller.storage.host.static.store.v1.Timestamp - 0, // 4: controller.storage.host.static.store.v1.Host.update_time:type_name -> controller.storage.host.static.store.v1.Timestamp - 0, // 5: controller.storage.host.static.store.v1.HostSet.create_time:type_name -> controller.storage.host.static.store.v1.Timestamp - 0, // 6: controller.storage.host.static.store.v1.HostSet.update_time:type_name -> controller.storage.host.static.store.v1.Timestamp - 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 + 4, // 0: controller.storage.host.static.store.v1.HostCatalog.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 4, // 1: controller.storage.host.static.store.v1.HostCatalog.update_time:type_name -> controller.storage.timestamp.v1.Timestamp + 4, // 2: controller.storage.host.static.store.v1.Host.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 4, // 3: controller.storage.host.static.store.v1.Host.update_time:type_name -> controller.storage.timestamp.v1.Timestamp + 4, // 4: controller.storage.host.static.store.v1.HostSet.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 4, // 5: controller.storage.host.static.store.v1.HostSet.update_time:type_name -> controller.storage.timestamp.v1.Timestamp + 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_controller_storage_host_static_store_v1_static_proto_init() } @@ -582,18 +521,6 @@ func file_controller_storage_host_static_store_v1_static_proto_init() { } if !protoimpl.UnsafeEnabled { file_controller_storage_host_static_store_v1_static_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Timestamp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_controller_storage_host_static_store_v1_static_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HostCatalog); i { case 0: return &v.state @@ -605,7 +532,7 @@ func file_controller_storage_host_static_store_v1_static_proto_init() { return nil } } - file_controller_storage_host_static_store_v1_static_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_controller_storage_host_static_store_v1_static_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Host); i { case 0: return &v.state @@ -617,7 +544,7 @@ func file_controller_storage_host_static_store_v1_static_proto_init() { return nil } } - file_controller_storage_host_static_store_v1_static_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_controller_storage_host_static_store_v1_static_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HostSet); i { case 0: return &v.state @@ -629,7 +556,7 @@ func file_controller_storage_host_static_store_v1_static_proto_init() { return nil } } - file_controller_storage_host_static_store_v1_static_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_controller_storage_host_static_store_v1_static_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HostSetMember); i { case 0: return &v.state @@ -648,7 +575,7 @@ func file_controller_storage_host_static_store_v1_static_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_controller_storage_host_static_store_v1_static_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/iam/repository_scope_test.go b/internal/iam/repository_scope_test.go index e0cfdc23e..dcc402f1f 100644 --- a/internal/iam/repository_scope_test.go +++ b/internal/iam/repository_scope_test.go @@ -9,6 +9,7 @@ import ( "github.com/golang/protobuf/ptypes" "github.com/hashicorp/go-uuid" "github.com/hashicorp/watchtower/internal/db" + "github.com/hashicorp/watchtower/internal/db/timestamp" iam_store "github.com/hashicorp/watchtower/internal/iam/store" "github.com/hashicorp/watchtower/internal/oplog" "github.com/stretchr/testify/assert" @@ -290,7 +291,7 @@ func Test_Repository_DeleteScope(t *testing.T) { func TestRepository_UpdateScope(t *testing.T) { cleanup, conn, _ := db.TestSetup(t, "postgres") - now := &iam_store.Timestamp{Timestamp: ptypes.TimestampNow()} + now := ×tamp.Timestamp{Timestamp: ptypes.TimestampNow()} id := testId(t) defer func() { if err := cleanup(); err != nil { diff --git a/internal/iam/repository_test.go b/internal/iam/repository_test.go index 979a374f2..e71bbf531 100644 --- a/internal/iam/repository_test.go +++ b/internal/iam/repository_test.go @@ -11,6 +11,7 @@ import ( wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/go-uuid" "github.com/hashicorp/watchtower/internal/db" + "github.com/hashicorp/watchtower/internal/db/timestamp" iam_store "github.com/hashicorp/watchtower/internal/iam/store" "github.com/hashicorp/watchtower/internal/oplog" "github.com/hashicorp/watchtower/internal/oplog/store" @@ -213,7 +214,7 @@ func Test_Repository_delete(t *testing.T) { func TestRepository_update(t *testing.T) { cleanup, conn, _ := db.TestSetup(t, "postgres") - now := &iam_store.Timestamp{Timestamp: ptypes.TimestampNow()} + now := ×tamp.Timestamp{Timestamp: ptypes.TimestampNow()} id := testId(t) defer func() { if err := cleanup(); err != nil { diff --git a/internal/iam/store/scanners.go b/internal/iam/store/scanners.go deleted file mode 100644 index f438b1e6e..000000000 --- a/internal/iam/store/scanners.go +++ /dev/null @@ -1,33 +0,0 @@ -package store - -import ( - "database/sql/driver" - "errors" - "fmt" - "time" - - "github.com/golang/protobuf/ptypes" -) - -// Scan supports Timestamps for oplogs -func (ts *Timestamp) Scan(value interface{}) error { - switch t := value.(type) { - case time.Time: - var err error - ts.Timestamp, err = ptypes.TimestampProto(t) // google proto version - if err != nil { - return fmt.Errorf("error converting the timestamp: %w", err) - } - default: - return errors.New("Not a protobuf Timestamp") - } - return nil -} - -// Value supports Timestamps for oplogs -func (ts *Timestamp) Value() (driver.Value, error) { - if ts == nil { - return nil, nil - } - return ptypes.Timestamp(ts.Timestamp) -} diff --git a/internal/iam/store/scanners_test.go b/internal/iam/store/scanners_test.go deleted file mode 100644 index 8e955b4ee..000000000 --- a/internal/iam/store/scanners_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package store - -import ( - "reflect" - "testing" - "time" - - "github.com/golang/protobuf/ptypes/timestamp" - "github.com/stretchr/testify/assert" -) - -func Test_TimestampValue(t *testing.T) { - t.Parallel() - assert := assert.New(t) - t.Run("valid", func(t *testing.T) { - ts := Timestamp{Timestamp: ×tamp.Timestamp{Seconds: 0, Nanos: 0}} - v, err := ts.Value() - assert.NoError(err) - assert.Equal(v, utcDate(1970, 1, 1)) - }) - t.Run("valid nil ts", func(t *testing.T) { - var ts *Timestamp - v, err := ts.Value() - assert.NoError(err) - assert.Equal(v, nil) - }) - t.Run("invalid ts", func(t *testing.T) { - ts := Timestamp{Timestamp: ×tamp.Timestamp{Seconds: maxValidSeconds, Nanos: 0}} - v, err := ts.Value() - assert.NotNil(err) - assert.Equal(err.Error(), "timestamp: seconds:253402300800 after 10000-01-01") - assert.Equal(v, utcDate(10000, 1, 1)) - }) -} - -func Test_TimestampScan(t *testing.T) { - t.Parallel() - assert := assert.New(t) - t.Run("valid", func(t *testing.T) { - v := time.Unix(0, 0) - ts := Timestamp{} - err := ts.Scan(v) - assert.NoError(err) - assert.True(reflect.DeepEqual(ts.Timestamp, ×tamp.Timestamp{Seconds: 0, Nanos: 0})) - }) - t.Run("valid default time", func(t *testing.T) { - var v time.Time - ts := Timestamp{} - err := ts.Scan(v) - assert.NoError(err) - assert.True(reflect.DeepEqual(ts.Timestamp, ×tamp.Timestamp{Seconds: -62135596800, Nanos: 0})) - }) - t.Run("invalid type", func(t *testing.T) { - v := 1 - ts := Timestamp{} - err := ts.Scan(v) - assert.NotNil(err) - assert.Equal(err.Error(), "Not a protobuf Timestamp") - }) - t.Run("invalid time", func(t *testing.T) { - v := time.Unix(maxValidSeconds, 0) - ts := Timestamp{} - err := ts.Scan(v) - assert.NotNil(err) - assert.Equal(err.Error(), "error converting the timestamp: timestamp: seconds:253402300800 after 10000-01-01") - }) -} - -const maxValidSeconds = 253402300800 - -func utcDate(year, month, day int) time.Time { - return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC) -} diff --git a/internal/iam/store/scope.pb.go b/internal/iam/store/scope.pb.go index 68e4cbc2f..2837e36ed 100644 --- a/internal/iam/store/scope.pb.go +++ b/internal/iam/store/scope.pb.go @@ -8,6 +8,7 @@ package store import ( proto "github.com/golang/protobuf/proto" + timestamp "github.com/hashicorp/watchtower/internal/db/timestamp" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -35,10 +36,10 @@ type Scope struct { PublicId string `protobuf:"bytes,1,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty" gorm:"primary_key"` // create_time from the RDBMS // @inject_tag: `gorm:"default:current_timestamp"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` // update_time from the RDBMS // @inject_tag: `gorm:"default:current_timestamp"` - UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` + UpdateTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` // name is the optional friendly name used to // access the Scope via an API // @inject_tag: `gorm:"default:null"` @@ -92,14 +93,14 @@ func (x *Scope) GetPublicId() string { return "" } -func (x *Scope) GetCreateTime() *Timestamp { +func (x *Scope) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *Scope) GetUpdateTime() *Timestamp { +func (x *Scope) GetUpdateTime() *timestamp.Timestamp { if x != nil { return x.UpdateTime } @@ -143,19 +144,19 @@ var file_controller_storage_iam_store_v1_scope_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x69, 0x61, 0x6d, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, - 0x67, 0x65, 0x2f, 0x69, 0x61, 0x6d, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, + 0x67, 0x65, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa5, 0x02, 0x0a, 0x05, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x2e, 0x69, 0x61, 0x6d, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, + 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x69, 0x61, - 0x6d, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, @@ -184,12 +185,12 @@ func file_controller_storage_iam_store_v1_scope_proto_rawDescGZIP() []byte { var file_controller_storage_iam_store_v1_scope_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_controller_storage_iam_store_v1_scope_proto_goTypes = []interface{}{ - (*Scope)(nil), // 0: controller.storage.iam.store.v1.Scope - (*Timestamp)(nil), // 1: controller.storage.iam.store.v1.Timestamp + (*Scope)(nil), // 0: controller.storage.iam.store.v1.Scope + (*timestamp.Timestamp)(nil), // 1: controller.storage.timestamp.v1.Timestamp } var file_controller_storage_iam_store_v1_scope_proto_depIdxs = []int32{ - 1, // 0: controller.storage.iam.store.v1.Scope.create_time:type_name -> controller.storage.iam.store.v1.Timestamp - 1, // 1: controller.storage.iam.store.v1.Scope.update_time:type_name -> controller.storage.iam.store.v1.Timestamp + 1, // 0: controller.storage.iam.store.v1.Scope.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 1, // 1: controller.storage.iam.store.v1.Scope.update_time:type_name -> controller.storage.timestamp.v1.Timestamp 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -202,7 +203,6 @@ func file_controller_storage_iam_store_v1_scope_proto_init() { if File_controller_storage_iam_store_v1_scope_proto != nil { return } - file_controller_storage_iam_store_v1_timestamp_proto_init() if !protoimpl.UnsafeEnabled { file_controller_storage_iam_store_v1_scope_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Scope); i { diff --git a/internal/oplog/store/oplog.pb.go b/internal/oplog/store/oplog.pb.go index 4685360e1..b4c6d4d7a 100644 --- a/internal/oplog/store/oplog.pb.go +++ b/internal/oplog/store/oplog.pb.go @@ -10,7 +10,7 @@ package store import ( proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" + timestamp "github.com/hashicorp/watchtower/internal/db/timestamp" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -28,58 +28,6 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 -// Timestamp for oplog messages. We've defined a new local type wrapper -// of google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer -// interfaces. See: -// https://golang.org/pkg/database/sql/#Scanner -// https://golang.org/pkg/database/sql/driver/#Valuer -type Timestamp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamp.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` -} - -func (x *Timestamp) Reset() { - *x = Timestamp{} - if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Timestamp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Timestamp) ProtoMessage() {} - -func (x *Timestamp) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Timestamp.ProtoReflect.Descriptor instead. -func (*Timestamp) Descriptor() ([]byte, []int) { - return file_controller_storage_oplog_store_v1_oplog_proto_rawDescGZIP(), []int{0} -} - -func (x *Timestamp) GetTimestamp() *timestamp.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - // Entry provides a message for oplog entries that's compatible with gorm type Entry struct { state protoimpl.MessageState @@ -89,9 +37,9 @@ type Entry struct { // @inject_tag: gorm:"primary_key" Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` // @inject_tag: `gorm:"default:current_timestamp"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` // @inject_tag: `gorm:"default:current_timestamp"` - UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` + UpdateTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` // @inject_tag: gorm:"not_null" Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty" gorm:"not_null"` // @inject_tat: gorm:"not_null" @@ -111,7 +59,7 @@ type Entry struct { func (x *Entry) Reset() { *x = Entry{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[1] + mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -124,7 +72,7 @@ func (x *Entry) String() string { func (*Entry) ProtoMessage() {} func (x *Entry) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[1] + mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -137,7 +85,7 @@ func (x *Entry) ProtoReflect() protoreflect.Message { // Deprecated: Use Entry.ProtoReflect.Descriptor instead. func (*Entry) Descriptor() ([]byte, []int) { - return file_controller_storage_oplog_store_v1_oplog_proto_rawDescGZIP(), []int{1} + return file_controller_storage_oplog_store_v1_oplog_proto_rawDescGZIP(), []int{0} } func (x *Entry) GetId() uint32 { @@ -147,14 +95,14 @@ func (x *Entry) GetId() uint32 { return 0 } -func (x *Entry) GetCreateTime() *Timestamp { +func (x *Entry) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *Entry) GetUpdateTime() *Timestamp { +func (x *Entry) GetUpdateTime() *timestamp.Timestamp { if x != nil { return x.UpdateTime } @@ -205,8 +153,8 @@ type Metadata struct { // @inject_tag: gorm:"primary_key" Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` // @inject_tag: `gorm:"default:current_timestamp"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` // @inject_tag: gorm:"not_nul - EntryId uint32 `protobuf:"varint,3,opt,name=entry_id,json=entryId,proto3" json:"entry_id,omitempty"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` // @inject_tag: gorm:"not_nul + EntryId uint32 `protobuf:"varint,3,opt,name=entry_id,json=entryId,proto3" json:"entry_id,omitempty"` // @inject_tag: gorm:"foreignkey:EntryId" Entry *Entry `protobuf:"bytes,4,opt,name=entry,proto3" json:"entry,omitempty" gorm:"foreignkey:EntryId"` // @inject_tag: gorm:"not_null" @@ -218,7 +166,7 @@ type Metadata struct { func (x *Metadata) Reset() { *x = Metadata{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[2] + mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -231,7 +179,7 @@ func (x *Metadata) String() string { func (*Metadata) ProtoMessage() {} func (x *Metadata) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[2] + mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -244,7 +192,7 @@ func (x *Metadata) ProtoReflect() protoreflect.Message { // Deprecated: Use Metadata.ProtoReflect.Descriptor instead. func (*Metadata) Descriptor() ([]byte, []int) { - return file_controller_storage_oplog_store_v1_oplog_proto_rawDescGZIP(), []int{2} + return file_controller_storage_oplog_store_v1_oplog_proto_rawDescGZIP(), []int{1} } func (x *Metadata) GetId() uint32 { @@ -254,7 +202,7 @@ func (x *Metadata) GetId() uint32 { return 0 } -func (x *Metadata) GetCreateTime() *Timestamp { +func (x *Metadata) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } @@ -298,9 +246,9 @@ type Ticket struct { // @inject_tag: gorm:"primary_key" Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` // @inject_tag: `gorm:"default:current_timestamp"` - CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` + CreateTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"` // @inject_tag: `gorm:"default:current_timestamp"` - UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` + UpdateTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"` // @inject_tat: gorm:"not_null" Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` // @inject_tat: gorm:"not_null;default:'1'" @@ -310,7 +258,7 @@ type Ticket struct { func (x *Ticket) Reset() { *x = Ticket{} if protoimpl.UnsafeEnabled { - mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[3] + mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -323,7 +271,7 @@ func (x *Ticket) String() string { func (*Ticket) ProtoMessage() {} func (x *Ticket) ProtoReflect() protoreflect.Message { - mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[3] + mi := &file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -336,7 +284,7 @@ func (x *Ticket) ProtoReflect() protoreflect.Message { // Deprecated: Use Ticket.ProtoReflect.Descriptor instead. func (*Ticket) Descriptor() ([]byte, []int) { - return file_controller_storage_oplog_store_v1_oplog_proto_rawDescGZIP(), []int{3} + return file_controller_storage_oplog_store_v1_oplog_proto_rawDescGZIP(), []int{2} } func (x *Ticket) GetId() uint32 { @@ -346,14 +294,14 @@ func (x *Ticket) GetId() uint32 { return 0 } -func (x *Ticket) GetCreateTime() *Timestamp { +func (x *Ticket) GetCreateTime() *timestamp.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *Ticket) GetUpdateTime() *Timestamp { +func (x *Ticket) GetUpdateTime() *timestamp.Timestamp { if x != nil { return x.UpdateTime } @@ -382,70 +330,66 @@ var file_controller_storage_oplog_store_v1_oplog_proto_rawDesc = []byte{ 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x70, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x6f, 0x70, 0x6c, 0x6f, 0x67, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, - 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xec, 0x02, 0x0a, 0x05, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x4d, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x6f, - 0x70, 0x6c, 0x6f, 0x67, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, - 0x69, 0x6d, 0x65, 0x12, 0x4d, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x6f, 0x70, - 0x6c, 0x6f, 0x67, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, - 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x4e, - 0x61, 0x6d, 0x65, 0x12, 0x47, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x6f, 0x70, 0x6c, 0x6f, 0x67, - 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, - 0x63, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, - 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x08, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xec, 0x01, 0x0a, 0x08, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4d, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6f, + 0x76, 0x31, 0x1a, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0xe8, 0x02, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4b, 0x0a, + 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, + 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, + 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, + 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x67, 0x67, 0x72, 0x65, + 0x67, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x47, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, + 0x6f, 0x70, 0x6c, 0x6f, 0x67, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x06, 0x63, 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xea, + 0x01, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, + 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x6e, 0x74, 0x72, + 0x79, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, + 0x79, 0x49, 0x64, 0x12, 0x3e, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, + 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x6f, 0x70, 0x6c, 0x6f, 0x67, 0x2e, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x65, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xe0, 0x01, 0x0a, 0x06, + 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x2e, 0x6f, 0x70, 0x6c, 0x6f, 0x67, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x5f, 0x69, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x49, 0x64, - 0x12, 0x3e, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x28, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x2e, 0x6f, 0x70, 0x6c, 0x6f, 0x67, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xe4, 0x01, 0x0a, 0x06, 0x54, 0x69, 0x63, - 0x6b, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x4d, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x6f, 0x70, - 0x6c, 0x6f, 0x67, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x4d, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x6f, 0x70, 0x6c, - 0x6f, 0x67, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, - 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, - 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, - 0x65, 0x72, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6f, 0x70, 0x6c, 0x6f, - 0x67, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x3c, + 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, + 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, + 0x72, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6f, 0x70, 0x6c, 0x6f, 0x67, + 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -460,28 +404,26 @@ func file_controller_storage_oplog_store_v1_oplog_proto_rawDescGZIP() []byte { return file_controller_storage_oplog_store_v1_oplog_proto_rawDescData } -var file_controller_storage_oplog_store_v1_oplog_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_controller_storage_oplog_store_v1_oplog_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_controller_storage_oplog_store_v1_oplog_proto_goTypes = []interface{}{ - (*Timestamp)(nil), // 0: controller.storage.oplog.store.v1.Timestamp - (*Entry)(nil), // 1: controller.storage.oplog.store.v1.Entry - (*Metadata)(nil), // 2: controller.storage.oplog.store.v1.Metadata - (*Ticket)(nil), // 3: controller.storage.oplog.store.v1.Ticket - (*timestamp.Timestamp)(nil), // 4: google.protobuf.Timestamp + (*Entry)(nil), // 0: controller.storage.oplog.store.v1.Entry + (*Metadata)(nil), // 1: controller.storage.oplog.store.v1.Metadata + (*Ticket)(nil), // 2: controller.storage.oplog.store.v1.Ticket + (*timestamp.Timestamp)(nil), // 3: controller.storage.timestamp.v1.Timestamp } var file_controller_storage_oplog_store_v1_oplog_proto_depIdxs = []int32{ - 4, // 0: controller.storage.oplog.store.v1.Timestamp.timestamp:type_name -> google.protobuf.Timestamp - 0, // 1: controller.storage.oplog.store.v1.Entry.create_time:type_name -> controller.storage.oplog.store.v1.Timestamp - 0, // 2: controller.storage.oplog.store.v1.Entry.update_time:type_name -> controller.storage.oplog.store.v1.Timestamp - 2, // 3: controller.storage.oplog.store.v1.Entry.metadata:type_name -> controller.storage.oplog.store.v1.Metadata - 0, // 4: controller.storage.oplog.store.v1.Metadata.create_time:type_name -> controller.storage.oplog.store.v1.Timestamp - 1, // 5: controller.storage.oplog.store.v1.Metadata.entry:type_name -> controller.storage.oplog.store.v1.Entry - 0, // 6: controller.storage.oplog.store.v1.Ticket.create_time:type_name -> controller.storage.oplog.store.v1.Timestamp - 0, // 7: controller.storage.oplog.store.v1.Ticket.update_time:type_name -> controller.storage.oplog.store.v1.Timestamp - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 3, // 0: controller.storage.oplog.store.v1.Entry.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 3, // 1: controller.storage.oplog.store.v1.Entry.update_time:type_name -> controller.storage.timestamp.v1.Timestamp + 1, // 2: controller.storage.oplog.store.v1.Entry.metadata:type_name -> controller.storage.oplog.store.v1.Metadata + 3, // 3: controller.storage.oplog.store.v1.Metadata.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 0, // 4: controller.storage.oplog.store.v1.Metadata.entry:type_name -> controller.storage.oplog.store.v1.Entry + 3, // 5: controller.storage.oplog.store.v1.Ticket.create_time:type_name -> controller.storage.timestamp.v1.Timestamp + 3, // 6: controller.storage.oplog.store.v1.Ticket.update_time:type_name -> controller.storage.timestamp.v1.Timestamp + 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_controller_storage_oplog_store_v1_oplog_proto_init() } @@ -491,18 +433,6 @@ func file_controller_storage_oplog_store_v1_oplog_proto_init() { } if !protoimpl.UnsafeEnabled { file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Timestamp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Entry); i { case 0: return &v.state @@ -514,7 +444,7 @@ func file_controller_storage_oplog_store_v1_oplog_proto_init() { return nil } } - file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Metadata); i { case 0: return &v.state @@ -526,7 +456,7 @@ func file_controller_storage_oplog_store_v1_oplog_proto_init() { return nil } } - file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_controller_storage_oplog_store_v1_oplog_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Ticket); i { case 0: return &v.state @@ -545,7 +475,7 @@ func file_controller_storage_oplog_store_v1_oplog_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_controller_storage_oplog_store_v1_oplog_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/oplog/store/scanners.go b/internal/oplog/store/scanners.go deleted file mode 100644 index f438b1e6e..000000000 --- a/internal/oplog/store/scanners.go +++ /dev/null @@ -1,33 +0,0 @@ -package store - -import ( - "database/sql/driver" - "errors" - "fmt" - "time" - - "github.com/golang/protobuf/ptypes" -) - -// Scan supports Timestamps for oplogs -func (ts *Timestamp) Scan(value interface{}) error { - switch t := value.(type) { - case time.Time: - var err error - ts.Timestamp, err = ptypes.TimestampProto(t) // google proto version - if err != nil { - return fmt.Errorf("error converting the timestamp: %w", err) - } - default: - return errors.New("Not a protobuf Timestamp") - } - return nil -} - -// Value supports Timestamps for oplogs -func (ts *Timestamp) Value() (driver.Value, error) { - if ts == nil { - return nil, nil - } - return ptypes.Timestamp(ts.Timestamp) -} diff --git a/internal/oplog/store/scanners_test.go b/internal/oplog/store/scanners_test.go deleted file mode 100644 index 022648123..000000000 --- a/internal/oplog/store/scanners_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package store - -import ( - "reflect" - "testing" - "time" - - "github.com/golang/protobuf/ptypes/timestamp" - "gotest.tools/assert" -) - -func Test_TimestampValue(t *testing.T) { - t.Parallel() - - t.Run("valid", func(t *testing.T) { - ts := Timestamp{Timestamp: ×tamp.Timestamp{Seconds: 0, Nanos: 0}} - v, err := ts.Value() - assert.NilError(t, err) - assert.Equal(t, v, utcDate(1970, 1, 1)) - }) - t.Run("valid nil ts", func(t *testing.T) { - var ts *Timestamp - v, err := ts.Value() - assert.NilError(t, err) - assert.Equal(t, v, nil) - }) - t.Run("invalid ts", func(t *testing.T) { - ts := Timestamp{Timestamp: ×tamp.Timestamp{Seconds: maxValidSeconds, Nanos: 0}} - v, err := ts.Value() - assert.Check(t, err != nil) - assert.Equal(t, err.Error(), "timestamp: seconds:253402300800 after 10000-01-01") - assert.Equal(t, v, utcDate(10000, 1, 1)) - }) -} - -func Test_TimestampScan(t *testing.T) { - t.Parallel() - - t.Run("valid", func(t *testing.T) { - v := time.Unix(0, 0) - ts := Timestamp{} - err := ts.Scan(v) - assert.NilError(t, err) - assert.Check(t, reflect.DeepEqual(ts.Timestamp, ×tamp.Timestamp{Seconds: 0, Nanos: 0})) - }) - t.Run("valid default time", func(t *testing.T) { - var v time.Time - ts := Timestamp{} - err := ts.Scan(v) - assert.NilError(t, err) - assert.Check(t, reflect.DeepEqual(ts.Timestamp, ×tamp.Timestamp{Seconds: -62135596800, Nanos: 0})) - }) - t.Run("invalid type", func(t *testing.T) { - v := 1 - ts := Timestamp{} - err := ts.Scan(v) - assert.Check(t, err != nil) - assert.Equal(t, err.Error(), "Not a protobuf Timestamp") - }) - t.Run("invalid time", func(t *testing.T) { - v := time.Unix(maxValidSeconds, 0) - ts := Timestamp{} - err := ts.Scan(v) - assert.Check(t, err != nil) - assert.Equal(t, err.Error(), "error converting the timestamp: timestamp: seconds:253402300800 after 10000-01-01") - }) -} - -const maxValidSeconds = 253402300800 - -func utcDate(year, month, day int) time.Time { - return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC) -} diff --git a/internal/proto/local/controller/storage/db/db_test/v1/db_test.proto b/internal/proto/local/controller/storage/db/db_test/v1/db_test.proto index e5e42d7a7..06455050f 100644 --- a/internal/proto/local/controller/storage/db/db_test/v1/db_test.proto +++ b/internal/proto/local/controller/storage/db/db_test/v1/db_test.proto @@ -6,12 +6,7 @@ syntax = "proto3"; package controller.storage.db.db_test.v1; option go_package = "github.com/hashicorp/watchtower/internal/db/db_test;db_test"; -import "google/protobuf/timestamp.proto"; - -// Timestamp for oplog messages -message Timestamp { - google.protobuf.Timestamp timestamp = 1; -} +import "controller/storage/timestamp/v1/timestamp.proto"; // TestUser for gorm test user model message StoreTestUser { @@ -20,11 +15,11 @@ message StoreTestUser { // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - Timestamp update_time = 3; + timestamp.v1.Timestamp update_time = 3; // public_id is the used to access the AssignablScope via an API string public_id = 4; @@ -44,11 +39,11 @@ message StoreTestCar { // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - Timestamp update_time = 3; + timestamp.v1.Timestamp update_time = 3; // public_id is the used to access the AssignablScope via an API string public_id = 4; @@ -68,11 +63,11 @@ message StoreTestRental { // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` - Timestamp update_time = 3; + timestamp.v1.Timestamp update_time = 3; // public_id is the used to access the AssignablScope via an API string public_id = 4; @@ -84,4 +79,4 @@ message StoreTestRental { uint32 user_id = 6; uint32 car_id = 7; -} \ No newline at end of file +} diff --git a/internal/proto/local/controller/storage/host/static/store/v1/static.proto b/internal/proto/local/controller/storage/host/static/store/v1/static.proto index 607b5f75e..4ef984890 100644 --- a/internal/proto/local/controller/storage/host/static/store/v1/static.proto +++ b/internal/proto/local/controller/storage/host/static/store/v1/static.proto @@ -5,16 +5,7 @@ syntax = "proto3"; package controller.storage.host.static.store.v1; option go_package = "github.com/hashicorp/watchtower/internal/host/static/store;store"; -import "google/protobuf/timestamp.proto"; - -// Timestamp for static host messages. We've defined a new local type wrapper -// of google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer -// interfaces. See: -// https://golang.org/pkg/database/sql/#Scanner -// https://golang.org/pkg/database/sql/driver/#Valuer -message Timestamp { - google.protobuf.Timestamp timestamp = 1; -} +import "controller/storage/timestamp/v1/timestamp.proto"; message HostCatalog { // public_is is a surrogate key suitable for use in a public API. @@ -23,11 +14,11 @@ message HostCatalog { // The create_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // The update_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp update_time = 3; + timestamp.v1.Timestamp update_time = 3; // name is optional. If set, it must be unique within scope_id. // @inject_tag: `gorm:"default:null"` @@ -49,11 +40,11 @@ message Host { // The create_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // The update_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp update_time = 3; + timestamp.v1.Timestamp update_time = 3; // name is optional. If set, it must be unique within // static_host_catalog_id. @@ -82,11 +73,11 @@ message HostSet { // The create_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // The update_time is set by the database. // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp update_time = 3; + timestamp.v1.Timestamp update_time = 3; // name is optional. If set, it must be unique within // static_host_catalog_id. diff --git a/internal/proto/local/controller/storage/iam/store/v1/scope.proto b/internal/proto/local/controller/storage/iam/store/v1/scope.proto index 95d5a69b9..9ebe35520 100644 --- a/internal/proto/local/controller/storage/iam/store/v1/scope.proto +++ b/internal/proto/local/controller/storage/iam/store/v1/scope.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package controller.storage.iam.store.v1; option go_package = "github.com/hashicorp/watchtower/internal/iam/store;store"; -import "controller/storage/iam/store/v1/timestamp.proto"; +import "controller/storage/timestamp/v1/timestamp.proto"; message Scope { // public_id is the used to access the Scope via an API @@ -12,11 +12,11 @@ message Scope { // create_time from the RDBMS // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // update_time from the RDBMS // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp update_time = 3; + timestamp.v1.Timestamp update_time = 3; // name is the optional friendly name used to // access the Scope via an API @@ -33,4 +33,4 @@ message Scope { // description of scope // @inject_tag: `gorm:"default:null"` string description = 7; -} \ No newline at end of file +} diff --git a/internal/proto/local/controller/storage/oplog/store/v1/oplog.proto b/internal/proto/local/controller/storage/oplog/store/v1/oplog.proto index ab890cc8a..9cd609e16 100644 --- a/internal/proto/local/controller/storage/oplog/store/v1/oplog.proto +++ b/internal/proto/local/controller/storage/oplog/store/v1/oplog.proto @@ -4,25 +4,16 @@ syntax = "proto3"; package controller.storage.oplog.store.v1; option go_package = "github.com/hashicorp/watchtower/internal/oplog/store;store"; -import "google/protobuf/timestamp.proto"; - -// Timestamp for oplog messages. We've defined a new local type wrapper -// of google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer -// interfaces. See: -// https://golang.org/pkg/database/sql/#Scanner -// https://golang.org/pkg/database/sql/driver/#Valuer -message Timestamp { - google.protobuf.Timestamp timestamp = 1; -} +import "controller/storage/timestamp/v1/timestamp.proto"; // Entry provides a message for oplog entries that's compatible with gorm message Entry { // @inject_tag: gorm:"primary_key" uint32 id = 1; // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp update_time = 3; + timestamp.v1.Timestamp update_time = 3; // @inject_tag: gorm:"not_null" string version = 4; @@ -49,7 +40,7 @@ message Metadata { // @inject_tag: gorm:"primary_key" uint32 id = 1; // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // @inject_tag: gorm:"not_nul uint32 entry_id = 3; @@ -67,9 +58,9 @@ message Ticket { // @inject_tag: gorm:"primary_key" uint32 id = 1; // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp create_time = 2; + timestamp.v1.Timestamp create_time = 2; // @inject_tag: `gorm:"default:current_timestamp"` - Timestamp update_time = 3; + timestamp.v1.Timestamp update_time = 3; // @inject_tat: gorm:"not_null" string name = 6; diff --git a/internal/proto/local/controller/storage/iam/store/v1/timestamp.proto b/internal/proto/local/controller/storage/timestamp/v1/timestamp.proto similarity index 61% rename from internal/proto/local/controller/storage/iam/store/v1/timestamp.proto rename to internal/proto/local/controller/storage/timestamp/v1/timestamp.proto index 21ab807ec..ad72a7763 100644 --- a/internal/proto/local/controller/storage/iam/store/v1/timestamp.proto +++ b/internal/proto/local/controller/storage/timestamp/v1/timestamp.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package controller.storage.iam.store.v1; -option go_package = "github.com/hashicorp/watchtower/internal/iam/store;store"; +package controller.storage.timestamp.v1; +option go_package = "github.com/hashicorp/watchtower/internal/db/timestamp;timestamp"; import "google/protobuf/timestamp.proto"; -// Timestamp for iam messages. We've defined a new local type wrapper +// Timestamp for storage messages. We've defined a new local type wrapper // of google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer // interfaces. See: // https://golang.org/pkg/database/sql/#Scanner