@@ -18,13 +18,13 @@ import (
1818 "github.com/openshift/hive/pkg/util/scheme"
1919)
2020
21- // RTOApplyOpt (runtime.Object apply option) modifies a runtime.Object in preparation for applying it.
22- type RTOApplyOpt func (runtime.Object , log.FieldLogger ) error
21+ // rtoApplyOpt (runtime.Object apply option) modifies a runtime.Object in preparation for applying it.
22+ type rtoApplyOpt func (runtime.Object , log.FieldLogger ) error
2323
24- // WithGarbageCollection returns a RTOApplyOpt that adds an owner reference to parent to the
24+ // withGarbageCollection returns a RTOApplyOpt that adds an owner reference to parent to the
2525// runtime object so the latter gets cleaned up when the parent is deleted. Errors only happen
2626// if the runtime object can't be interpreted as a metav1.Object or meta.Type.
27- func WithGarbageCollection (parent v1.Object ) RTOApplyOpt {
27+ func withGarbageCollection (parent v1.Object ) rtoApplyOpt {
2828 return func (runtimeObj runtime.Object , hLog log.FieldLogger ) error {
2929 obj , err := meta .Accessor (runtimeObj )
3030 if err != nil {
@@ -52,9 +52,9 @@ func WithGarbageCollection(parent v1.Object) RTOApplyOpt {
5252 }
5353}
5454
55- // WithNamespaceOverride returns a RTOApplyOpt that sets the namespace of the runtime object.
55+ // withNamespaceOverride returns a RTOApplyOpt that sets the namespace of the runtime object.
5656// There are no error cases.
57- func WithNamespaceOverride (namespaceOverride string ) RTOApplyOpt {
57+ func withNamespaceOverride (namespaceOverride string ) rtoApplyOpt {
5858 return func (runtimeObj runtime.Object , hLog log.FieldLogger ) error {
5959 obj , err := meta .Accessor (runtimeObj )
6060 if err != nil {
@@ -66,11 +66,11 @@ func WithNamespaceOverride(namespaceOverride string) RTOApplyOpt {
6666 }
6767}
6868
69- // CRBWithSubjectNSOverride sets the namespace of each Subject to namespaceOverride if it is
69+ // crbWithSubjectNSOverride sets the namespace of each Subject to namespaceOverride if it is
7070// - a ServiceAccount subject
7171// - otherwise unset
7272// Errors if the runtime object is not a *ClusterRoleBinding
73- func CRBWithSubjectNSOverride (namespaceOverride string ) RTOApplyOpt {
73+ func crbWithSubjectNSOverride (namespaceOverride string ) rtoApplyOpt {
7474 return func (rto runtime.Object , hLog log.FieldLogger ) error {
7575 rb , ok := rto .(* rbacv1.ClusterRoleBinding )
7676 if ! ok {
@@ -85,49 +85,49 @@ func CRBWithSubjectNSOverride(namespaceOverride string) RTOApplyOpt {
8585 }
8686}
8787
88- // ToRuntimeObject defines a function that produces a runtime object. It is intended for use
88+ // toRuntimeObject defines a function that produces a runtime object. It is intended for use
8989// in closures to supply such objects from different sources (asset paths, byte arrays) to
9090// ApplyRuntimeObject().
91- type ToRuntimeObject func (log.FieldLogger ) (runtime.Object , error )
91+ type toRuntimeObject func (log.FieldLogger ) (runtime.Object , error )
9292
93- // Passthrough 's func just returns the input runtime object.
94- func Passthrough (rto runtime.Object ) ToRuntimeObject {
93+ // passthrough 's func just returns the input runtime object.
94+ func passthrough (rto runtime.Object ) toRuntimeObject {
9595 return func (fl log.FieldLogger ) (runtime.Object , error ) {
9696 return rto , nil
9797 }
9898}
9999
100- // FromAssetPath 's func loads a runtime object from a known asset path in bindata.
101- func FromAssetPath (assetPath string ) ToRuntimeObject {
100+ // fromAssetPath 's func loads a runtime object from a known asset path in bindata.
101+ func fromAssetPath (assetPath string ) toRuntimeObject {
102102 return func (hLog log.FieldLogger ) (runtime.Object , error ) {
103103 hLog .WithField ("assetPath" , assetPath ).Info ("loading runtime object from asset" )
104104 return readRuntimeObject (assetPath )
105105 }
106106}
107107
108- // CRBFromAssetPath is a special case of FromAssetPath that returns a *ClusterRoleBinding
108+ // crbFromAssetPath is a special case of FromAssetPath that returns a *ClusterRoleBinding
109109// (a specific instance of a runtime object) from a known asset path in bindata. Panics if
110110// the asset is not a CRB, or if the asset can't be loaded from the specified path.
111- func CRBFromAssetPath (roleBindingAssetPath string ) ToRuntimeObject {
111+ func crbFromAssetPath (roleBindingAssetPath string ) toRuntimeObject {
112112 return func (hLog log.FieldLogger ) (runtime.Object , error ) {
113113 hLog .WithField ("assetPath" , roleBindingAssetPath ).Info ("loading ClusterRoleBinding from asset" )
114114 return resourceread .ReadClusterRoleBindingV1OrDie (assets .MustAsset (roleBindingAssetPath )), nil
115115 }
116116}
117117
118- // FromBytes produces a func that decodes a byte array into a runtime object.
119- func FromBytes (assetBytes []byte ) ToRuntimeObject {
118+ // fromBytes produces a func that decodes a byte array into a runtime object.
119+ func fromBytes (assetBytes []byte ) toRuntimeObject {
120120 return func (hLog log.FieldLogger ) (runtime.Object , error ) {
121121 hLog .Info ("decoding runtime object from bytes" )
122122 return decodeRuntimeObject (assetBytes )
123123 }
124124}
125125
126- // ApplyRuntimeObject
126+ // applyRuntimeObject
127127// - Executes rtoFactory to produce a runtime object.
128128// - Modifies the runtime object according to opts.
129129// - Applies the runtime object to the cluster via h.
130- func ApplyRuntimeObject (h resource.Helper , rtoFactory ToRuntimeObject , hLog log.FieldLogger , opts ... RTOApplyOpt ) (resource.ApplyResult , error ) {
130+ func applyRuntimeObject (h resource.Helper , rtoFactory toRuntimeObject , hLog log.FieldLogger , opts ... rtoApplyOpt ) (resource.ApplyResult , error ) {
131131 requiredObj , err := rtoFactory (hLog )
132132 if err != nil {
133133 hLog .WithError (err ).Error ("failed to convert to runtime object" )
@@ -142,23 +142,23 @@ func ApplyRuntimeObject(h resource.Helper, rtoFactory ToRuntimeObject, hLog log.
142142 return h .ApplyRuntimeObject (requiredObj , scheme .GetScheme ())
143143}
144144
145- func DeleteAssetByPathWithNSOverride (h resource.Helper , assetPath , namespaceOverride string , hiveconfig * hivev1.HiveConfig ) error {
145+ func deleteAssetByPathWithNSOverride (h resource.Helper , assetPath , namespaceOverride string , hiveconfig * hivev1.HiveConfig ) error {
146146 requiredObj , err := readRuntimeObject (assetPath )
147147 if err != nil {
148148 return errors .Wrapf (err , "unable to decode asset: %s" , assetPath )
149149 }
150- return DeleteRuntimeObjectWithNSOverride (h , requiredObj , namespaceOverride , hiveconfig )
150+ return deleteRuntimeObjectWithNSOverride (h , requiredObj , namespaceOverride , hiveconfig )
151151}
152152
153- func DeleteAssetBytesWithNSOverride (h resource.Helper , assetBytes []byte , namespaceOverride string , hiveconfig * hivev1.HiveConfig ) error {
153+ func deleteAssetBytesWithNSOverride (h resource.Helper , assetBytes []byte , namespaceOverride string , hiveconfig * hivev1.HiveConfig ) error {
154154 rtObj , err := decodeRuntimeObject (assetBytes )
155155 if err != nil {
156156 return errors .Wrap (err , "unable to decode asset" )
157157 }
158- return DeleteRuntimeObjectWithNSOverride (h , rtObj , namespaceOverride , hiveconfig )
158+ return deleteRuntimeObjectWithNSOverride (h , rtObj , namespaceOverride , hiveconfig )
159159}
160160
161- func DeleteRuntimeObjectWithNSOverride (h resource.Helper , requiredObj runtime.Object , namespaceOverride string , hiveconfig * hivev1.HiveConfig ) error {
161+ func deleteRuntimeObjectWithNSOverride (h resource.Helper , requiredObj runtime.Object , namespaceOverride string , hiveconfig * hivev1.HiveConfig ) error {
162162 objA , _ := meta .Accessor (requiredObj )
163163 objT , _ := meta .TypeAccessor (requiredObj )
164164 if err := h .Delete (objT .GetAPIVersion (), objT .GetKind (), namespaceOverride , objA .GetName ()); err != nil {
0 commit comments