Skip to content

Commit

Permalink
feat: add AddReference method to References
Browse files Browse the repository at this point in the history
Signed-off-by: Yordis Prieto <[email protected]>
  • Loading branch information
yordis committed Jun 2, 2024
1 parent 4073347 commit 30b0582
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/config/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@ type ExternalName struct {
// given resource. Key should be the field path of the field to be referenced.
type References map[string]Reference

// AddReference adds a reference configuration for the given field path.
// The fieldPath is the Terraform field path of the field to be referenced.
//
// Example: "vpc_id" or "forwarding_rule.certificate_name" in case of nested
// in another object.
func (r References) AddReference(fieldPath string, ref Reference) error {
if _, ok := r[fieldPath]; ok {
return fmt.Errorf("reference for field %s already exists", fieldPath)
}

r[fieldPath] = ref
return nil
}

// Reference represents the Crossplane options used to generate
// reference resolvers for fields
type Reference struct {
Expand Down

0 comments on commit 30b0582

Please sign in to comment.