getRefSubAttribute returns the sub-attribute of the reference attribute that matches the given subAttrName, if none are found it will return an error.
(refAttr *schema.CoreAttribute, subAttrName string)
| 153 | // getRefSubAttribute returns the sub-attribute of the reference attribute that matches the given subAttrName, if none |
| 154 | // are found it will return an error. |
| 155 | func (v OperationValidator) getRefSubAttribute(refAttr *schema.CoreAttribute, subAttrName string) (*schema.CoreAttribute, error) { |
| 156 | if !refAttr.HasSubAttributes() { |
| 157 | return nil, fmt.Errorf("the referred attribute has no sub-attributes: %s", v.Path) |
| 158 | } |
| 159 | var refSubAttr *schema.CoreAttribute |
| 160 | for _, attr := range refAttr.SubAttributes() { |
| 161 | if strings.EqualFold(attr.Name(), subAttrName) { |
| 162 | refSubAttr = &attr |
| 163 | break |
| 164 | } |
| 165 | } |
| 166 | if refSubAttr == nil { |
| 167 | return nil, fmt.Errorf("could not find attribute %s", v.Path) |
| 168 | } |
| 169 | return refSubAttr, nil |
| 170 | } |
| 171 | |
| 172 | // validateEmptyPath validates paths that don't have a "path" value. In this case the target location is assumed to be |
| 173 | // the resource itself. The "value" parameter contains a set of attributes to be added to the resource. |