@@ -42,26 +42,18 @@ type ErrTPRInstall struct {
4242 errMsg string
4343}
4444
45- // Installer takes in a client and exposes method for installing third party resources
46- type Installer struct {
47- tprs extensionsv1beta.ThirdPartyResourceInterface
48- }
49-
50- // NewInstaller is used to install third party resources
51- func NewInstaller (tprs extensionsv1beta.ThirdPartyResourceInterface ) * Installer {
52- return & Installer {
53- tprs : tprs ,
54- }
45+ func (e ErrTPRInstall ) Error () string {
46+ return e .errMsg
5547}
5648
5749// InstallTypes installs all third party resource types to the cluster
58- func ( i * Installer ) InstallTypes () error {
50+ func InstallTypes (cl extensionsv1beta. ThirdPartyResourceInterface ) error {
5951 var wg sync.WaitGroup
6052 errMsg := make (chan string , len (thirdPartyResources ))
6153
6254 for _ , tpr := range thirdPartyResources {
6355 glog .Infof ("Checking for existence of %s" , tpr .Name )
64- if _ , err := i . tprs .Get (tpr .Name ); err == nil {
56+ if _ , err := cl .Get (tpr .Name ); err == nil {
6557 glog .Infof ("Found existing TPR %s" , tpr .Name )
6658 continue
6759 }
@@ -71,7 +63,7 @@ func (i *Installer) InstallTypes() error {
7163 wg .Add (1 )
7264 go func (tpr v1beta1.ThirdPartyResource , client extensionsv1beta.ThirdPartyResourceInterface ) {
7365 defer wg .Done ()
74- if _ , err := i . tprs .Create (& tpr ); err != nil {
66+ if _ , err := cl .Create (& tpr ); err != nil {
7567 errMsg <- fmt .Sprintf ("%s: %s" , tpr .Name , err )
7668 } else {
7769 glog .Infof ("Created TPR '%s'" , tpr .Name )
@@ -90,7 +82,7 @@ func (i *Installer) InstallTypes() error {
9082 glog .Infof ("Error polling for TPR status:" , err )
9183 }
9284 }
93- }(tpr , i . tprs )
85+ }(tpr , cl )
9486 }
9587
9688 wg .Wait ()
@@ -110,7 +102,3 @@ func (i *Installer) InstallTypes() error {
110102
111103 return nil
112104}
113-
114- func (e ErrTPRInstall ) Error () string {
115- return e .errMsg
116- }
0 commit comments