mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-22 09:13:04 +02:00
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:
+10
-5
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user