forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontroller.go
30 lines (22 loc) · 897 Bytes
/
controller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package test
import (
"fmt"
routeapi "github.com/openshift/origin/pkg/route/api"
"github.com/openshift/origin/pkg/route/controller/allocation"
)
type TestAllocationPlugin struct {
Name string
}
func (p *TestAllocationPlugin) Allocate(route *routeapi.Route) (*routeapi.RouterShard, error) {
return &routeapi.RouterShard{ShardName: "test", DNSSuffix: "openshift.test"}, nil
}
func (p *TestAllocationPlugin) GenerateHostname(route *routeapi.Route, shard *routeapi.RouterShard) string {
if len(route.ServiceName) > 0 && len(route.Namespace) > 0 {
return fmt.Sprintf("%s-%s.%s", route.ServiceName, route.Namespace, shard.DNSSuffix)
}
return "test-test-test.openshift.test"
}
func NewTestRouteAllocationController() *allocation.RouteAllocationController {
plugin := &TestAllocationPlugin{"test route allocation plugin"}
return &allocation.RouteAllocationController{Plugin: plugin}
}