github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/domain/viewer/converter.go (about) 1 package viewer 2 3 import ( 4 "github.com/kyma-incubator/compass/components/director/pkg/apperrors" 5 "github.com/kyma-incubator/compass/components/director/pkg/consumer" 6 "github.com/kyma-incubator/compass/components/director/pkg/graphql" 7 ) 8 9 // ToViewer missing godoc 10 func ToViewer(cons consumer.Consumer) (*graphql.Viewer, error) { 11 switch cons.ConsumerType { 12 case consumer.Runtime: 13 return &graphql.Viewer{ID: cons.ConsumerID, Type: graphql.ViewerTypeRuntime}, nil 14 case consumer.Application: 15 return &graphql.Viewer{ID: cons.ConsumerID, Type: graphql.ViewerTypeApplication}, nil 16 case consumer.IntegrationSystem: 17 return &graphql.Viewer{ID: cons.ConsumerID, Type: graphql.ViewerTypeIntegrationSystem}, nil 18 case consumer.User: 19 return &graphql.Viewer{ID: cons.ConsumerID, Type: graphql.ViewerTypeUser}, nil 20 } 21 22 return nil, apperrors.NewInternalError("viewer does not exist") 23 }