Fix style issues in retrieval/...

pull/1645/head
beorn7 9 years ago
parent b95c096a45
commit d43c0159aa

@ -18,6 +18,7 @@ import (
"github.com/prometheus/prometheus/retrieval/discovery/consul"
)
// NewConsul creates a new Consul based Discovery.
func NewConsul(cfg *config.ConsulSDConfig) (*consul.Discovery, error) {
return consul.NewDiscovery(cfg)
}

@ -253,10 +253,10 @@ func (kd *Discovery) updateNode(node *Node, eventType EventType) {
defer kd.nodesMu.Unlock()
updatedNodeName := node.ObjectMeta.Name
switch eventType {
case deleted:
case Deleted:
// Deleted - remove from nodes map.
delete(kd.nodes, updatedNodeName)
case added, modified:
case Added, Modified:
// Added/Modified - update the node in the nodes map.
kd.nodes[updatedNodeName] = node
}
@ -331,7 +331,7 @@ func (kd *Discovery) watchNodes(events chan interface{}, done <-chan struct{}, r
kd.nodes = map[string]*Node{}
for _, node := range nodes {
events <- &nodeEvent{added, node}
events <- &nodeEvent{Added, node}
}
req, err := http.NewRequest("GET", nodesURL, nil)
@ -391,12 +391,12 @@ func (kd *Discovery) startServiceWatch(events chan<- interface{}, done <-chan st
for oldNSName, oldNS := range existingServices {
if ns, ok := services[oldNSName]; !ok {
for _, service := range existingServices[oldNSName] {
events <- &serviceEvent{deleted, service}
events <- &serviceEvent{Deleted, service}
}
} else {
for oldServiceName, oldService := range oldNS {
if _, ok := ns[oldServiceName]; !ok {
events <- &serviceEvent{deleted, oldService}
events <- &serviceEvent{Deleted, oldService}
}
}
}
@ -407,7 +407,7 @@ func (kd *Discovery) startServiceWatch(events chan<- interface{}, done <-chan st
for _, ns := range services {
for _, service := range ns {
events <- &serviceEvent{added, service}
events <- &serviceEvent{Added, service}
}
}
@ -510,9 +510,9 @@ func (kd *Discovery) updateService(service *Service, eventType EventType) *confi
defer kd.servicesMu.Unlock()
switch eventType {
case deleted:
case Deleted:
return kd.deleteService(service)
case added, modified:
case Added, Modified:
return kd.addService(service)
}
return nil

@ -13,12 +13,14 @@
package kubernetes
// EventType can legally only have the values defined as constants below.
type EventType string
// Possible values for EventType.
const (
added EventType = "ADDED"
modified EventType = "MODIFIED"
deleted EventType = "DELETED"
Added EventType = "ADDED"
Modified EventType = "MODIFIED"
Deleted EventType = "DELETED"
)
type nodeEvent struct {
@ -200,6 +202,7 @@ type NodeStatus struct {
Addresses []NodeAddress `json:"addresses,omitempty" description:"list of addresses reachable to the node; see http://releases.k8s.io/HEAD/docs/admin/node.md#node-addresses" patchStrategy:"merge" patchMergeKey:"type"`
}
// NodeAddressType can legally only have the values defined as constants below.
type NodeAddressType string
// These are valid address types of node. NodeLegacyHostIP is used to transit
@ -211,6 +214,7 @@ const (
NodeInternalIP NodeAddressType = "InternalIP"
)
// NodeAddress defines the address of a node.
type NodeAddress struct {
Type NodeAddressType `json:"type" description:"node address type, one of Hostname, ExternalIP or InternalIP"`
Address string `json:"address" description:"the node address"`

Loading…
Cancel
Save