55 "fmt"
66
77 v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
8+ "github.com/conductorone/baton-sdk/pkg/annotations"
89)
910
1011func (c Config ) extractTraits (rtID string ) ([]v2.ResourceType_Trait , error ) {
@@ -54,12 +55,19 @@ func (c Config) GetResourceTypes(ctx context.Context) ([]*v2.ResourceType, error
5455 return nil , err
5556 }
5657
57- resourceTypes = append ( resourceTypes , & v2.ResourceType {
58+ resourceType := & v2.ResourceType {
5859 Id : rtID ,
5960 DisplayName : rt .Name ,
6061 Description : rt .Description ,
6162 Traits : traits ,
62- })
63+ }
64+
65+ if rt .SkipEntitlementsAndGrants {
66+ annos := annotations .Annotations (resourceType .Annotations )
67+ annos .Update (& v2.SkipEntitlementsAndGrants {})
68+ resourceType .Annotations = annos
69+ }
70+ resourceTypes = append (resourceTypes , resourceType )
6371 }
6472 return resourceTypes , nil
6573}
@@ -75,10 +83,18 @@ func (c Config) GetResourceType(ctx context.Context, rtID string) (*v2.ResourceT
7583 return nil , fmt .Errorf ("resource type %s not found in config" , rtID )
7684 }
7785
78- return & v2.ResourceType {
86+ ret := & v2.ResourceType {
7987 Id : rtID ,
8088 DisplayName : rt .Name ,
8189 Description : rt .Description ,
8290 Traits : traits ,
83- }, nil
91+ }
92+
93+ if rt .SkipEntitlementsAndGrants {
94+ annos := annotations .Annotations (ret .Annotations )
95+ annos .Update (& v2.SkipEntitlementsAndGrants {})
96+ ret .Annotations = annos
97+ }
98+
99+ return ret , nil
84100}
0 commit comments