func()

in pkg/cloud/rgraph/testing/ez/factories.go [390:428]


func (f targetHttpProxyFactory) builder(g *Graph, n *Node) rnode.Builder {
	id := f.id(g, n)
	b := targethttpproxy.NewBuilder(id)
	setCommonOptions(n, b)

	if b.State() == rnode.NodeExists {
		ma := targethttpproxy.NewMutableTargetHttpProxy(id.ProjectID, id.Key)
		err := ma.Access(func(x *compute.TargetHttpProxy) {
			for _, ref := range n.Refs {
				switch ref.Field {
				case "UrlMap":
					x.UrlMap = g.ids.selfLink(ref.To)
				default:
					panicf("invalid Ref Field: %q (must be one of [UrlMap])", ref.Field)
				}
			}

			if n.SetupFunc != nil {
				sf, ok := n.SetupFunc.(func(x *compute.TargetHttpProxy))
				if !ok {
					panicf("invalid type for SetupFunc: %T", n.SetupFunc)
				}
				sf(x)
			}
		})
		if g.Options&PanicOnAccessErr != 0 && err != nil {
			panicf("targetHttpProxyFactory %s: Access: %v", id, err)
		}
		r, err := ma.Freeze()
		if err != nil {
			panic(err)
		}
		err = b.SetResource(r)
		if err != nil {
			panic(err)
		}
	}
	return b
}