MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / GetBoolean

Method GetBoolean

apis/controller/v1alpha1/attributes.go:154–173  ·  view source on GitHub ↗

GetBoolean allows returning the attribute with the given key as a bool. If the attribute JSON/YAML content is not a JSON boolean (or a JSON string that can be converted into a JSON boolean), then the result will be the `false` zero value and an error is raised. String values can be converted to bo

(key string, errorHolder *error)

Source from the content-addressed store, hash-verified

152// to receive any error that might have be raised during the attribute
153// decoding
154func (attributes Attributes) GetBoolean(key string, errorHolder *error) bool {
155 return attributes.getPrimitive(
156 key,
157 false,
158 "boolean",
159 func(attributes Attributes, key string, attributeType string) (interface{}, error) {
160 var convertedValue interface{}
161 var retryError error
162 switch attributeType {
163 case "string":
164 var convError error
165 convertedValue, convError = strconv.ParseBool(attributes.GetString(key, &retryError))
166 if retryError == nil {
167 retryError = convError
168 }
169 }
170 return convertedValue, retryError
171 },
172 errorHolder).(bool)
173}
174
175// Get allows returning the attribute with the given key
176// as an interface. The underlying type of the returned interface

Callers 9

GetStringMethod · 0.95
GetServiceForEndpointsFunction · 0.80
findMergeTargetFunction · 0.80
NeedsBootstrapFunction · 0.80

Calls 2

getPrimitiveMethod · 0.95
GetStringMethod · 0.95

Tested by

no test coverage detected