Skip to content

Commit

Permalink
Upgrade Golang and dependencies versions. (#27)
Browse files Browse the repository at this point in the history
# Upgrade Golang and Dependencies to Improve Performance and Security

## Overview
This pull request introduces significant updates to the `keess` project,
focusing on upgrading Golang and various dependencies to their latest
versions.

## Key Changes
1. **Golang Upgrade:** Updated to version 1.21, ensuring compatibility
with the latest features and security patches.
2. **Dependencies Update:** Modified the `go.mod` file to include the
latest versions of our dependencies, enhancing the project's stability
and performance.
3. **Dockerfile and Makefile Adjustments:** Reflected the Golang version
upgrade and tweaked the build process for better efficiency.
4. **Chart Updates:** Made necessary updates to `Chart.yaml` and
`values.yaml` to align with the current project configuration.

## Benefits
- **Enhanced Security:** The latest versions of Golang and dependencies
include important security fixes.
- **Improved Performance:** The upgrades contribute to better overall
performance of the application.
- **Future-Proofing:** These updates ensure that our project stays
up-to-date with the latest technological standards.
  • Loading branch information
mvleandro authored Jan 29, 2024
1 parent c03ad4f commit 9089d4e
Show file tree
Hide file tree
Showing 8 changed files with 1,288 additions and 54 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ apiserver.local.config/**
.DS_Store
.vscode
keess
coverage.*

39 changes: 29 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
# Build
FROM --platform=linux/amd64 golang:1.19 as build
# Stage 1: Build the Go application
FROM golang:1.21-alpine AS builder

WORKDIR /app
COPY . ./
# Set necessary environmet variables needed for our image
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64

# Move to working directory /build
WORKDIR /build

# Copy and download dependency using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy the code into the container
COPY . .

# Run tests
RUN go test ./...
RUN go build -o /keess

# Run
FROM --platform=linux/amd64 ubuntu
# Build the application
RUN go build -o keess .

# Stage 2: Build a small image
FROM alpine

WORKDIR /
COPY --from=build /keess /keess
# Copy the binary from the builder stage
COPY --from=builder /build/keess /app/keess

ENTRYPOINT ["./keess", "run"]
# Command to run
ENTRYPOINT ["/app/keess", "run"]
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Project variables
PROJECT_NAME := "keess"
DOCKER_IMAGE_NAME := "keess"
DOCKER_TAG := "latest"

# Go related variables
GOBASE := $(shell pwd)
GOBIN := $(GOBASE)/bin

.PHONY: build test docker-build coverage run docker-run help

# Build the project
build:
@echo "Building $(PROJECT_NAME)..."
@GOBIN=$(GOBIN) go build -o $(GOBIN)/$(PROJECT_NAME) $(GOBASE)

# Run tests
test:
@echo "Running tests..."
@go test ./...

# Build Docker image
docker-build:
@echo "Building Docker image..."

# Remove the existing builder
@docker buildx rm mybuilder
@docker buildx create --name mybuilder --use
@docker buildx build --platform linux/amd64,linux/arm64 -t $(DOCKER_IMAGE_NAME):$(DOCKER_TAG) .

# New target for code coverage
coverage:
@echo "Generating code coverage..."
@go test ./... -coverprofile=coverage.out
@go tool cover -html=coverage.out -o coverage.html
@echo "Opening code coverage report in browser..."
@open coverage.html

# Target to execute the application
run: build
@echo "Running the application..."
@./bin/keess run

# Target to run the Docker image with the .kube directory mounted
docker-run:
@echo "Running Docker image with .kube directory mounted..."
@docker run --rm -it -v ${HOME}/.kube:/root/.kube $(DOCKER_IMAGE_NAME):$(DOCKER_TAG)

# Help
help:
@echo "Makefile commands:"
@echo "build - Build the project"
@echo "test - Run tests"
@echo "docker-build - Build Docker image"
@echo "coverage - Generate and view code coverage report"
@echo "run - Run the application"
@echo "docker-run - Run the Docker image with .kube directory mounted"



2 changes: 1 addition & 1 deletion application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func New() *cli.App {
app := cli.NewApp()
app.Name = "Keess"
app.Version = "v0.2.13"
app.Version = "0.2.14"
app.Usage = "Keep stuff synchronized."
app.Description = "Keep secrets and configmaps synchronized."
app.Suggest = true
Expand Down
4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.13
version: 0.2.14

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.2.13"
appVersion: "0.2.14"
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ image:
repository: image-registry.powerapp.cloud/keess/keess
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "main-35d1677055f029d07336104d51082ff26dbe89e5-19"
tag: ""


# Default Keess config
Expand Down
85 changes: 45 additions & 40 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
module keess

go 1.19
go 1.21

require (
github.com/appscode/go v0.0.0-20201105063637-5613f3b8169f
github.com/spf13/viper v1.16.0
github.com/urfave/cli/v2 v2.25.7
go.uber.org/zap v1.24.0
k8s.io/api v0.27.3
k8s.io/apimachinery v0.27.3
k8s.io/client-go v0.27.3
github.com/fsnotify/fsnotify v1.7.0
github.com/spf13/viper v1.18.2
github.com/urfave/cli/v2 v2.27.1
go.uber.org/zap v1.26.0
k8s.io/api v0.29.1
k8s.io/apimachinery v0.29.1
k8s.io/client-go v0.29.1
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/gnostic v0.7.0 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // 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/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -37,32 +38,36 @@ require (
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.0.8 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240126223410-2919ad4fcfec // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 9089d4e

Please sign in to comment.