Skip to content

Commit

Permalink
Bugfix: populate state in named entity metadata (flyteorg#389)
Browse files Browse the repository at this point in the history
Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan authored Apr 5, 2022
1 parent 860ebfb commit 6f14ee9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions flyteadmin/pkg/repositories/transformers/named_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -37,6 +41,7 @@ func FromNamedEntityModel(model models.NamedEntity) admin.NamedEntity {
},
Metadata: &admin.NamedEntityMetadata{
Description: model.Description,
State: admin.NamedEntityState(entityState),
},
}
}
Expand Down
3 changes: 3 additions & 0 deletions flyteadmin/pkg/repositories/transformers/named_entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -49,6 +50,7 @@ func TestFromNamedEntityModel(t *testing.T) {
},
NamedEntityMetadataFields: models.NamedEntityMetadataFields{
Description: "description",
State: &entityState,
},
}

Expand All @@ -62,6 +64,7 @@ func TestFromNamedEntityModel(t *testing.T) {
},
Metadata: &admin.NamedEntityMetadata{
Description: "description",
State: admin.NamedEntityState_NAMED_ENTITY_ARCHIVED,
},
}, &namedEntity))
}
Expand Down

0 comments on commit 6f14ee9

Please sign in to comment.