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

feat: keptn-gateway service init #3654

Merged
merged 23 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ changefreq
Chans
Checkmarx
clientgoscheme
clientset
cloudevents
clt
clusterrole
Expand Down Expand Up @@ -408,6 +409,7 @@ Meha
mergo
metricsapi
metricscontroller
metricscount
metricskeptnsh
metricsobject
metricsprovider
Expand Down Expand Up @@ -539,6 +541,8 @@ remediations
replicasets
replicationcontrollers
resourcereference
restapi
returnval
Rexed
rgb
RLock
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ jobs:
folder: "scheduler/"
- name: "certificate-operator"
folder: "keptn-cert-manager/"
- name: "keptn-gateway"
folder: "keptn-gateway/"
steps:
- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand Down Expand Up @@ -138,6 +140,8 @@ jobs:
folder: "runtimes/python-runtime/"
- name: "certificate-operator"
folder: "keptn-cert-manager/"
- name: "keptn-gateway"
folder: "keptn-gateway/"
steps:
- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
folder: "scheduler/"
- name: "certificate-operator"
folder: "keptn-cert-manager/"
- name: "keptn-gateway"
folder: "keptn-gateway/"
steps:
- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ env:
# renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools
CONTROLLER_TOOLS_VERSION: "v0.15.0"
SCHEDULER_COMPATIBLE_K8S_VERSION: "v0.24.3"
PUBLISHABLE_ITEMS: '[".","lifecycle-operator","metrics-operator","keptn-cert-manager","runtimes/deno-runtime","runtimes/python-runtime","scheduler"]'
PUBLISHABLE_ITEMS: >
[
".",
"lifecycle-operator",
"metrics-operator",
"keptn-cert-manager",
"runtimes/deno-runtime",
"runtimes/python-runtime",
"scheduler",
"keptn-gateway
]

jobs:
release-please:
Expand Down Expand Up @@ -101,6 +111,7 @@ jobs:
case "lifecycle-operator":
case "scheduler":
case "metrics-operator":
case "keptn-gateway":
releaseMatrix.push({
name: item,
folder: item,
Expand Down Expand Up @@ -180,6 +191,7 @@ jobs:
temp="${temp##deno-runtime-}"
temp="${temp##scheduler-}"
temp="${temp##lifecycle-operator-}"
temp="${temp##keptn-gateway-}"
echo "IMAGE_TAG=${temp##metrics-operator-}" >> "$GITHUB_OUTPUT"

- name: Build Docker Image
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ readme-generator-for-helm/
**helm_tests_output.yaml

/docs/site

# keptn-gateway bin
keptn-gateway/keptn-gateway
52 changes: 52 additions & 0 deletions keptn-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM --platform=$BUILDPLATFORM golang:1.22.5-alpine3.19 AS builder

ENV CGO_ENABLED=0

WORKDIR /keptn-gateway

COPY go.mod go.sum ./
RUN go mod download

COPY ./*.go ./

ARG RELEASE_VERSION
ARG GIT_HASH
ARG BUILD_TIME
ARG TARGETOS
ARG TARGETARCH

RUN GOOS="$TARGETOS" GOARCH="$TARGETARCH" go build -ldflags "\
-X main.gitCommit=${GIT_HASH} \
-X main.buildTime=${BUILD_TIME} \
-X main.buildVersion=${RELEASE_VERSION} \
-w" \
-o bin/keptn-gateway ./main.go

FROM gcr.io/distroless/static-debian11:debug-nonroot AS debug

LABEL org.opencontainers.image.source="https://github.com/keptn/lifecycle-toolkit" \
org.opencontainers.image.url="https://keptn.sh" \
org.opencontainers.image.title="Keptn Gateway" \
org.opencontainers.image.vendor="Keptn" \
org.opencontainers.image.licenses="Apache-2.0"

COPY --from=builder /keptn-gateway/bin/keptn-gateway /bin/keptn-gateway

WORKDIR /bin

CMD ["keptn-gateway"]

FROM gcr.io/distroless/static-debian11:nonroot AS production

LABEL org.opencontainers.image.source="https://github.com/keptn/lifecycle-toolkit" \
org.opencontainers.image.url="https://keptn.sh" \
org.opencontainers.image.title="Keptn Gateway" \
org.opencontainers.image.vendor="Keptn" \
org.opencontainers.image.licenses="Apache-2.0"

COPY --from=builder /keptn-gateway/bin/keptn-gateway /bin/keptn-gateway
USER 65532:65532

WORKDIR /bin

CMD ["keptn-gateway"]
49 changes: 49 additions & 0 deletions keptn-gateway/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Simple Makefile for a Go project

# Build the application
all: build

build:
@echo "Building..."


@go build -o keptn-gateway cmd/api/main.go

# Run the application
run:
@go run cmd/api/main.go



# Test the application
test:
@echo "Testing..."
@go test ./... -v



# Clean the binary
clean:
@echo "Cleaning..."
@rm -f main

# Live Reload

watch:
@if command -v air > /dev/null; then \
air; \
echo "Watching...";\
else \
read -p "Go's 'air' is not installed on your machine. Do you want to install it? [Y/n] " choice; \
if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \
go install github.com/air-verse/air@latest; \
air; \
echo "Watching...";\
else \
echo "You chose not to install air. Exiting..."; \
exit 1; \
fi; \
fi


.PHONY: all build run test clean watch
15 changes: 15 additions & 0 deletions keptn-gateway/cmd/api/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import (
"fmt"
"keptn.sh/keptn-gateway/internal/gateway"
)

func main() {
gw := gateway.NewGateway()

err := gw.ListenAndServe()
if err != nil {
panic(fmt.Sprintf("cannot start server: %s", err))
}
asamonik marked this conversation as resolved.
Show resolved Hide resolved
}
87 changes: 87 additions & 0 deletions keptn-gateway/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
module keptn.sh/keptn-gateway

go 1.22.5

require (
github.com/gin-contrib/cors v1.7.2
github.com/gin-gonic/gin v1.10.0
github.com/joho/godotenv v1.5.1
github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20240805065043-2dbcd0b00232
go.uber.org/zap v1.27.0
k8s.io/client-go v0.29.7
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.47.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.30.3 // indirect
k8s.io/apiextensions-apiserver v0.28.12 // indirect
k8s.io/apimachinery v0.30.3 // indirect
k8s.io/component-base v0.28.12 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/controller-runtime v0.16.6 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading