-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from georgekuruvillak/adopt_etcd_resources
Adopt etcd resources
- Loading branch information
Showing
283 changed files
with
62,893 additions
and
37,508 deletions.
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,78 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. | ||
# | ||
# 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 -ex | ||
|
||
# For the build step concourse will set the following environment variables: | ||
# SOURCE_PATH - path to component repository root directory. | ||
# BINARY_PATH - path to an existing (empty) directory to place build results into. | ||
if [[ -z "${SOURCE_PATH}" ]]; then | ||
export SOURCE_PATH="$(readlink -f $(dirname ${0})/..)" | ||
else | ||
export SOURCE_PATH="$(readlink -f "${SOURCE_PATH}")" | ||
fi | ||
|
||
if [[ -z "${BINARY_PATH}" ]]; then | ||
export BINARY_PATH="${SOURCE_PATH}/bin" | ||
else | ||
export BINARY_PATH="$(readlink -f "${BINARY_PATH}")/bin" | ||
fi | ||
|
||
VCS="github.com" | ||
ORGANIZATION="gardener" | ||
PROJECT="etcd-druid" | ||
REPOSITORY=${VCS}/${ORGANIZATION}/${PROJECT} | ||
|
||
# The `go <cmd>` commands requires to see the target repository to be part of a | ||
# Go workspace. Thus, if we are not yet in a Go workspace, let's create one | ||
# temporarily by using symbolic links. | ||
if [[ "${SOURCE_PATH}" != *"src/${REPOSITORY}" ]]; then | ||
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/${REPOSITORY}" | ||
if [[ -d "${SOURCE_PATH}/tmp" ]]; then | ||
rm -rf "${SOURCE_PATH}/tmp" | ||
fi | ||
mkdir -p "${SOURCE_PATH}/tmp/src/${VCS}/${ORGANIZATION}" | ||
ln -s "${SOURCE_PATH}" "${SOURCE_SYMLINK_PATH}" | ||
cd "${SOURCE_SYMLINK_PATH}" | ||
|
||
export GOPATH="${SOURCE_PATH}/tmp" | ||
export GOBIN="${SOURCE_PATH}/tmp/bin" | ||
export PATH="${GOBIN}:${PATH}" | ||
fi | ||
|
||
############################################################################### | ||
|
||
VERSION_FILE="$(readlink -f "${SOURCE_PATH}/VERSION")" | ||
VERSION="$(cat "${VERSION_FILE}")" | ||
GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound") | ||
|
||
# If no LOCAL_BUILD environment variable is set, we configure the `go build` command | ||
# to build for linux OS, amd64 architectures and without CGO enablement. | ||
if [[ -z "$LOCAL_BUILD" ]]; then | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build \ | ||
-mod vendor \ | ||
-a \ | ||
-v \ | ||
-o ${BINARY_PATH}/linux-amd64/etcd-druid \ | ||
main.go | ||
|
||
# If the LOCAL_BUILD environment variable is set, we simply run `go build`. | ||
else | ||
GO111MODULE=on go build \ | ||
-mod vendor \ | ||
-v \ | ||
-o ${BINARY_PATH}/etcd-druid \ | ||
main.go | ||
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,64 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. | ||
# | ||
# 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 -e | ||
|
||
# For the check step concourse will set the following environment variables: | ||
# SOURCE_PATH - path to component repository root directory. | ||
|
||
if [[ -z "${SOURCE_PATH}" ]]; then | ||
export SOURCE_PATH="$(readlink -f "$(dirname ${0})/..")" | ||
else | ||
export SOURCE_PATH="$(readlink -f ${SOURCE_PATH})" | ||
fi | ||
VCS="github.com" | ||
ORGANIZATION="gardener" | ||
PROJECT="etcd-druid" | ||
REPOSITORY=${VCS}/${ORGANIZATION}/${PROJECT} | ||
|
||
# The `go <cmd>` commands requires to see the target repository to be part of a | ||
# Go workspace. Thus, if we are not yet in a Go workspace, let's create one | ||
# temporarily by using symbolic links. | ||
if [[ "${SOURCE_PATH}" != *"src/${REPOSITORY}" ]]; then | ||
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/${REPOSITORY}" | ||
if [[ -d "${SOURCE_PATH}/tmp" ]]; then | ||
rm -rf "${SOURCE_PATH}/tmp" | ||
fi | ||
mkdir -p "${SOURCE_PATH}/tmp/src/${VCS}/${ORGANIZATION}" | ||
ln -s "${SOURCE_PATH}" "${SOURCE_SYMLINK_PATH}" | ||
cd "${SOURCE_SYMLINK_PATH}" | ||
|
||
export GOPATH="${SOURCE_PATH}/tmp" | ||
export GOBIN="${SOURCE_PATH}/tmp/bin" | ||
export PATH="${GOBIN}:${PATH}" | ||
fi | ||
|
||
export GO111MODULE=on | ||
|
||
# Install Golint (linting tool). | ||
go get -u golang.org/x/lint/golint | ||
|
||
############################################################################### | ||
|
||
PACKAGES="$(go list -mod=vendor -e ./... | grep -vE '/api|/api/v1alpha1/|/tmp/|/vendor/')" | ||
LINT_FOLDERS="$(echo ${PACKAGES} | sed "s|github.com/gardener/etcd-druid|.|g")" | ||
|
||
# Execute static code checks. | ||
go vet ${PACKAGES} | ||
|
||
# Execute automatic code formatting directive. | ||
go fmt ${PACKAGES} | ||
|
||
# Execute lint checks. | ||
golint -set_exit_status ${LINT_FOLDERS} |
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,43 @@ | ||
etcd-druid: | ||
template: 'default' | ||
base_definition: | ||
repo: ~ | ||
traits: | ||
version: | ||
preprocess: | ||
'inject-commit-hash' | ||
inject_effective_version: true | ||
publish: | ||
dockerimages: | ||
etcd-druid: | ||
registry: 'gcr-readwrite' | ||
image: 'eu.gcr.io/gardener-project/gardener/etcd-druid' | ||
dockerfile: 'Dockerfile' | ||
inputs: | ||
repos: | ||
source: ~ | ||
steps: | ||
build: ~ | ||
steps: | ||
check: | ||
image: 'golang:1.12.0' | ||
test: | ||
image: 'golang:1.12.0' | ||
build: | ||
image: 'golang:1.12.0' | ||
output_dir: 'binary' | ||
|
||
jobs: | ||
head-update: | ||
traits: | ||
draft_release: ~ | ||
pull-request: | ||
traits: | ||
pull-request: ~ | ||
release: | ||
traits: | ||
version: | ||
preprocess: 'finalize' | ||
release: | ||
nextversion: 'bump_minor' | ||
component_descriptor: ~ |
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,76 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. | ||
# | ||
# 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 -e | ||
|
||
# For the test step concourse will set the following environment variables: | ||
# SOURCE_PATH - path to component repository root directory. | ||
if [[ -z "${SOURCE_PATH}" ]]; then | ||
export SOURCE_PATH="$(readlink -f "$(dirname ${0})/..")" | ||
else | ||
export SOURCE_PATH="$(readlink -f "${SOURCE_PATH}")" | ||
fi | ||
|
||
VCS="github.com" | ||
ORGANIZATION="gardener" | ||
PROJECT="etcd-druid" | ||
REPOSITORY=${VCS}/${ORGANIZATION}/${PROJECT} | ||
|
||
# The `go <cmd>` commands requires to see the target repository to be part of a | ||
# Go workspace. Thus, if we are not yet in a Go workspace, let's create one | ||
# temporarily by using symbolic links. | ||
if [[ "${SOURCE_PATH}" != *"src/${REPOSITORY}" ]]; then | ||
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/${REPOSITORY}" | ||
if [[ -d "${SOURCE_PATH}/tmp" ]]; then | ||
rm -rf "${SOURCE_PATH}/tmp" | ||
fi | ||
mkdir -p "${SOURCE_PATH}/tmp/src/${VCS}/${ORGANIZATION}" | ||
ln -s "${SOURCE_PATH}" "${SOURCE_SYMLINK_PATH}" | ||
cd "${SOURCE_SYMLINK_PATH}" | ||
|
||
export GOPATH="${SOURCE_PATH}/tmp" | ||
export GOBIN="${SOURCE_PATH}/tmp/bin" | ||
export PATH="${GOBIN}:${PATH}" | ||
fi | ||
|
||
export GO111MODULE=on | ||
|
||
# Install Ginkgo (test framework) to be able to execute the tests. | ||
go get -u github.com/onsi/ginkgo/ginkgo | ||
|
||
############################################################################### | ||
|
||
function test_with_coverage() { | ||
echo "[INFO] Test coverage is enabled." | ||
local output_dir=test/output | ||
local coverprofile_file=coverprofile.out | ||
mkdir -p test/output | ||
ginkgo $GINKGO_COMMON_FLAGS --coverprofile ${coverprofile_file} -covermode=set -outputdir ${output_dir} ${TEST_PACKAGES} | ||
sed -i '/mode: set/d' ${output_dir}/${coverprofile_file} | ||
{( echo "mode: set"; cat ${output_dir}/${coverprofile_file} )} > ${output_dir}/${coverprofile_file}.temp | ||
mv ${output_dir}/${coverprofile_file}.temp ${output_dir}/${coverprofile_file} | ||
go tool cover -func ${output_dir}/${coverprofile_file} | ||
} | ||
|
||
################################################################################ | ||
|
||
TEST_PACKAGES="api controllers" | ||
GINKGO_COMMON_FLAGS="-r -timeout=1h0m0s --randomizeAllSpecs --randomizeSuites --failOnPending --progress" | ||
if [ -z $COVER ] || [ "$COVER" = false ] ; then | ||
echo "[INFO] Test coverage is disabled." | ||
ginkgo -race -trace $GINKGO_COMMON_FLAGS ${TEST_PACKAGES} | ||
else | ||
test_with_coverage | ||
fi | ||
echo "Finished executing unit tests." |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
/dev | ||
|
||
*.coverprofile | ||
/cover.out | ||
*.html | ||
.vscode | ||
.idea | ||
|
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 |
---|---|---|
@@ -1,25 +1,20 @@ | ||
# Build the manager binary | ||
FROM golang:1.12.5 as builder | ||
WORKDIR /go/src/github.com/gardener/etcd-druid | ||
COPY . . | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY main.go main.go | ||
COPY api/ api/ | ||
COPY controllers/ controllers/ | ||
# # cache deps before building and copying source so that we don't need to re-download as much | ||
# # and so that source changes don't invalidate our downloaded layer | ||
#RUN go mod download | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go | ||
RUN .ci/build | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:latest | ||
FROM alpine:3.10.3 AS druid | ||
RUN apk add --update bash curl | ||
WORKDIR / | ||
COPY --from=builder /workspace/manager . | ||
ENTRYPOINT ["/manager"] | ||
COPY --from=builder /go/src/github.com/gardener/etcd-druid/bin/linux-amd64/etcd-druid bin/. | ||
COPY charts charts | ||
ENTRYPOINT ["/bin/etcd-druid"] |
Oops, something went wrong.