-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from martel-innovate/migrate
Migrate from c0c0n3/source-watcher
- Loading branch information
Showing
253 changed files
with
40,847 additions
and
2 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,21 @@ | ||
name: rebase | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
rebase: | ||
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') && (github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the latest code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Automatic Rebase | ||
uses: cirrus-actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT }} |
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,39 @@ | ||
name: Create and publish a Docker image | ||
|
||
on: [release] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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 @@ | ||
name: test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
unit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Restore Go cache | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
- name: Setup Kubebuilder | ||
uses: fluxcd/pkg/actions/kubebuilder@main | ||
- name: Run tests | ||
run: make test | ||
env: | ||
KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin | ||
- name: Check if working tree is dirty | ||
run: | | ||
if [[ $(git diff --stat) != '' ]]; then | ||
echo 'run make test and commit changes' | ||
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,18 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool | ||
*.out | ||
|
||
# Local build output dir | ||
bin/ | ||
|
||
# IDE files | ||
.vscode |
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,3 @@ | ||
## Code of Conduct | ||
|
||
Source watcher follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). |
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,82 @@ | ||
# Contributing | ||
|
||
Source watcher is [Apache 2.0 licensed](LICENSE) and accepts contributions | ||
via GitHub pull requests. This document outlines some of the conventions on | ||
to make it easier to get your contribution accepted. | ||
|
||
We gratefully welcome improvements to issues and documentation as well as to | ||
code. | ||
|
||
## Certificate of Origin | ||
|
||
By contributing to this project you agree to the Developer Certificate of | ||
Origin (DCO). This document was created by the Linux Kernel community and is a | ||
simple statement that you, as a contributor, have the legal right to make the | ||
contribution. | ||
|
||
We require all commits to be signed. By signing off with your signature, you | ||
certify that you wrote the patch or otherwise have the right to contribute the | ||
material by the rules of the [DCO](DCO): | ||
|
||
`Signed-off-by: Jane Doe <[email protected]>` | ||
|
||
The signature must contain your real name | ||
(sorry, no pseudonyms or anonymous contributions) | ||
If your `user.name` and `user.email` are configured in your Git config, | ||
you can sign your commit automatically with `git commit -s`. | ||
|
||
## Communications | ||
|
||
The project uses Slack: To join the conversation, simply join the | ||
[CNCF](https://slack.cncf.io/) Slack workspace and use the | ||
[#flux](https://cloud-native.slack.com/messages/flux/) channel. | ||
|
||
The developers use a mailing list to discuss development as well. | ||
Simply subscribe to [flux-dev on cncf.io](https://lists.cncf.io/g/cncf-flux-dev) | ||
to join the conversation (this will also add an invitation to your | ||
Google calendar for our [Flux | ||
meeting](https://docs.google.com/document/d/1l_M0om0qUEN_NNiGgpqJ2tvsF2iioHkaARDeh6b70B0/edit#)). | ||
|
||
### How to run the test suite | ||
|
||
Prerequisites: | ||
* go >= 1.16 | ||
* kubebuilder >= 3.0 | ||
* kustomize >= 4.0 | ||
|
||
You can run the unit tests by simply doing | ||
|
||
```bash | ||
make test | ||
``` | ||
|
||
## Acceptance policy | ||
|
||
These things will make a PR more likely to be accepted: | ||
|
||
- a well-described requirement | ||
- tests for new code | ||
- tests for old code! | ||
- new code and tests follow the conventions in old code and tests | ||
- a good commit message (see below) | ||
- all code must abide [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments) | ||
- names should abide [What's in a name](https://talks.golang.org/2014/names.slide#1) | ||
- code must build on both Linux and Darwin, via plain `go build` | ||
- code should have appropriate test coverage and tests should be written | ||
to work with `go test` | ||
|
||
In general, we will merge a PR once one maintainer has endorsed it. | ||
For substantial changes, more people may become involved, and you might | ||
get asked to resubmit the PR or divide the changes into more than one PR. | ||
|
||
### Format of the Commit Message | ||
|
||
For Kustomize Controller we prefer the following rules for good commit messages: | ||
|
||
- Limit the subject to 50 characters and write as the continuation | ||
of the sentence "If applied, this commit will ..." | ||
- Explain what and why in the body, if more than a trivial change; | ||
wrap it at 72 characters. | ||
|
||
The [following article](https://chris.beams.io/posts/git-commit/#seven-rules) | ||
has some more helpful advice on documenting your work. |
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,36 @@ | ||
Developer Certificate of Origin | ||
Version 1.1 | ||
|
||
Copyright (C) 2004, 2006 The Linux Foundation and its contributors. | ||
660 York Street, Suite 102, | ||
San Francisco, CA 94110 USA | ||
|
||
Everyone is permitted to copy and distribute verbatim copies of this | ||
license document, but changing it is not allowed. | ||
|
||
|
||
Developer's Certificate of Origin 1.1 | ||
|
||
By making a contribution to this project, I certify that: | ||
|
||
(a) The contribution was created in whole or in part by me and I | ||
have the right to submit it under the open source license | ||
indicated in the file; or | ||
|
||
(b) The contribution is based upon previous work that, to the best | ||
of my knowledge, is covered under an appropriate open source | ||
license and I have the right under that license to submit that | ||
work with modifications, whether created in whole or in part | ||
by me, under the same open source license (unless I am | ||
permitted to submit under a different license), as indicated | ||
in the file; or | ||
|
||
(c) The contribution was provided directly to me by some other | ||
person who certified (a), (b) or (c) and I have not modified | ||
it. | ||
|
||
(d) I understand and agree that this project and the contribution | ||
are public and that a record of the contribution (including all | ||
personal information I submit with it, including my sign-off) is | ||
maintained indefinitely and may be redistributed consistent with | ||
this project or the open source license(s) involved. |
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,34 @@ | ||
FROM golang:1.16-alpine as builder | ||
|
||
WORKDIR /workspace | ||
|
||
# copy modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
|
||
# cache modules | ||
RUN go mod download | ||
|
||
# copy source code | ||
COPY main.go main.go | ||
COPY controllers/ controllers/ | ||
COPY osmops/ osmops/ | ||
|
||
# build | ||
RUN CGO_ENABLED=0 go build -a -o source-watcher main.go | ||
|
||
FROM alpine:3.13 | ||
|
||
RUN apk add --no-cache ca-certificates tini | ||
|
||
COPY --from=builder /workspace/source-watcher /usr/local/bin/ | ||
|
||
# Create minimal nsswitch.conf file to prioritize the usage of /etc/hosts over DNS queries. | ||
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-354316460 | ||
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf | ||
|
||
RUN addgroup -S controller && adduser -S controller -G controller | ||
|
||
USER controller | ||
|
||
ENTRYPOINT [ "/sbin/tini", "--", "source-watcher" ] |
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,92 @@ | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= ghcr.io/martel-innovate/osmops:latest | ||
# Produce CRDs that work back to Kubernetes 1.16 | ||
CRD_OPTIONS ?= crd:crdVersions=v1 | ||
|
||
# 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 | ||
|
||
all: manager | ||
|
||
# Run tests | ||
test: generate fmt vet manifests | ||
go test ./... -coverprofile cover.out | ||
|
||
# Build manager binary | ||
manager: generate fmt vet | ||
go build -o bin/manager main.go | ||
|
||
# Run against the configured Kubernetes cluster in ~/.kube/config | ||
run: generate fmt vet manifests | ||
go run ./main.go | ||
|
||
# Install CRDs into a cluster | ||
install: manifests | ||
kustomize build config/crd | ||
# kustomize build config/crd | kubectl apply -f - | ||
# ^ potentially harmful. what if you're connected to the wrong cluster?! | ||
|
||
# Uninstall CRDs from a cluster | ||
uninstall: manifests | ||
kustomize build config/crd | ||
# kustomize build config/crd | kubectl delete -f - | ||
# ^ potentially harmful. what if you're connected to the wrong cluster?! | ||
|
||
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
deploy: manifests | ||
cd config/manager && kustomize edit set image source-watcher=${IMG} | ||
kustomize build config/default | ||
# kustomize build config/default | kubectl apply -f - | ||
# ^ potentially harmful. what if you're connected to the wrong cluster?! | ||
|
||
# Generate manifests e.g. CRD, RBAC etc. | ||
manifests: controller-gen | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=source-reader webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
||
# Run go fmt against code | ||
fmt: | ||
go fmt ./... | ||
|
||
# Run go vet against code | ||
vet: | ||
go vet ./... | ||
|
||
# Generate code | ||
generate: controller-gen | ||
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." | ||
|
||
# Build the docker image | ||
docker-build: test | ||
docker build . -t ${IMG} | ||
|
||
# Push the docker image | ||
# TODO: get rid of this mess. Use GH actions when moving to own repo. | ||
# NOTE. docker login stores the token in osxkeychain, logout removes it from | ||
# there. Not sure why GH recommends using their tool (gh), since as you can | ||
# see the token is stored unencrypted and with no password protection! | ||
docker-push: | ||
grep oauth_token ~/.config/gh/hosts.yml | sed 's/.*oauth_token: //' | docker login ghcr.io -u c0c0n3 --password-stdin | ||
docker push ${IMG} | ||
docker logout ghcr.io | ||
|
||
# find or download controller-gen | ||
# download controller-gen if necessary | ||
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 |
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,3 @@ | ||
domain: fluxcd.io | ||
repo: github.com/fluxcd/source-watcher | ||
version: "2" |
Oops, something went wrong.