From 1d87510e89210388b0b33841f447fb0c7cc49ea2 Mon Sep 17 00:00:00 2001 From: Jim Lambert Date: Sat, 5 Sep 2020 10:32:47 -0400 Subject: [PATCH] refactor to use servers.ServerType in place of string --- internal/session/session.go | 5 +++-- internal/session/session_test.go | 2 +- internal/session/testing.go | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/session/session.go b/internal/session/session.go index bfa713d85b..2dc9885e15 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/hashicorp/boundary/internal/db" + "github.com/hashicorp/boundary/internal/servers" "github.com/hashicorp/boundary/internal/session/store" "google.golang.org/protobuf/proto" ) @@ -19,7 +20,7 @@ type ComposedOf struct { UserId string HostId string ServerId string - ServerType string + ServerType servers.ServerType TargetId string HostSetId string AuthTokenId string @@ -43,7 +44,7 @@ func New(c ComposedOf, opt ...Option) (*Session, error) { UserId: c.UserId, HostId: c.HostId, ServerId: c.ServerId, - ServerType: c.ServerType, + ServerType: c.ServerType.String(), TargetId: c.TargetId, SetId: c.HostSetId, AuthTokenId: c.AuthTokenId, diff --git a/internal/session/session_test.go b/internal/session/session_test.go index fad0d1dd57..8a769a4d75 100644 --- a/internal/session/session_test.go +++ b/internal/session/session_test.go @@ -43,7 +43,7 @@ func TestSession_Create(t *testing.T) { UserId: composedOf.UserId, HostId: composedOf.HostId, ServerId: composedOf.ServerId, - ServerType: composedOf.ServerType, + ServerType: composedOf.ServerType.String(), TargetId: composedOf.TargetId, SetId: composedOf.HostSetId, AuthTokenId: composedOf.AuthTokenId, diff --git a/internal/session/testing.go b/internal/session/testing.go index 3d253ee327..55e0ca8c6e 100644 --- a/internal/session/testing.go +++ b/internal/session/testing.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/servers" "github.com/hashicorp/boundary/internal/target" - "github.com/hashicorp/boundary/internal/types/resource" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/go-uuid" "github.com/jinzhu/gorm" @@ -89,7 +88,7 @@ func TestSessionParams(t *testing.T, conn *gorm.DB, wrapper wrapping.Wrapper, ia worker := &servers.Server{ PrivateId: "test-session-worker-" + id, Name: "test-session-worker-" + id, - Type: resource.Worker.String(), + Type: servers.ServerTypeWorker.String(), Description: "Test Session Worker", Address: "127.0.0.1", } @@ -100,7 +99,7 @@ func TestSessionParams(t *testing.T, conn *gorm.DB, wrapper wrapping.Wrapper, ia UserId: user.PublicId, HostId: hosts[0].PublicId, ServerId: worker.PrivateId, - ServerType: worker.Type, + ServerType: servers.ServerTypeWorker, TargetId: tcpTarget.PublicId, HostSetId: sets[0].PublicId, AuthTokenId: at.PublicId,