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

Method GetString

apis/controller/v1alpha1/attributes.go:90–107  ·  view source on GitHub ↗

GetString allows returning the attribute with the given key as a string. If the attribute JSON/YAML content is not a JSON string (or a primitive type that can be converted into a string), then the result will be the empty string and an error will be raised. An optional error holder can be passed as

(key string, errorHolder *error)

Source from the content-addressed store, hash-verified

88// to receive any error that might have be raised during the attribute
89// decoding
90func (attributes Attributes) GetString(key string, errorHolder *error) string {
91 return attributes.getPrimitive(
92 key,
93 "",
94 "string",
95 func(attributes Attributes, key string, attributeType string) (interface{}, error) {
96 var convertedValue interface{}
97 var retryError error
98 switch attributeType {
99 case "bool":
100 convertedValue = strconv.FormatBool(attributes.GetBoolean(key, &retryError))
101 case "number":
102 convertedValue = strconv.FormatFloat(attributes.GetNumber(key, &retryError), 'g', -1, 64)
103 }
104 return convertedValue, retryError
105 },
106 errorHolder).(string)
107}
108
109// GetNumber allows returning the attribute with the given key
110// as a float64. If the attribute JSON/YAML content is

Callers 15

GetNumberMethod · 0.95
GetBooleanMethod · 0.95
dwPVCHandlerMethod · 0.80
getMainUrlFunction · 0.80
findMergeTargetFunction · 0.80
mergeContributionsIntoFunction · 0.80
GetStarterProjectFunction · 0.80
InferWorkspaceImageFunction · 0.80

Calls 3

getPrimitiveMethod · 0.95
GetBooleanMethod · 0.95
GetNumberMethod · 0.95

Tested by

no test coverage detected