diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..7bd79fff --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +repos: + - repo: https://github.com/TekWizely/pre-commit-golang + rev: v1.0.0-beta.5 + hooks: + - id: go-fmt + - id: go-vet-mod + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-symlinks + - id: check-merge-conflict + - id: check-case-conflict + - id: detect-aws-credentials + args: + - --allow-missing-credentials + - id: detect-private-key + - id: forbid-new-submodules diff --git a/README.md b/README.md index f0503baf..c25d3cc2 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,16 @@ The following annotations on services of type `LoadBalancer` are supported: The following configuration flags are supported: -- `-cloudscale-token`, `CLOUDSCALE_TOKEN`, no default, required: cloudscale.ch API token with +- `-cloudscale-token`, `CLOUDSCALE_TOKEN`, no default, required: cloudscale.ch API token with write access - `-ip-limit`, `IP_LIMIT`, default `5`: maximum number of floating ips that are allowed to exist on the cloudscale.ch account; this is used as an additional guard in case this controller is out of control and would create an infinite amount of floating ips - `-controller-id`, `CONTROLLER_ID`, no default: if set, the controller will only process services with a `linkyard.ch/slb-controller-id` annotation set to this value -- `-leader-election-configmap`, `LEADER_ELECTION_CONFIGMAP`, no default: name of the `ConfigMap` +- `-leader-election-configmap`, `LEADER_ELECTION_CONFIGMAP`, no default: name of the `ConfigMap` to use for leader election -- `-leader-election-namespace` `LEADER_ELECTION_NAMESPACE`, no default: name of the namespace where +- `-leader-election-namespace` `LEADER_ELECTION_NAMESPACE`, no default: name of the namespace where the `ConfigMap` for leader election is located at - `-leader-election-node`, `LEADER_ELECTION_NODE`, no default: name of the pod - `-leader-election-ttl`, `LEADER_ELECTION_TTL`, default `10s`: TTL for leader election, e.g. `10s`; @@ -36,7 +36,7 @@ The following configuration flags are supported: `Panic`, `Fatal`, `Error`, `Warn`, `Info`, `Debug`, `Trace` - `-kubeconfig`, `KUBECONFIG`, no default, not required: path to a kubernetes kubconfig file; this is not required when running inside a kubernetes cluster -- `-fake-cloudscale-client`, `FAKE_CLOUDSCALE_CLIENT`: set to `true` to use a fake cloudscale.ch +- `-fake-cloudscale-client`, `FAKE_CLOUDSCALE_CLIENT`: set to `true` to use a fake cloudscale.ch API client -- `-chaos-chance`, `CHAOS_CHANCE`, default `0`: chance of a call to one of the fake components failing; +- `-chaos-chance`, `CHAOS_CHANCE`, default `0`: chance of a call to one of the fake components failing; range `[0.0,1,0)` diff --git a/cmd/cloudscale_slb_controller/main.go b/cmd/cloudscale_slb_controller/main.go index a027a56c..eabbd80d 100644 --- a/cmd/cloudscale_slb_controller/main.go +++ b/cmd/cloudscale_slb_controller/main.go @@ -29,7 +29,7 @@ Flags: -cloudscale-token cloudscale.ch API token [CLOUDSCALE_TOKEN] -ip-limit maximum number of floating ips that are allowed to exist on the - cloudscale.ch account (default: 5); used to make sure we don't go + cloudscale.ch account (default: 5); used to make sure we don't go bankrupt if this component runs amok [IP_LIMIT] -kubeconfig path to a kubernetes kubeconfig [KUBECONFIG] diff --git a/deploy/rbac.yaml b/deploy/rbac.yaml index e0ab2c52..2e465261 100644 --- a/deploy/rbac.yaml +++ b/deploy/rbac.yaml @@ -92,4 +92,4 @@ roleRef: name: cloudscale-slb-controller subjects: - kind: ServiceAccount - name: cloudscale-slb-controller \ No newline at end of file + name: cloudscale-slb-controller diff --git a/glide.yaml b/glide.yaml index 3ec04a8e..da279439 100644 --- a/glide.yaml +++ b/glide.yaml @@ -13,4 +13,4 @@ import: - package: github.com/evanphx/json-patch - package: github.com/imdario/mergo - package: github.com/spf13/pflag - - package: github.com/namsral/flag \ No newline at end of file + - package: github.com/namsral/flag diff --git a/internal/event_processor.go b/internal/event_processor.go index 4820f259..5d957bf2 100644 --- a/internal/event_processor.go +++ b/internal/event_processor.go @@ -144,9 +144,9 @@ func (processor *EventProcessor) ReAttach(namespace string, name string) (*v1.Se svc, err := processor.k8sClient.CoreV1().Services(namespace).Get(name, metav1.GetOptions{}) if err != nil { log.WithFields(log.Fields{ - "svc": getKeyFor(namespace, name), - "action": "ReAttach", - "error": err, + "svc": getKeyFor(namespace, name), + "action": "ReAttach", + "error": err, }).Error("unable to re-attach ip") processor.emitEvent( "Warning", @@ -165,10 +165,10 @@ func (processor *EventProcessor) VerifyIp(svc *v1.Service) error { ip, serverName, err := processor.verifyIp(svc) if err != nil { log.WithFields(log.Fields{ - "svc": getKey(svc), - "action": "VerifyIp", + "svc": getKey(svc), + "action": "VerifyIp", "server_name": serverName, - "error": err, + "error": err, }).Error("unable to verify ip") processor.emitEvent( "Warning",