Implement replicaLoadBalancer boolean flag. (#38)

The flag adds a replica service with the name cluster_name-repl and
a DNS name that defaults to {cluster}-repl.{team}.{hostedzone}.

The implementation converted Service field of the cluster into a map
with one or two elements and deals with the cases when the new flag
is changed on a running cluster
(the update and the sync should create or delete the replica service).
In order to pick up master and replica service and master endpoint
when listing cluster resources.

* Update the spec when updating the cluster.
This commit is contained in:
Oleksii Kliukin
2017-06-07 13:54:17 +02:00
committed by GitHub
parent 7b0ca31bfb
commit dc36c4ca12
26 changed files with 329 additions and 166 deletions
+10 -5
View File
@@ -9,7 +9,8 @@ import (
"github.com/Sirupsen/logrus"
)
type InfrastructureAccount struct {
// InfrastructureAccount defines an account of the team on some infrastructure (i.e AWS, Google) platform.
type infrastructureAccount struct {
ID string `json:"id"`
Name string `json:"name"`
Provider string `json:"provider"`
@@ -20,7 +21,8 @@ type InfrastructureAccount struct {
Disabled bool `json:"disabled"`
}
type Team struct {
// Team defines informaiton for a single team, including the list of members and infrastructure accounts.
type team struct {
Dn string `json:"dn"`
ID string `json:"id"`
TeamName string `json:"id_name"`
@@ -34,15 +36,17 @@ type Team struct {
DeliveryLead string `json:"delivery_lead"`
ParentTeamID string `json:"parent_team_id"`
InfrastructureAccounts []InfrastructureAccount `json:"infrastructure-accounts"`
InfrastructureAccounts []infrastructureAccount `json:"infrastructure-accounts"`
}
//
type API struct {
url string
httpClient *http.Client
logger *logrus.Entry
}
// NewTeamsAPI creates an object to query the team API.
func NewTeamsAPI(url string, log *logrus.Logger) *API {
t := API{
url: strings.TrimRight(url, "/"),
@@ -53,7 +57,8 @@ func NewTeamsAPI(url string, log *logrus.Logger) *API {
return &t
}
func (t *API) TeamInfo(teamID, token string) (*Team, error) {
// TeamInfo returns information about a given team using its ID and a token to authenticate to the API service.
func (t *API) TeamInfo(teamID, token string) (*team, error) {
url := fmt.Sprintf("%s/teams/%s", t.url, teamID)
t.logger.Debugf("Request url: %s", url)
req, err := http.NewRequest("GET", url, nil)
@@ -81,7 +86,7 @@ func (t *API) TeamInfo(teamID, token string) (*Team, error) {
return nil, fmt.Errorf("team API query failed with status code %d", resp.StatusCode)
}
teamInfo := &Team{}
teamInfo := &team{}
d := json.NewDecoder(resp.Body)
err = d.Decode(teamInfo)
if err != nil {
+3 -3
View File
@@ -17,7 +17,7 @@ var (
var teamsAPItc = []struct {
in string
inCode int
out *Team
out *team
err error
}{
{`{
@@ -66,7 +66,7 @@ var teamsAPItc = []struct {
"parent_team_id": "111221"
}`,
200,
&Team{
&team{
Dn: "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
ID: "acid",
TeamName: "ACID",
@@ -79,7 +79,7 @@ var teamsAPItc = []struct {
CostCenter: "00099999",
DeliveryLead: "member4",
ParentTeamID: "111221",
InfrastructureAccounts: []InfrastructureAccount{
InfrastructureAccounts: []infrastructureAccount{
{
ID: "1234512345",
Name: "acid",