refact(target): Remove old TargetType (#1618)
Now that subtypes are registered via sub-packages, this TargetType is
not needed and should not be used. This removes it and updates the
target.Repository and targets.Service to use the updated code.
This was missed in eac433f7ff.
This commit is contained in:
1 parent
769416c2ff
commit
b5fbf9608e
8 files changed
+49
-390
No files matched your search
@@ -1474,7 +1474,7 @@ func toProto(ctx context.Context, in target.Target, hostSources []target.HostSou
|
||||
out.ScopeId = in.GetScopeId()
|
||||
}
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = target.TcpTargetType.String()
|
||||
out.Type = in.GetType().String()
|
||||
}
|
||||
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
|
||||
out.Description = wrapperspb.String(in.GetDescription())
|
||||
@@ -1626,11 +1626,9 @@ func validateCreateRequest(req *pbs.CreateTargetRequest) error {
|
||||
badFields["attributes.default_port"] = "This optional field cannot be set to 0."
|
||||
}
|
||||
}
|
||||
switch req.GetItem().GetType() {
|
||||
case target.TcpTargetType.String():
|
||||
case "":
|
||||
if req.GetItem().GetType() == "" {
|
||||
badFields[globals.TypeField] = "This is a required field."
|
||||
default:
|
||||
} else if target.SubtypeFromType(req.GetItem().GetType()) == "" {
|
||||
badFields[globals.TypeField] = "Unknown type provided."
|
||||
}
|
||||
if filter := req.GetItem().GetWorkerFilter(); filter != nil {
|
||||
|
||||
@@ -117,7 +117,7 @@ func TestGet(t *testing.T) {
|
||||
CreatedTime: tar.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: tar.UpdateTime.GetTimestamp(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: o.GetPublicId()},
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
HostSetIds: []string{hs[0].GetPublicId(), hs[1].GetPublicId()},
|
||||
HostSourceIds: []string{hs[0].GetPublicId(), hs[1].GetPublicId()},
|
||||
Attributes: new(structpb.Struct),
|
||||
@@ -212,7 +212,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: tar.GetUpdateTime().GetTimestamp(),
|
||||
Version: tar.GetVersion(),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attributes: new(structpb.Struct),
|
||||
SessionMaxSeconds: wrapperspb.UInt32(28800),
|
||||
SessionConnectionLimit: wrapperspb.Int32(1),
|
||||
@@ -228,7 +228,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: tar.GetUpdateTime().GetTimestamp(),
|
||||
Version: tar.GetVersion(),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attributes: new(structpb.Struct),
|
||||
SessionMaxSeconds: wrapperspb.UInt32(28800),
|
||||
SessionConnectionLimit: wrapperspb.Int32(1),
|
||||
@@ -421,7 +421,7 @@ func TestCreate(t *testing.T) {
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
@@ -434,7 +434,7 @@ func TestCreate(t *testing.T) {
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
@@ -450,7 +450,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateTargetRequest{Item: &pb.Target{
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(0),
|
||||
}},
|
||||
@@ -623,7 +623,7 @@ func TestUpdate(t *testing.T) {
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
@@ -658,7 +658,7 @@ func TestUpdate(t *testing.T) {
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
@@ -745,7 +745,7 @@ func TestUpdate(t *testing.T) {
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
Name: wrapperspb.String("default"),
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
@@ -778,7 +778,7 @@ func TestUpdate(t *testing.T) {
|
||||
Name: wrapperspb.String("updated"),
|
||||
Description: wrapperspb.String("default"),
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
@@ -814,7 +814,7 @@ func TestUpdate(t *testing.T) {
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
Type: target.TcpTargetType.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
HostSourceIds: hostSourceIds,
|
||||
|
||||
Reference in new issue
Block a user