Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM keppel.eu-de-1.cloud.sap/ccloud-dockerhub-mirror/library/golang:1.14-alpine3.12 as builder
FROM keppel.eu-de-1.cloud.sap/ccloud-dockerhub-mirror/library/golang:1.20-alpine3.18 as builder
WORKDIR /go/src/github.com/sapcc/atlas
RUN apk add --no-cache make
COPY . .
ARG VERSION
RUN make all

FROM keppel.eu-de-1.cloud.sap/ccloud-dockerhub-mirror/library/alpine:3.9
FROM keppel.eu-de-1.cloud.sap/ccloud-dockerhub-mirror/library/alpine:3.18
LABEL maintainer="Stefan Hipfel <stefan.hipfel@sap.com>"
LABEL source_repository="https://github.com/sapcc/atlas"

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ GOOS ?= $(shell go env | grep GOOS | cut -d'"' -f2)
BINARY := atlas

LDFLAGS := -X github.com/sapcc/atlas/pkg/atlas.VERSION=$(VERSION)
GOFLAGS := -ldflags "$(LDFLAGS)"
GOFLAGS := -mod vendor -ldflags "-s -w $(LDFLAGS)"

SRCDIRS := cmd pkg internal
PACKAGES := $(shell find $(SRCDIRS) -type d)
Expand All @@ -16,9 +16,9 @@ GOFILES := $(wildcard $(GOFILES))
all: bin/$(GOOS)/$(BINARY)

bin/%/$(BINARY): $(GOFILES) Makefile
GOOS=$* GOARCH=amd64 go build $(GOFLAGS) -v -i -o bin/$*/$(BINARY) ./cmd/atlas
GOOS=$* GOARCH=amd64 go build $(GOFLAGS) -o bin/$*/$(BINARY) ./cmd/atlas

build:
build:
docker build -t $(IMAGE):$(VERSION) .

push: build
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ Either by building via docker using `docker build .` and then `docker run CONTAI
environment with `go run cmd/atlas/main.go --help`.

Prometheus server configuration:
A sample prometheus job to read those configmap targets is shown [here](https://github.com/sapcc/ipmi_sd/blob/master/prometheus.yml)
A sample prometheus job to read those configmap targets is shown [here](https://github.com/sapcc/ipmi_sd/blob/master/prometheus.yml)
4 changes: 2 additions & 2 deletions etc/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ discoveries:
netbox_api_token: netbox_api_token
dcim:
devices:
- custom_labels:
- custom_labels:
job: "snmp"
target: 1
role: "aci-leaf"
manufacturer: "cisco"
region: "eu-west"
status: "1"
- custom_labels:
- custom_labels:
job: "snmp2"
role: "aci-spine"
target: 1
Expand Down
2 changes: 1 addition & 1 deletion internal/discovery/ironic_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func init() {
Register(ironicDiscovery, NewIronicDiscovery)
}

//NewIronicDiscovery creates a new Ironic Discovery
// NewIronicDiscovery creates a new Ironic Discovery
func NewIronicDiscovery(disc interface{}, ctx context.Context, opts config.Options, l log.Logger) (d Discovery, err error) {
var cfg ironicConfig
if err := UnmarshalHandler(disc, &cfg, nil); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/discovery/netbox_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func init() {
Register(netboxDiscovery, NewNetboxDiscovery)
}

//NewNetboxDiscovery creates
// NewNetboxDiscovery creates
func NewNetboxDiscovery(disc interface{}, ctx context.Context, opts config.Options, l log.Logger) (d Discovery, err error) {
var cfg netboxConfig
configValues := configValues{Region: opts.Region}
Expand Down
4 changes: 2 additions & 2 deletions pkg/clients/ironic.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ func (c IronicClient) GetNodes() ([]IronicNode, error) {
////////////////////////////////////////////////////////////////////////////////
// OpenStack is being inconsistent with itself again

//For fields that are sometimes missing, sometimes an integer, sometimes a string.
// For fields that are sometimes missing, sometimes an integer, sometimes a string.
type veryFlexibleUint64 uint64

//UnmarshalJSON implements the json.Unmarshaler interface.
// UnmarshalJSON implements the json.Unmarshaler interface.
func (value *veryFlexibleUint64) UnmarshalJSON(buf []byte) error {
if string(buf) == "null" {
*value = 0
Expand Down
10 changes: 5 additions & 5 deletions pkg/netbox/netbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (nb *Netbox) Servers(rackID string) ([]models.DeviceWithConfigContext, erro

}

//DevicesByRegion retrieves devices by region, manufacturer and status
// DevicesByRegion retrieves devices by region, manufacturer and status
func (nb *Netbox) DevicesByRegion(query, manufacturer, region, status string) (res []models.DeviceWithConfigContext, err error) {
res = make([]models.DeviceWithConfigContext, 0)
params := dcim.NewDcimDevicesListParams()
Expand Down Expand Up @@ -183,7 +183,7 @@ func (nb *Netbox) DevicesByRegion(query, manufacturer, region, status string) (r
return res, err
}

//DevicesByRegion retrieves devices by region, manufacturer and status
// DevicesByRegion retrieves devices by region, manufacturer and status
func (nb *Netbox) DevicesByParams(params dcim.DcimDevicesListParams) (res []models.DeviceWithConfigContext, err error) {
res = make([]models.DeviceWithConfigContext, 0)
limit := int64(100)
Expand Down Expand Up @@ -211,7 +211,7 @@ func (nb *Netbox) DevicesByParams(params dcim.DcimDevicesListParams) (res []mode
return res, err
}

//DevicesByRegion retrieves devices by region, manufacturer and status
// DevicesByRegion retrieves devices by region, manufacturer and status
func (nb *Netbox) DeviceByParams(params dcim.DcimDevicesListParams) (res models.DeviceWithConfigContext, err error) {
limit := int64(1)
params.WithLimit(&limit)
Expand All @@ -229,7 +229,7 @@ func (nb *Netbox) DeviceByParams(params dcim.DcimDevicesListParams) (res models.
return res, err
}

//VMsByTag retrieves devices by region, manufacturer and status
// VMsByTag retrieves devices by region, manufacturer and status
func (nb *Netbox) VMsByParams(params virtualization.VirtualizationVirtualMachinesListParams) (res []models.VirtualMachineWithConfigContext, err error) {
res = make([]models.VirtualMachineWithConfigContext, 0)
params.WithTimeout(30 * time.Second)
Expand All @@ -256,7 +256,7 @@ func (nb *Netbox) VMsByParams(params virtualization.VirtualizationVirtualMachine
return res, err
}

//VMsByTag retrieves devices by region, manufacturer and status
// VMsByTag retrieves devices by region, manufacturer and status
func (nb *Netbox) VMsByTag(query, status, tag string) (res []models.VirtualMachineWithConfigContext, err error) {
res = make([]models.VirtualMachineWithConfigContext, 0)
params := virtualization.NewVirtualizationVirtualMachinesListParams()
Expand Down
20 changes: 10 additions & 10 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ var DefaultBackoff = wait.Backoff{
// write. Callers should preserve previous executions if they wish to retry changes. It performs an
// exponential backoff.
//
// var pod *api.Pod
// err := RetryOnConflict(DefaultBackoff, func() (err error) {
// pod, err = c.Pods("mynamespace").UpdateStatus(podStatus)
// return
// })
// if err != nil {
// // may be conflict if max retries were hit
// return err
// }
// ...
// var pod *api.Pod
// err := RetryOnConflict(DefaultBackoff, func() (err error) {
// pod, err = c.Pods("mynamespace").UpdateStatus(podStatus)
// return
// })
// if err != nil {
// // may be conflict if max retries were hit
// return err
// }
// ...
//
// TODO: Make Backoff an interface?
func RetryOnConflict(backoff wait.Backoff, fn func() error) error {
Expand Down