// ItemsFromResource attempts to construct one or more instances of `backend.Item` from
// a given resource.  If `rsc` is not one of the supported resource types,
// a `trace.NotImplementedError` is returned.
ItemsFromResource attempts to construct one or more instances of `backend.Item` from
a given resource.  If `rsc` is not one of the supported resource types,
a `trace.NotImplementedError` is returned.
// ItemsFromResource attempts to construct one or more instances of ` backend . Item ` from // a given resource . If ` rsc ` is not one of the supported resource types // a ` trace . NotImplementedError ` is returned .
func itemsFromResource(resource services.Resource) ([]backend.Item, error) {
	var item *backend.Item
	var extItems []backend.Item
	var err error
	switch r := resource.(type) {
	case services.User:
		item, err = itemFromUser(r)
		if auth := r.GetLocalAuth(); err == nil && auth != nil {
			extItems, err = itemsFromLocalAuthSecrets(r.GetName(), *auth)
		}
	case services.CertAuthority:
		item, err = itemFromCertAuthority(r)
	case services.TrustedCluster:
		item, err = itemFromTrustedCluster(r)
	case services.GithubConnector:
		item, err = itemFromGithubConnector(r)
	case services.Role:
		item, err = itemFromRole(r)
	case services.OIDCConnector:
		item, err = itemFromOIDCConnector(r)
	case services.SAMLConnector:
		item, err = itemFromSAMLConnector(r)
	default:
		return nil, trace.NotImplemented("cannot itemFrom resource of type %T", resource)
	}
	if err != nil {
		return nil, trace.Wrap(err)
	}
	items := make([]backend.Item, 0, len(extItems)+1)
	items = append(items, *item)
	items = append(items, extItems...)
	return items, nil
}
func itemsFromResource ( resource services . Resource ) ( [ ] backend . Item , error ) { var item * backend . Item var extItems [ ] backend . Item var err error switch r := resource . ( type ) { case services . User : item , err = itemFromUser ( r ) if auth := r . GetLocalAuth ( ) ; err == nil && auth != nil { extItems , err = itemsFromLocalAuthSecrets ( r . GetName ( ) , * auth ) } case services . CertAuthority : item , err = itemFromCertAuthority ( r ) case services . TrustedCluster : item , err = itemFromTrustedCluster ( r ) case services . GithubConnector : item , err = itemFromGithubConnector ( r ) case services . Role : item , err = itemFromRole ( r ) case services . OIDCConnector : item , err = itemFromOIDCConnector ( r ) case services . SAMLConnector : item , err = itemFromSAMLConnector ( r ) default : return nil , trace . NotImplemented ( " " , resource ) } if err != nil { return nil , trace . Wrap ( err ) } items := make ( [ ] backend . Item , 0 , len ( extItems ) + 1 ) items = append ( items , * item ) items = append ( items , extItems ... ) return items , nil }
ItemsFromResource attempts to construct one or more instances of `backend.Item` from
a given resource.
ItemsFromResource attempts to construct one or more instances of ` backend . Item ` from a given resource .