Skip to content
Merged
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
35 changes: 0 additions & 35 deletions .github/workflows/testing.yml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Tests

on:
push:
branches:
- '**'
pull_request:

permissions:
contents: read

jobs:
Linting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@2023.1.5

- name: Run Linter
run: make lint

Units:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Run Unit Tests
run: make test

Integrations:
runs-on: ubuntu-latest
needs: Units

env:
CLOUDSCALE_API_TOKEN: ${{ secrets.CLOUDSCALE_API_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Create Test Cluster
run: helpers/run-in-test-cluster

- name: Wait For CCM Startup
run: sleep 60

- name: Run Integration Tests
run: make integration

- name: Destroy Test Cluster
if: always()
run: helpers/cleanup
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.iml
cover.out
k8test
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apk add --no-cache git
WORKDIR /host
COPY . /host

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOCACHE=/var/cache/container \
go build -trimpath -ldflags "-s -w -X main.version=$VERSION" \
-o bin/cloudscale-cloud-controller-manager \
cmd/cloudscale-cloud-controller-manager/main.go
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
.PHONY: build lint test
.PHONY: build lint test integration coverage

build:
go build -trimpath -o bin/cloudscale-cloud-controller-manager \
cmd/cloudscale-cloud-controller-manager/main.go

lint:
golangci-lint run
golangci-lint run --timeout=10m
staticcheck ./...

test:
go test -race -coverpkg=./pkg/... ./pkg/...
go test -race -coverpkg=./pkg/cloudscale_ccm -coverprofile cover.out ./pkg/cloudscale_ccm -v

integration:
K8TEST_PATH=${PWD}/k8test go test -count=1 -tags=integration ./pkg/internal/integration -v

coverage: test
go tool cover -html=cover.out
7 changes: 4 additions & 3 deletions cmd/cloudscale-cloud-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
package main

import (
"github.com/cloudscale-ch/cloudscale-cloud-controller-manager/pkg/cloudscale"
"os"

"github.com/cloudscale-ch/cloudscale-cloud-controller-manager/pkg/cloudscale_ccm"
"k8s.io/apimachinery/pkg/util/wait"
cloudprovider "k8s.io/cloud-provider"
"k8s.io/cloud-provider/app"
Expand All @@ -13,15 +15,14 @@ import (
_ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugins
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration
"k8s.io/klog/v2"
"os"
)

func main() {
ccmOptions, err := options.NewCloudControllerManagerOptions()

// Always set --cloud-provider, as running this binary with another
// provider is nonsensical.
ccmOptions.KubeCloudShared.CloudProvider.Name = cloudscale.ProviderName
ccmOptions.KubeCloudShared.CloudProvider.Name = cloudscale_ccm.ProviderName

if err != nil {
klog.Fatalf("unable to initialize command options: %v", err)
Expand Down
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
module github.com/cloudscale-ch/cloudscale-cloud-controller-manager

go 1.20
go 1.21

require (
github.com/cloudscale-ch/cloudscale-go-sdk v1.11.0
golang.org/x/oauth2 v0.9.0
k8s.io/api v0.27.3 // indirect
k8s.io/api v0.27.3
k8s.io/apimachinery v0.27.3
k8s.io/cloud-provider v0.27.3
k8s.io/component-base v0.27.3
k8s.io/klog/v2 v2.100.1
)

require (
github.com/google/uuid v1.3.0
github.com/stretchr/testify v1.8.3
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
Expand Down Expand Up @@ -41,7 +46,6 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
Expand All @@ -56,6 +60,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
Expand Down
Loading