57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package controller
|
|
|
|
import (
|
|
"github.com/zalando-incubator/postgres-operator/pkg/cluster"
|
|
"github.com/zalando-incubator/postgres-operator/pkg/spec"
|
|
"github.com/zalando-incubator/postgres-operator/pkg/util/config"
|
|
)
|
|
|
|
type controllerStatus struct {
|
|
ControllerConfig Config
|
|
OperatorConfig config.Config
|
|
LastSyncTime int64
|
|
Clusters int
|
|
}
|
|
|
|
type clusterStatus struct {
|
|
Team string
|
|
Cluster string
|
|
|
|
Config cluster.Config
|
|
Status spec.PostgresStatus
|
|
Resources cluster.KubeResources
|
|
Spec spec.PostgresSpec
|
|
Error error
|
|
}
|
|
|
|
func (c *Controller) ClusterStatus(team, cluster string) interface{} {
|
|
clusterName := spec.NamespacedName{
|
|
Namespace: c.opConfig.Namespace,
|
|
Name: team + "-" + cluster,
|
|
}
|
|
|
|
cl, ok := c.clusters[clusterName]
|
|
if !ok {
|
|
return struct{}{}
|
|
}
|
|
|
|
return clusterStatus{
|
|
Config: cl.Config,
|
|
Cluster: cl.Spec.ClusterName,
|
|
Team: cl.Spec.TeamID,
|
|
Status: cl.Status,
|
|
Resources: cl.KubeResources,
|
|
Spec: cl.Spec,
|
|
Error: cl.Error,
|
|
}
|
|
}
|
|
|
|
func (c *Controller) Status() interface{} {
|
|
return controllerStatus{
|
|
ControllerConfig: c.config,
|
|
OperatorConfig: *c.opConfig,
|
|
LastSyncTime: c.lastClusterSyncTime,
|
|
Clusters: len(c.clusters),
|
|
}
|
|
}
|