-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: repository cloner #659
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bf9694e
feat(crd): make the CodeRepositories immutable
sgaist 337ba0e
feat(crd): untie configuration name from git in CodeRepository field
sgaist 7a195a7
feat(crd): update documentation for cloning secret
sgaist b42ff21
feat: implement git clone helper
sgaist 8f5128d
feat: implement cloning of repositories
sgaist 4b243a6
fix: improve comments
sgaist ca3122b
refactor: use go-git for URL parsing
sgaist aaaae85
refactor: rename AuthConfig to CloneConfig
sgaist dc38d0c
Merge branch 'main' into feature/repository-cloner
sgaist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,42 @@ | ||
# | ||
# Copyright 2024. | ||
# | ||
# 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. | ||
# | ||
|
||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
go.work.sum | ||
|
||
# env file | ||
.env | ||
|
||
# Output folder | ||
bin/ |
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,27 @@ | ||
# Build the application from source | ||
FROM golang:1.22 AS build-stage | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY *.go ./ | ||
COPY cmd ./cmd | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -o /cloner | ||
|
||
# Run the tests in the container | ||
FROM build-stage AS run-test-stage | ||
RUN go test -v ./... | ||
|
||
# Deploy the application binary into a lean image | ||
FROM gcr.io/distroless/base-debian12 AS build-release-stage | ||
|
||
WORKDIR / | ||
|
||
COPY --from=build-stage /cloner /cloner | ||
|
||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["/cloner"] |
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,122 @@ | ||
# | ||
# Copyright 2024. | ||
# | ||
# 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. | ||
# | ||
|
||
# VERSION defines the project version for the bundle. | ||
# Update this value when you upgrade the version of your project. | ||
# To re-generate a bundle for another specific version without changing the standard setup, you can: | ||
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2) | ||
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2) | ||
VERSION ?= 0.0.1 | ||
LDFLAGS="-X 'cloner/cmd.Version=v$(VERSION)'" | ||
|
||
# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images. | ||
# This variable is used to construct full image tags for bundle and catalog images. | ||
# | ||
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both | ||
# amalthea.dev/amalthea-bundle:$VERSION and amalthea.dev/amalthea-catalog:$VERSION. | ||
IMAGE_TAG_BASE ?= renku/cloner | ||
IMG ?= $(IMAGE_TAG_BASE):$(VERSION) | ||
|
||
# CONTAINER_TOOL defines the container tool to be used for building images. | ||
# Be aware that the target commands are only tested with Docker which is | ||
# scaffolded by default. However, you might want to replace it to use other | ||
# tools. (i.e. podman) | ||
CONTAINER_TOOL ?= docker | ||
|
||
# Setting SHELL to bash allows bash commands to be executed by recipes. | ||
# 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 | ||
|
||
.PHONY: help | ||
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) | ||
|
||
.PHONY: all | ||
all: mod test vet fmt build run | ||
|
||
##@ Run | ||
|
||
.PHONY: | ||
run: fmt vet build run ## Run the proxy | ||
chmod +x bin/cloner | ||
./bin/cloner | ||
|
||
.PHONY: install | ||
install: run ## Install the proxy | ||
go install -v ./... | ||
|
||
##@ QA | ||
|
||
.PHONY: audit | ||
audit: ## Run quality control checks | ||
go mod verify | ||
go vet ./... | ||
go run honnef.co/go/tools/cmd/staticcheck@latest -checks=all,-ST1000,-U1000 ./... | ||
go run golang.org/x/vuln/cmd/govulncheck@latest ./... | ||
|
||
.PHONY: test | ||
test: build ## Run tests | ||
go test $$(go list ./... | grep -v /e2e) -race -buildvcs | ||
|
||
.PHONY: vet | ||
vet: ## Run go vet against code. | ||
go vet ./... | ||
|
||
.PHONY: fmt | ||
fmt: ## Run go fmt against code. | ||
go fmt ./... | ||
|
||
.PHONY: mod | ||
mod: ## Tidy mods | ||
go mod tidy | ||
|
||
.PHONY: code-cleanup | ||
code-cleanup: vet fmt mod ## Code cleanup | ||
|
||
##@ Build | ||
|
||
.PHONY: build | ||
build: fmt vet | ||
go build -ldflags=$(LDFLAGS) -o bin/cloner main.go | ||
|
||
# If you wish to build the manager image targeting other platforms you can use the --platform flag. | ||
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it. | ||
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/ | ||
.PHONY: docker-build | ||
docker-build: ## Build docker image with the manager. | ||
$(CONTAINER_TOOL) build -t ${IMG} . | ||
|
||
.PHONY: docker-push | ||
docker-push: ## Push docker image with the manager. | ||
$(CONTAINER_TOOL) push ${IMG} | ||
|
||
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple | ||
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: | ||
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/ | ||
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/ | ||
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail) | ||
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option. | ||
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le | ||
.PHONY: docker-buildx | ||
docker-buildx: ## Build and push docker image for the manager for cross-platform support | ||
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile | ||
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross | ||
- $(CONTAINER_TOOL) buildx create --name project-v3-builder | ||
$(CONTAINER_TOOL) buildx use project-v3-builder | ||
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . | ||
- $(CONTAINER_TOOL) buildx rm project-v3-builder | ||
rm Dockerfile.cross |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this means that we would expect specific keys to have specific values in the secret. Or that the secret will have a specific format. If yes, then we should document these values here.