@@ -68,7 +68,7 @@ func (d *defaultServicePlan) Admit(a admission.Attributes) error {
68
68
}
69
69
instance , ok := a .GetObject ().(* servicecatalog.ServiceInstance )
70
70
if ! ok {
71
- return apierrors .NewBadRequest ("Resource was marked with kind Instance but was unable to be converted" )
71
+ return apierrors .NewBadRequest ("Resource was marked with kind ServiceInstance but was unable to be converted" )
72
72
}
73
73
74
74
// If the plan is specified, let it through and have the controller
@@ -83,7 +83,7 @@ func (d *defaultServicePlan) Admit(a admission.Attributes) error {
83
83
if ! apierrors .IsNotFound (err ) {
84
84
return admission .NewForbidden (a , err )
85
85
}
86
- msg := fmt .Sprintf ("ServiceClass %q does not exist, can not figure out the default Service Plan ." , instance .Spec .ClusterServiceClassExternalName )
86
+ msg := fmt .Sprintf ("ClusterServiceClass %q does not exist, can not figure out the default ClusterServicePlan ." , instance .Spec .ClusterServiceClassExternalName )
87
87
glog .V (4 ).Info (msg )
88
88
return admission .NewForbidden (a , errors .New (msg ))
89
89
}
@@ -98,30 +98,30 @@ func (d *defaultServicePlan) Admit(a admission.Attributes) error {
98
98
99
99
plans , err := d .getClusterServicePlansByClusterServiceClassName (sc .Name )
100
100
if err != nil {
101
- msg := fmt .Sprintf ("Error listing plans for service class (K8S: %v ExternalName: %v) - retry and specify desired ClusterServicePlan" , sc .Name , instance .Spec .ClusterServiceClassExternalName )
102
- glog .V (4 ).Info ( msg )
101
+ msg := fmt .Sprintf ("Error listing ClusterServicePlans for ClusterServiceClass (K8S: %v ExternalName: %v) - retry and specify desired ClusterServicePlan" , sc .Name , instance .Spec .ClusterServiceClassExternalName )
102
+ glog .V (4 ).Infof ( `ServiceInstance "%s/%s": %s` , instance . Namespace , instance . Name , msg )
103
103
return admission .NewForbidden (a , errors .New (msg ))
104
104
}
105
105
106
106
// check if there were any service plans
107
107
// TODO: in combination with not allowing classes with no plans, this should be impossible
108
108
if len (plans ) <= 0 {
109
- msg := fmt .Sprintf ("no plans found at all for service class %q" , instance .Spec .ClusterServiceClassExternalName )
110
- glog .V (4 ).Info ( msg )
109
+ msg := fmt .Sprintf ("no ClusterServicePlans found at all for ClusterServiceClass %q" , instance .Spec .ClusterServiceClassExternalName )
110
+ glog .V (4 ).Infof ( `ServiceInstance "%s/%s": %s` , instance . Namespace , instance . Name , msg )
111
111
return admission .NewForbidden (a , errors .New (msg ))
112
112
}
113
113
114
114
// check if more than one service plan was specified and error
115
115
if len (plans ) > 1 {
116
116
msg := fmt .Sprintf ("ServiceClass %q has more than one plan, PlanName must be specified" , instance .Spec .ClusterServiceClassExternalName )
117
- glog .V (4 ).Info ( msg )
117
+ glog .V (4 ).Infof ( `ServiceInstance "%s/%s": %s` , instance . Namespace , instance . Name , msg )
118
118
return admission .NewForbidden (a , errors .New (msg ))
119
119
}
120
120
// otherwise, by default, pick the only plan that exists for the service class
121
121
122
122
p := plans [0 ]
123
- glog .V (4 ).Infof (" Using default plan %q (K8S: %q) for Service Class %q for instance %s" ,
124
- p .Spec .ExternalName , p .Name , sc .Spec .ExternalName , instance . Name )
123
+ glog .V (4 ).Infof (`ServiceInstance "%s/%s": Using default plan %q (K8S: %q) for Service Class %q` ,
124
+ instance . Namespace , instance . Name , p .Spec .ExternalName , p .Name , sc .Spec .ExternalName )
125
125
if instance .Spec .ClusterServiceClassExternalName != "" {
126
126
instance .Spec .ClusterServicePlanExternalName = p .Spec .ExternalName
127
127
} else {
@@ -147,10 +147,10 @@ func (d *defaultServicePlan) SetInternalServiceCatalogClientSet(f internalclient
147
147
148
148
func (d * defaultServicePlan ) Validate () error {
149
149
if d .scClient == nil {
150
- return errors .New ("missing service class interface" )
150
+ return errors .New ("missing clusterserviceclass interface" )
151
151
}
152
152
if d .spClient == nil {
153
- return errors .New ("missing serviceplan interface" )
153
+ return errors .New ("missing clusterserviceplan interface" )
154
154
}
155
155
return nil
156
156
}
@@ -163,27 +163,27 @@ func (d *defaultServicePlan) getClusterServiceClassByPlanReference(a admission.A
163
163
}
164
164
165
165
func (d * defaultServicePlan ) getClusterServiceClassByK8SName (a admission.Attributes , scK8SName string ) (* servicecatalog.ClusterServiceClass , error ) {
166
- glog .V (4 ).Infof ("Fetching serviceclass by class k8s name %q" , scK8SName )
166
+ glog .V (4 ).Infof ("Fetching ClusterServiceClass by k8s name %q" , scK8SName )
167
167
return d .scClient .Get (scK8SName , apimachineryv1.GetOptions {})
168
168
}
169
169
170
170
func (d * defaultServicePlan ) getClusterServiceClassByExternalName (a admission.Attributes , scName string ) (* servicecatalog.ClusterServiceClass , error ) {
171
- glog .V (4 ).Infof ("Fetching serviceclass filtered by class external name %q" , scName )
171
+ glog .V (4 ).Infof ("Fetching ClusterServiceClass filtered by external name %q" , scName )
172
172
fieldSet := fields.Set {
173
173
"spec.externalName" : scName ,
174
174
}
175
175
fieldSelector := fields .SelectorFromSet (fieldSet ).String ()
176
176
listOpts := apimachineryv1.ListOptions {FieldSelector : fieldSelector }
177
177
serviceClasses , err := d .scClient .List (listOpts )
178
178
if err != nil {
179
- glog .V (4 ).Infof ("List failed %q" , err )
179
+ glog .V (4 ).Infof ("Listing ClusterServiceClasses failed: %q" , err )
180
180
return nil , err
181
181
}
182
182
if len (serviceClasses .Items ) == 1 {
183
- glog .V (4 ).Infof ("Found Single item as %+v" , serviceClasses .Items [0 ])
183
+ glog .V (4 ).Infof ("Found single ClusterServiceClass as %+v" , serviceClasses .Items [0 ])
184
184
return & serviceClasses .Items [0 ], nil
185
185
}
186
- msg := fmt .Sprintf ("Could not find a single ServiceClass with name %q, found %v" , scName , len (serviceClasses .Items ))
186
+ msg := fmt .Sprintf ("Could not find a single ClusterServiceClass with name %q, found %v" , scName , len (serviceClasses .Items ))
187
187
glog .V (4 ).Info (msg )
188
188
return nil , admission .NewNotFound (a )
189
189
}
@@ -199,10 +199,10 @@ func (d *defaultServicePlan) getClusterServicePlansByClusterServiceClassName(scN
199
199
listOpts := apimachineryv1.ListOptions {FieldSelector : fieldSelector }
200
200
servicePlans , err := d .spClient .List (listOpts )
201
201
if err != nil {
202
- glog .Infof ("List failed %q" , err )
202
+ glog .Infof ("Listing ClusterServicePlans failed: %q" , err )
203
203
return nil , err
204
204
}
205
- glog .V (4 ).Infof ("plans fetched by filtering classname: %+v" , servicePlans .Items )
205
+ glog .V (4 ).Infof ("ClusterServicePlans fetched by filtering classname: %+v" , servicePlans .Items )
206
206
r := servicePlans .Items
207
207
return r , err
208
208
}
0 commit comments