@@ -8,13 +8,13 @@ import (
88 "time"
99
1010 "github.com/SAP/crossplane-provider-cloudfoundry/apis/resources/v1alpha1"
11- "github.com/SAP/crossplane-provider-cloudfoundry/cmd/exporter/cf/cache"
1211 "github.com/SAP/crossplane-provider-cloudfoundry/cmd/exporter/cf/guidname"
1312 "github.com/SAP/crossplane-provider-cloudfoundry/cmd/exporter/cf/resources"
1413
1514 "github.com/SAP/xp-clifford/cli/configparam"
1615 "github.com/SAP/xp-clifford/cli/export"
1716 "github.com/SAP/xp-clifford/erratt"
17+ "github.com/SAP/xp-clifford/mkcontainer"
1818 "github.com/SAP/xp-clifford/parsan"
1919 "github.com/SAP/xp-clifford/yaml"
2020 "github.com/cloudfoundry/go-cfclient/v3/client"
@@ -23,7 +23,7 @@ import (
2323)
2424
2525var (
26- c cache. CacheWithGUIDAndName [ * res ]
26+ c mkcontainer. Container
2727 param = configparam .StringSlice ("organization" , "Filter for Cloud Foundry organizations" ).
2828 WithFlagName ("org" )
2929)
@@ -37,6 +37,11 @@ type res struct {
3737 * yaml.ResourceWithComment
3838}
3939
40+ var (
41+ _ mkcontainer.ItemWithGUID = & res {}
42+ _ mkcontainer.ItemWithName = & res {}
43+ )
44+
4045func (r * res ) GetGUID () string {
4146 return r .GUID
4247}
@@ -67,17 +72,17 @@ func (o org) Export(ctx context.Context, cfClient *client.Client, evHandler expo
6772 if err != nil {
6873 return err
6974 }
70- if orgs .Len () == 0 {
75+ if orgs .IsEmpty () {
7176 evHandler .Warn (erratt .New ("no orgs found" , "orgs" , param .Value ()))
7277 } else {
7378 for _ , org := range orgs .AllByGUIDs () {
74- evHandler .Resource (convertOrgResource (org ))
79+ evHandler .Resource (convertOrgResource (org .( * res ) ))
7580 }
7681 }
7782 return nil
7883}
7984
80- func Get (ctx context.Context , cfClient * client.Client ) (cache. CacheWithGUIDAndName [ * res ] , error ) {
85+ func Get (ctx context.Context , cfClient * client.Client ) (mkcontainer. Container , error ) {
8186 if c != nil {
8287 return c , nil
8388 }
@@ -103,8 +108,8 @@ func Get(ctx context.Context, cfClient *client.Client) (cache.CacheWithGUIDAndNa
103108 if err != nil {
104109 return nil , err
105110 }
106- c = cache . NewWithGUIDAndName [ * res ] ()
107- c .StoreWithGUIDAndName (orgs ... )
111+ c = mkcontainer . New ()
112+ c .Store (orgs ... )
108113 slog .Debug ("orgs collected" , "orgs" , c .GetNames ())
109114 return c , nil
110115}
@@ -122,7 +127,7 @@ func ResolveReference(ctx context.Context, cfClient *client.Client, orgRef *v1al
122127 return erratt .New ("space reference not found" , "GUID" , * orgRef .Org )
123128 }
124129 orgRef .OrgRef = & v1.Reference {
125- Name : org .Name ,
130+ Name : org .(mkcontainer. ItemWithName ). GetName () ,
126131 }
127132 orgRef .Org = nil
128133 return nil
@@ -136,13 +141,13 @@ func getAllNamesFn(ctx context.Context, cfClient *client.Client) func() ([]strin
136141 }
137142 names := make ([]string , len (resources ))
138143 for i , res := range resources {
139- names [i ] = guidname .NewName (res . GUID , res . Name ).String ()
144+ names [i ] = guidname .NewName (res ).String ()
140145 }
141146 return names , nil
142147 }
143148}
144149
145- func getAll (ctx context.Context , cfClient * client.Client , orgNames []string ) ([]* res , error ) {
150+ func getAll (ctx context.Context , cfClient * client.Client , orgNames []string ) ([]mkcontainer. Item , error ) {
146151 var nameRxs []* regexp.Regexp
147152
148153 if len (orgNames ) > 0 {
@@ -163,7 +168,7 @@ func getAll(ctx context.Context, cfClient *client.Client, orgNames []string) ([]
163168 return nil , err
164169 }
165170
166- var results []* res
171+ var results []mkcontainer. Item
167172 for _ , org := range orgs {
168173 for _ , nameRx := range nameRxs {
169174 if nameRx .MatchString (org .Name ) {
0 commit comments