Skip to content

Commit 30b0582

Browse files
committed
feat: add AddReference method to References
Signed-off-by: Yordis Prieto <[email protected]>
1 parent 4073347 commit 30b0582

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/config/resource.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ type ExternalName struct {
169169
// given resource. Key should be the field path of the field to be referenced.
170170
type References map[string]Reference
171171

172+
// AddReference adds a reference configuration for the given field path.
173+
// The fieldPath is the Terraform field path of the field to be referenced.
174+
//
175+
// Example: "vpc_id" or "forwarding_rule.certificate_name" in case of nested
176+
// in another object.
177+
func (r References) AddReference(fieldPath string, ref Reference) error {
178+
if _, ok := r[fieldPath]; ok {
179+
return fmt.Errorf("reference for field %s already exists", fieldPath)
180+
}
181+
182+
r[fieldPath] = ref
183+
return nil
184+
}
185+
172186
// Reference represents the Crossplane options used to generate
173187
// reference resolvers for fields
174188
type Reference struct {

0 commit comments

Comments
 (0)