Skip to content

Commit

Permalink
Merge pull request #341 from psinghal20/router-resource
Browse files Browse the repository at this point in the history
Add Router Resource
  • Loading branch information
turkenh authored Dec 2, 2021
2 parents cf9303b + b2416eb commit b619aff
Show file tree
Hide file tree
Showing 13 changed files with 2,809 additions and 0 deletions.
21 changes: 21 additions & 0 deletions apis/compute/v1alpha1/referencers.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,24 @@ func (mg *Firewall) ResolveReferences(ctx context.Context, c client.Reader) erro

return nil
}

// ResolveReferences of this Router
func (mg *Router) ResolveReferences(ctx context.Context, c client.Reader) error {
r := reference.NewAPIResolver(c, mg)

// Resolve spec.forProvider.network
rsp, err := r.Resolve(ctx, reference.ResolutionRequest{
CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Network),
Reference: mg.Spec.ForProvider.NetworkRef,
Selector: mg.Spec.ForProvider.NetworkSelector,
To: reference.To{Managed: &v1beta1.Network{}, List: &v1beta1.NetworkList{}},
Extract: v1beta1.NetworkURL(),
})
if err != nil {
return errors.Wrap(err, "spec.forProvider.network")
}
mg.Spec.ForProvider.Network = reference.ToPtrValue(rsp.ResolvedValue)
mg.Spec.ForProvider.NetworkRef = rsp.ResolvedReference

return nil
}
9 changes: 9 additions & 0 deletions apis/compute/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ var (
FirewallGroupVersionKind = SchemeGroupVersion.WithKind(FirewallKind)
)

// Router type metadata.
var (
RouterKind = reflect.TypeOf(Router{}).Name()
RouterGroupKind = schema.GroupKind{Group: Group, Kind: RouterKind}.String()
RouterKindAPIVersion = RouterKind + "." + SchemeGroupVersion.String()
RouterGroupVersionKind = SchemeGroupVersion.WithKind(RouterKind)
)

func init() {
SchemeBuilder.Register(&Firewall{}, &FirewallList{})
SchemeBuilder.Register(&Router{}, &RouterList{})
}
Loading

0 comments on commit b619aff

Please sign in to comment.