Skip to content

Commit

Permalink
Merge pull request #1 from wayfair-incubator/add_core_files
Browse files Browse the repository at this point in the history
Adding the initial core project files
  • Loading branch information
amelbakry authored May 6, 2022
2 parents 66569fe + 3fd51f1 commit 1f07a32
Show file tree
Hide file tree
Showing 48 changed files with 2,482 additions and 133 deletions.
82 changes: 2 additions & 80 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,86 +5,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.7] - 2022-04-04

- Update lint workflow trigger behavior

## [0.3.6] - 2022-03-22

- Bumps actions/checkout from 2 to 3
- Adds new template badges to README

## [0.3.5] - 2021-10-21

### Added

- Add step to update contact information in Code of Conduct

## [0.3.4] - 2021-10-19

### Added

- Dependabot configuration

## [0.3.3] - 2021-10-07

### Added

- Markdown linting

## [0.3.2] - 2021-08-24

### Added

- Version badge in README links to this changelog

## [0.3.1] - 2021-08-02

### Added

- This changelog

### Changed

- Add versioning badge to README
- Add step to remove contents of changelog to prevent confusion

## [0.3.0] - 2021-07-21

### Added

- Integrate stale action

### Changed

- Add "Before you begin" section to README

## [0.2.1] - 2021-06-08

### Changed

- Add explanation of why PR descriptions are so important

## [0.2.0] - 2021-06-03

### Added

- Pull request template
- Bug report template
- Feature request template

## [0.1.1] - 2021-05-24

### Changed

- Be more explicit about where the code of conduct applies

## [0.1.0] - 2021-05-11
## [0.2.0] - 2022-05-05

### Added

- Contributor Covenant
- Contribution guidelines
- Maintainers file
- README template
- Security guidance
- Initial release
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# k8s-used-api-versions.dockerfile
#
# k8s-used-api-versions checks the status of the used API versions
# and export them in a Prometheus metrics format
#
# @authors k8s-used-api-versions Maintainers

FROM golang:1.17 as build
ENV GOPATH=/go
ENV PATH="$PATH:$GOPATH/bin"
WORKDIR /app
COPY . /app
RUN go test -v ./pkg/...
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go

FROM alpine:3.12
ARG USERNAME=manager
ARG USERID=1003
ARG GROUPID=1003

RUN addgroup -g ${GROUPID} -S manager && \
adduser -u ${USERID} -S manager -G manager

WORKDIR /
USER manager
COPY --from=build /app/manager .
COPY --from=build /app/config/versions.yaml ./config/versions.yaml
ENTRYPOINT ["/manager"]
4 changes: 1 addition & 3 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Maintainers

- [GitHub Username](https://github.com/username)
- [GitHub Username](https://github.com/username)
- [GitHub Username](https://github.com/username)
- [Ahmed ElBakry](https://github.com/amelbakry)
108 changes: 108 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

all: build

##@ General

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php

help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Development

manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases

generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

fmt: ## Run go fmt against code.
go fmt ./...

vet: ## Run go vet against code.
go vet ./...

ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
test: manifests generate fmt vet ## Run tests.
mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out

##@ Build

build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go

run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go

docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .

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

##@ Deployment

install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -

deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | kubectl apply -f -

undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete -f -


CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])

KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef
16 changes: 16 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
domain: wayfair.com
layout:
- go.kubebuilder.io/v3
projectName: k8s-used-api-versions
repo: https://github.com/wayfair-incubator/k8s-used-api-versions
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: wayfair.com
group: api-version
kind: UsedApiVersions
path: https://github.com/wayfair-incubator/k8s-used-api-versions/api/v1beta1
version: v1beta1
version: "3"
Loading

0 comments on commit 1f07a32

Please sign in to comment.