-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
657 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = tab | ||
tab_width = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
max_line_length = 120 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.go] | ||
indent_style = tab | ||
|
||
[Makefile] | ||
indent_style = tab | ||
tab_width = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: base-pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
|
||
build: | ||
name: Build and test with coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.15 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.15 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Get dependencies | ||
run: | | ||
go get -v -t -d ./... | ||
- name: Build | ||
run: | | ||
make build | ||
- name: Test | ||
run: | | ||
make test | ||
- name: Coverage | ||
run: | | ||
make coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
MAKEFLAGS += --no-print-directory | ||
COMPONENTS = community-controller system-controller edge-scheduler | ||
|
||
ifeq (,$(shell go env GOBIN)) | ||
GOBIN=$(shell go env GOPATH)/bin | ||
else | ||
GOBIN=$(shell go env GOBIN) | ||
endif | ||
|
||
CRD_OPTIONS ?= "crd:trivialVersions=true" | ||
|
||
.PHONY: all build coverage clean manifests test | ||
|
||
all: build coverage clean manifests test | ||
|
||
build: | ||
$(call action, build) | ||
|
||
coverage: | ||
$(call action, coverage) | ||
|
||
clean: | ||
$(call action, clean) | ||
|
||
test: | ||
$(call action, test) | ||
|
||
# Generate manifests e.g. CRD, RBAC etc. | ||
manifests: controller-gen | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=systemautoscaler-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
||
controller-gen: | ||
ifeq (, $(shell which controller-gen)) | ||
@{ \ | ||
set -e ;\ | ||
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$CONTROLLER_GEN_TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\ | ||
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ | ||
} | ||
CONTROLLER_GEN=$(GOBIN)/controller-gen | ||
else | ||
CONTROLLER_GEN=$(shell which controller-gen) | ||
endif | ||
|
||
|
||
define action | ||
@for c in $(COMPONENTS); \ | ||
do \ | ||
$(MAKE) $(1) -C pkg/$$c; \ | ||
done | ||
endef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module github.com/lterrac/edge-autoscaler | ||
|
||
go 1.16 | ||
|
||
require ( | ||
k8s.io/code-generator v0.21.2 | ||
k8s.io/kube-openapi v0.0.0-20210527164424-3c818078ee3d | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package tools | ||
|
||
import ( | ||
_ "k8s.io/code-generator" // This package imports things required by build scripts, to force `go mod` to see them as dependencies | ||
_ "k8s.io/kube-openapi/cmd/openapi-gen" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2017 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. | ||
CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} | ||
|
||
# generate the code with: | ||
# --output-base because this script should also be able to run inside the vendor dir of | ||
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir | ||
# instead of the $GOPATH directly. For normal projects this can be dropped. | ||
bash "${CODEGEN_PKG}"/generate-groups.sh "all" \ | ||
github.com/lterrac/edge-autoscaler/pkg/generated github.com/lterrac/edge-autoscaler/pkg/apis \ | ||
systemautoscaler:v1beta1 \ | ||
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../../.." \ | ||
--go-header-file "${SCRIPT_ROOT}"/hack/boilerplate.go.txt | ||
|
||
# To use your own boilerplate text append: | ||
# --go-header-file "${SCRIPT_ROOT}"/hack/custom-boilerplate.go.txt | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2017 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. | ||
|
||
DIFFROOT="${SCRIPT_ROOT}/pkg" | ||
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/pkg" | ||
_tmp="${SCRIPT_ROOT}/_tmp" | ||
|
||
cleanup() { | ||
rm -rf "${_tmp}" | ||
} | ||
trap "cleanup" EXIT SIGINT | ||
|
||
cleanup | ||
|
||
mkdir -p "${TMP_DIFFROOT}" | ||
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" | ||
|
||
"${SCRIPT_ROOT}/hack/update-codegen.sh" | ||
echo "diffing ${DIFFROOT} against freshly generated codegen" | ||
ret=0 | ||
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? | ||
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" | ||
if [[ $ret -eq 0 ]] | ||
then | ||
echo "${DIFFROOT} up to date." | ||
else | ||
echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
**/testdata | ||
.dockerignore | ||
Dockerfile | ||
README.md | ||
*.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM gcr.io/distroless/static:nonroot | ||
|
||
LABEL name="Community Controller" | ||
|
||
COPY community-controller /usr/local/bin/ | ||
|
||
CMD ["community-controller"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
BUILD_SETTINGS = CGO_ENABLED=0 GOOS=linux GOARCH=amd64 | ||
IMAGE = community-controller | ||
IMAGE_VERSION = $(shell git tag --points-at HEAD | sed '/$(IMAGE)\/.*/!s/.*//' | sed 's/\//:/') | ||
REPO = systemautoscaler | ||
|
||
|
||
.PHONY: all build coverage clean e2e fmt release test vet | ||
|
||
all: build test coverage clean | ||
|
||
build: fmt vet test | ||
$(BUILD_SETTINGS) go build -trimpath -o "$(IMAGE)" ./main.go | ||
|
||
fmt: | ||
@go fmt ./... | ||
|
||
test: | ||
@go test -race $(shell go list ./... | grep -v e2e) --coverprofile=coverage.out | ||
|
||
e2e: | ||
@go test -race $(shell go list ./... | grep e2e) | ||
|
||
coverage: test | ||
@go tool cover -func=coverage.out | ||
|
||
release: | ||
@if [ -n "$(IMAGE_VERSION)" ]; then \ | ||
echo "Building $(IMAGE_VERSION)" ;\ | ||
docker build -t $(REPO)/$(IMAGE_VERSION) . ;\ | ||
docker push $(REPO)/$(IMAGE_VERSION) ;\ | ||
else \ | ||
echo "$(IMAGE) unchanged: no version tag on HEAD commit" ;\ | ||
fi | ||
|
||
vet: | ||
@go vet ./... | ||
|
||
clean: | ||
@rm -rf ./$(IMAGE) | ||
@go clean -cache | ||
@rm -rf *.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Community Controller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
func main() { | ||
println("Hello World!") | ||
} |
8 changes: 8 additions & 0 deletions
8
pkg/community-controller/pkg/controller/community-controller.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package controller | ||
|
||
type CommunityController struct { | ||
} | ||
|
||
func NewController() *CommunityController { | ||
return &CommunityController{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
**/testdata | ||
.dockerignore | ||
Dockerfile | ||
README.md | ||
*.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM gcr.io/distroless/static:nonroot | ||
|
||
LABEL name="Edge Scheduler" | ||
|
||
COPY edge-scheduler /usr/local/bin/ | ||
|
||
CMD ["edge-scheduler"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
BUILD_SETTINGS = CGO_ENABLED=0 GOOS=linux GOARCH=amd64 | ||
IMAGE = edge-scheduler | ||
IMAGE_VERSION = $(shell git tag --points-at HEAD | sed '/$(IMAGE)\/.*/!s/.*//' | sed 's/\//:/') | ||
REPO = systemautoscaler | ||
|
||
|
||
.PHONY: all build coverage clean e2e fmt release test vet | ||
|
||
all: build test coverage clean | ||
|
||
build: fmt vet test | ||
$(BUILD_SETTINGS) go build -trimpath -o "$(IMAGE)" ./main.go | ||
|
||
fmt: | ||
@go fmt ./... | ||
|
||
test: | ||
@go test -race $(shell go list ./... | grep -v e2e) --coverprofile=coverage.out | ||
|
||
e2e: | ||
@go test -race $(shell go list ./... | grep e2e) | ||
|
||
coverage: test | ||
@go tool cover -func=coverage.out | ||
|
||
release: | ||
@if [ -n "$(IMAGE_VERSION)" ]; then \ | ||
echo "Building $(IMAGE_VERSION)" ;\ | ||
docker build -t $(REPO)/$(IMAGE_VERSION) . ;\ | ||
docker push $(REPO)/$(IMAGE_VERSION) ;\ | ||
else \ | ||
echo "$(IMAGE) unchanged: no version tag on HEAD commit" ;\ | ||
fi | ||
|
||
vet: | ||
@go vet ./... | ||
|
||
clean: | ||
@rm -rf ./$(IMAGE) | ||
@go clean -cache | ||
@rm -rf *.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Edge Scheduler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
func main() { | ||
println("Hello World!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package scheduler | ||
|
||
type Scheduler struct { | ||
} | ||
|
||
func NewScheduler() *Scheduler { | ||
return &Scheduler{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
**/testdata | ||
.dockerignore | ||
Dockerfile | ||
README.md | ||
*.out |
Oops, something went wrong.