From 6f14ee925f01fb41a08ecf34310c3543554179cf Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 5 Apr 2022 13:01:17 -0700 Subject: [PATCH] Bugfix: populate state in named entity metadata (#389) Signed-off-by: Katrina Rogan --- flyteadmin/pkg/repositories/transformers/named_entity.go | 5 +++++ .../pkg/repositories/transformers/named_entity_test.go | 3 +++ 2 files changed, 8 insertions(+) diff --git a/flyteadmin/pkg/repositories/transformers/named_entity.go b/flyteadmin/pkg/repositories/transformers/named_entity.go index 5765154ecf..9bda1746c0 100644 --- a/flyteadmin/pkg/repositories/transformers/named_entity.go +++ b/flyteadmin/pkg/repositories/transformers/named_entity.go @@ -28,6 +28,10 @@ func FromNamedEntityMetadataFields(metadata models.NamedEntityMetadataFields) ad } func FromNamedEntityModel(model models.NamedEntity) admin.NamedEntity { + var entityState int32 + if model.State != nil { + entityState = *model.State + } return admin.NamedEntity{ ResourceType: model.ResourceType, Id: &admin.NamedEntityIdentifier{ @@ -37,6 +41,7 @@ func FromNamedEntityModel(model models.NamedEntity) admin.NamedEntity { }, Metadata: &admin.NamedEntityMetadata{ Description: model.Description, + State: admin.NamedEntityState(entityState), }, } } diff --git a/flyteadmin/pkg/repositories/transformers/named_entity_test.go b/flyteadmin/pkg/repositories/transformers/named_entity_test.go index cf8cb1c9a1..f202a605a0 100644 --- a/flyteadmin/pkg/repositories/transformers/named_entity_test.go +++ b/flyteadmin/pkg/repositories/transformers/named_entity_test.go @@ -40,6 +40,7 @@ func TestCreateNamedEntityModel(t *testing.T) { } func TestFromNamedEntityModel(t *testing.T) { + entityState := int32(1) model := models.NamedEntity{ NamedEntityKey: models.NamedEntityKey{ ResourceType: core.ResourceType_WORKFLOW, @@ -49,6 +50,7 @@ func TestFromNamedEntityModel(t *testing.T) { }, NamedEntityMetadataFields: models.NamedEntityMetadataFields{ Description: "description", + State: &entityState, }, } @@ -62,6 +64,7 @@ func TestFromNamedEntityModel(t *testing.T) { }, Metadata: &admin.NamedEntityMetadata{ Description: "description", + State: admin.NamedEntityState_NAMED_ENTITY_ARCHIVED, }, }, &namedEntity)) }