Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain project dependencies and images #141

Merged
merged 4 commits into from
Mar 10, 2021
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .ci/test
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 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
set -e

# For the test step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.
Expand Down
28 changes: 24 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
**How to categorize this PR?**
<!--
Please select area, kind, and priority for this pull request. This helps the community categorizing it.
Replace below TODOs or exchange the existing identifiers with those that fit best in your opinion.
If multiple identifiers make sense you can also state the commands multiple times, e.g.
/area control-plane
/area auto-scaling
...

"/area" identifiers: audit-logging|auto-scaling|backup|certification|control-plane-migration|control-plane|cost|delivery|dev-productivity|disaster-recovery|documentation|high-availability|logging|metering|monitoring|networking|open-source|ops-productivity|os|performance|quality|robustness|scalability|security|storage|testing|usability|user-management
"/kind" identifiers: api-change|bug|cleanup|discussion|enhancement|epic|impediment|poc|post-mortem|question|regression|task|technical-debt|test
"/priority" identifiers: normal|critical|blocker

For Gardener Enhancement Proposals (GEPs), please check the following [documentation](https://github.com/gardener/gardener/tree/master/docs/proposals/README.md) before submitting this pull request.
-->
/area TODO
/kind TODO
/priority normal

**What this PR does / why we need it**:

**Which issue(s) this PR fixes**:
Expand All @@ -6,15 +25,16 @@ Fixes #
**Special notes for your reviewer**:

**Release note**:
<!-- Write your release note:
<!--
Write your release note:
1. Enter your release note in the below block.
2. If no release note is required, just write "NONE" within the block.

Format of block header: <category> <target_group>
Possible values:
- category: improvement|noteworthy|action
- target_group: user|operator|developer
- category: breaking|feature|bugfix|doc|other
- target_group: user|operator|developer|dependency
-->
```improvement operator
```other operator

```
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ config.vmdk
.virtualgo
.fuse_hidden*

.cache_ggshield
.gitguardian.yaml

7 changes: 7 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
run:
concurrency: 4
deadline: 10m

linters:
disable:
- unused
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM eu.gcr.io/gardener-project/3rd/library-1.docker.io/library/golang:1.13.9 as builder
FROM golang:1.15.8 as builder
WORKDIR /go/src/github.com/gardener/etcd-druid
COPY . .

Expand All @@ -12,8 +12,9 @@ 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 eu.gcr.io/gardener-project/3rd/alpine:3.10.3 AS druid
RUN apk add --update bash curl
FROM alpine:3.12.3 AS druid
RUN apk add --update bash \
&& apk del curl
WORKDIR /
COPY --from=builder /go/src/github.com/gardener/etcd-druid/bin/linux-amd64/etcd-druid bin/.
COPY charts charts
Expand Down
44 changes: 26 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,67 +29,75 @@ CRD_OPTIONS ?= "crd:trivialVersions=true"
revendor:
@env GO111MODULE=on go mod vendor
@env GO111MODULE=on go mod tidy
@chmod +x $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/*
@chmod +x $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/.ci/*
@$(REPO_ROOT)/hack/update-github-templates.sh

all: druid

# Run tests
test: fmt vet manifests
.PHONY: test
test: fmt check manifests
.ci/test

# Build manager binary
druid: fmt vet
.PHONY: druid
druid: fmt check
@env GO111MODULE=on go build -o bin/druid main.go

# Run against the configured Kubernetes cluster in ~/.kube/config
run: fmt vet
.PHONY: run
run: fmt check
go run ./main.go

# Install CRDs into a cluster
.PHONY: install
install: manifests
kubectl apply -f config/crd/bases

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
.PHONY: deploy
deploy: manifests
kubectl apply -f config/crd/bases
kustomize build config/default | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./api/...;./controllers/..." output:crd:artifacts:config=config/crd/bases
.PHONY: manifests
manifests: install-requirements
@controller-gen $(CRD_OPTIONS) rbac:roleName=manager-role paths="./api/...;./controllers/..." output:crd:artifacts:config=config/crd/bases

# Run go fmt against code
.PHONY: fmt
fmt:
@env GO111MODULE=on go fmt ./...

# Run go vet against code
vet:
PACKAGES="$(shell GO111MODULE=on go list -mod=vendor -e ./... | grep -vE '/api|/api/v1alpha1')"
@env GO111MODULE=on go vet $(PACKAGES)
# Check packages
.PHONY: check
check:
@$(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/check.sh --golangci-lint-config=./.golangci.yaml ./api/... ./pkg/... ./controllers/...

# Generate code
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./api/...
.PHONY: generate
generate: install-requirements
@controller-gen object:headerFile=./hack/boilerplate.go.txt paths=./api/...

# Build the docker image
.PHONY: docker-build
docker-build:
docker build . -t ${IMG} --rm
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml

# Push the docker image
.PHONY: docker-push
docker-push:
docker push ${IMG}

# find or download controller-gen
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
go get sigs.k8s.io/controller-tools/cmd/[email protected]
CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
.PHONY: install-requirements
install-requirements:
@go install -mod=vendor sigs.k8s.io/controller-tools/cmd/controller-gen

.PHONY: update-dependencies
update-dependencies:
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/etcd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type BackupSpec struct {
DeltaSnapshotMemoryLimit *resource.Quantity `json:"deltaSnapshotMemoryLimit,omitempty"`
}

// EtcdConfig defines parametes associated etcd deployed
// EtcdConfig defines parameters associated etcd deployed
type EtcdConfig struct {
// Quota defines the etcd DB quota.
// +optional
Expand Down
13 changes: 8 additions & 5 deletions api/v1alpha1/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,30 @@ import (
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.

var cfg *rest.Config
var k8sClient client.Client
var testEnv *envtest.Environment
var (
cfg *rest.Config
k8sClient client.Client
testEnv *envtest.Environment
)

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"v1 Suite",
[]Reporter{envtest.NewlineReporter{}})
[]Reporter{printer.NewlineReporter{}})
}

var _ = BeforeSuite(func(done Done) {
logf.SetLogger(zap.LoggerTo(GinkgoWriter, true))
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

By("bootstrapping test environment")
testEnv = &envtest.Environment{
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading