Merge pull request #3511 from backstage/freben/owned

catalog-model: update ownership of data
This commit is contained in:
Fredrik Adelöw
2020-12-01 22:54:04 +01:00
committed by GitHub
16 changed files with 33 additions and 18 deletions
@@ -42,3 +42,17 @@ spec:
email: nigel-manning@example.com
picture: https://example.com/staff/nigel.jpeg
memberOf: [team-a]
---
# This user is added as an example, to make it more easy for the "Guest"
# sign-in option to demonstrate some entities being owned. In a regular org,
# a guest user would probably not be registered like this.
apiVersion: backstage.io/v1alpha1
kind: User
metadata:
name: guest
spec:
profile:
displayName: Guest User
email: guest@example.com
picture: https://example.com/staff/the-ceos-dog.jpeg
memberOf: [team-a]
@@ -6,7 +6,7 @@ metadata:
spec:
type: grpc
lifecycle: deprecated
owner: grpc@example.com
owner: team-c
definition: |
// Copyright 2015 gRPC authors.
//
@@ -9,7 +9,7 @@ metadata:
spec:
type: openapi
lifecycle: experimental
owner: pets@example.com
owner: team-c
definition: |
openapi: "3.0.0"
info:
@@ -12,6 +12,6 @@ metadata:
spec:
type: openapi
lifecycle: production
owner: spotify@example.com
owner: team-a
definition:
$text: https://github.com/APIs-guru/openapi-directory/blob/master/APIs/spotify.com/v1/swagger.yaml
@@ -8,7 +8,7 @@ metadata:
spec:
type: asyncapi
lifecycle: production
owner: streetlights@example.com
owner: team-c
definition: |
asyncapi: 2.0.0
info:
@@ -6,7 +6,7 @@ metadata:
spec:
type: graphql
lifecycle: production
owner: yoda@dagobah.space
owner: team-b
definition: |
schema {
query: Root
@@ -9,4 +9,4 @@ metadata:
spec:
type: service
lifecycle: experimental
owner: artists@example.com
owner: team-a
@@ -6,7 +6,7 @@ metadata:
spec:
type: service
lifecycle: experimental
owner: pets@example.com
owner: team-c
implementsApis:
- petstore
- streetlights
@@ -6,4 +6,4 @@ metadata:
spec:
type: library
lifecycle: experimental
owner: players@example.com
owner: team-c
@@ -9,4 +9,4 @@ metadata:
spec:
type: service
lifecycle: production
owner: guest
owner: user:guest
@@ -8,4 +8,4 @@ metadata:
spec:
type: service
lifecycle: experimental
owner: players@example.com
owner: team-b
@@ -9,4 +9,4 @@ metadata:
spec:
type: website
lifecycle: production
owner: tools@example.com
owner: team-b
@@ -8,4 +8,4 @@ metadata:
spec:
type: service
lifecycle: production
owner: guest
owner: user:guest
@@ -8,4 +8,4 @@ metadata:
spec:
type: service
lifecycle: production
owner: guest
owner: user:guest
@@ -6,4 +6,4 @@ metadata:
spec:
type: website
lifecycle: production
owner: artists@example.com
owner: team-a
+5 -4
View File
@@ -21,20 +21,21 @@ import { identityApiRef, useApi } from '@backstage/core';
import { catalogApiRef } from '../plugin';
/**
* Get the group memberships of the logged-in user.
* Get the catalog User entity (if any) that matches the logged-in user.
*/
export function useOwnUser(): AsyncState<UserEntity> {
export function useOwnUser(): AsyncState<UserEntity | undefined> {
const catalogApi = useApi(catalogApiRef);
const identityApi = useApi(identityApiRef);
// TODO: get the full entity (or at least the full entity name) from the identityApi
// TODO: get the full entity (or at least the full entity name) from the
// identityApi
return useAsync(
() =>
catalogApi.getEntityByName({
kind: 'User',
namespace: 'default',
name: identityApi.getUserId(),
}) as Promise<UserEntity>,
}) as Promise<UserEntity | undefined>,
[catalogApi, identityApi],
);
}