Skip to content

Commit

Permalink
Fix installation of gosec and addlicense (#957)
Browse files Browse the repository at this point in the history
* Change values and names of variables used in tools.mk file to fix bug in gosec and addlicense installation

* run make generate

* Update go version to v1.23.3

---------

Co-authored-by: Rishabh Patel <[email protected]>
  • Loading branch information
thiyyakat and rishabh-11 authored Dec 2, 2024
1 parent 31418bc commit f733669
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .ci/pipeline_definitions
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ machine-controller-manager:
availability_requirement: 'low'
steps:
check:
image: 'golang:1.22.5'
image: 'golang:1.23.3'
test:
image: europe-docker.pkg.dev/gardener-project/releases/testmachinery/base-step:stable
build:
image: 'golang:1.22.5'
image: 'golang:1.23.3'
output_dir: 'binary'
jobs:
head-update:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
############# builder #############
FROM golang:1.22.5 AS builder
FROM golang:1.23.3 AS builder

WORKDIR /go/src/github.com/gardener/machine-controller-manager
COPY . .
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

-include .env
TOOLS_DIR := hack/tools
include hack/tools.mk

IMAGE_REPOSITORY := europe-docker.pkg.dev/gardener-project/public/gardener/machine-controller-manager
Expand Down
16 changes: 7 additions & 9 deletions docs/documents/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -2607,10 +2607,9 @@ k8s.io/apimachinery/pkg/util/intstr.IntOrString
Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
Absolute number is calculated from percentage by rounding down.
This can not be 0 if MaxSurge is 0.
By default, a fixed value of 1 is used.
Example: when this is set to 30%, the old MC can be scaled down to 70% of desired machines
immediately when the rolling update starts. Once new machines are ready, old MC
can be scaled down further, followed by scaling up the new MC, ensuring
Example: when this is set to 30%, the old machine set can be scaled down to 70% of desired machines
immediately when the rolling update starts. Once new machines are ready, old machine set
can be scaled down further, followed by scaling up the new machine set, ensuring
that the total number of machines available at all times during the update is at
least 70% of desired machines.</p>
</td>
Expand All @@ -2633,12 +2632,11 @@ machines.
Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
This can not be 0 if MaxUnavailable is 0.
Absolute number is calculated from percentage by rounding up.
By default, a value of 1 is used.
Example: when this is set to 30%, the new MC can be scaled up immediately when
the rolling update starts, such that the total number of old and new machines do not exceed
Example: when this is set to 30%, the new machine set can be scaled up immediately when
the rolling update starts, such that the total number of old and new machines does not exceed
130% of desired machines. Once old machines have been killed,
new MC can be scaled up further, ensuring that total number of machines running
at any time during the update is atmost 130% of desired machines.</p>
new machine set can be scaled up further, ensuring that total number of machines running
at any time during the update is utmost 130% of desired machines.</p>
</td>
</tr>
</tbody>
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/gardener/machine-controller-manager

go 1.22.0

toolchain go1.23.0
go 1.23.0

require (
github.com/Masterminds/semver/v3 v3.2.1
Expand Down
13 changes: 10 additions & 3 deletions hack/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
#
# SPDX-License-Identifier: Apache-2.0

TOOLS_DIR := hack/tools
ifeq ($(strip $(shell go list -m 2>/dev/null)),github.com/gardener/machine-controller-manager)
TOOLS_PKG_PATH := ./hack/tools
else
# dependency on github.com/gardener/machine-controller-manager/hack/tools is optional and only needed if other projects want to reuse
# install-gosec.sh. If they don't use it and the project doesn't depend on the package,
# silence the error to minimize confusion.
TOOLS_PKG_PATH := $(shell go list -tags tools -f '{{ .Dir }}' github.com/gardener/machine-controller-manager/hack/tools 2>/dev/null)
endif
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin

## Tool Binaries
Expand All @@ -13,7 +20,7 @@ CONVERSION_GEN ?= $(TOOLS_BIN_DIR)/conversion-gen
OPENAPI_GEN ?= $(TOOLS_BIN_DIR)/openapi-gen
VGOPATH ?= $(TOOLS_BIN_DIR)/vgopath
GEN_CRD_API_REFERENCE_DOCS ?= $(TOOLS_BIN_DIR)/gen-crd-api-reference-docs
ADDLICENSE ?= $(TOOLS_BIN_DIR)/addlicense
GO_ADD_LICENSE ?= $(TOOLS_BIN_DIR)/addlicense
GOIMPORTS ?= $(TOOLS_BIN_DIR)/goimports
GOLANGCI_LINT ?= $(TOOLS_BIN_DIR)/golangci-lint
GOSEC ?= $(TOOLS_BIN_DIR)/gosec
Expand Down Expand Up @@ -74,4 +81,4 @@ $(GOLANGCI_LINT): $(TOOLS_BIN_DIR)
GOBIN=$(abspath $(TOOLS_BIN_DIR)) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)

$(GOSEC):
GOSEC_VERSION=$(GOSEC_VERSION) bash $(abspath $(TOOLS_DIR))/install-gosec.sh
GOSEC_VERSION=$(GOSEC_VERSION) bash $(TOOLS_PKG_PATH)/install-gosec.sh
Empty file added hack/tools/bin/.gitkeep
Empty file.
Binary file removed hack/tools/bin/addlicense
Binary file not shown.
6 changes: 6 additions & 0 deletions hack/tools/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0

// Package tools allows importing scripts in this directory in other projects via go mod dependencies.
package tools
5 changes: 1 addition & 4 deletions hack/tools/install-gosec.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ TOOLS_BIN_DIR=${TOOLS_BIN_DIR:-$(dirname $0)/bin}

platform=$(uname -s | tr '[:upper:]' '[:lower:]')
version=$GOSEC_VERSION
echo "gosec version:$GOSEC_VERSION"
case $(uname -m) in
aarch64 | arm64)
arch="arm64"
Expand All @@ -34,10 +33,8 @@ function cleanup {
rm -rf "${temp_dir}"
}
trap cleanup EXIT ERR INT TERM
echo "Downloading from: https://github.com/securego/gosec/releases/download/${version}/${file_name}"
curl -L -o ${temp_dir}/${file_name} "https://github.com/securego/gosec/releases/download/${version}/${file_name}"


tar -xzm -C "${temp_dir}" -f "${temp_dir}/${file_name}"
mv "${temp_dir}/gosec" $TOOLS_BIN_DIR
chmod +x $TOOLS_BIN_DIR/gosec
chmod +x $TOOLS_BIN_DIR/gosec
16 changes: 7 additions & 9 deletions kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,11 @@ spec:
Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
This can not be 0 if MaxUnavailable is 0.
Absolute number is calculated from percentage by rounding up.
By default, a value of 1 is used.
Example: when this is set to 30%, the new MC can be scaled up immediately when
the rolling update starts, such that the total number of old and new machines do not exceed
Example: when this is set to 30%, the new machine set can be scaled up immediately when
the rolling update starts, such that the total number of old and new machines does not exceed
130% of desired machines. Once old machines have been killed,
new MC can be scaled up further, ensuring that total number of machines running
at any time during the update is atmost 130% of desired machines.
new machine set can be scaled up further, ensuring that total number of machines running
at any time during the update is utmost 130% of desired machines.
x-kubernetes-int-or-string: true
maxUnavailable:
anyOf:
Expand All @@ -195,10 +194,9 @@ spec:
Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
Absolute number is calculated from percentage by rounding down.
This can not be 0 if MaxSurge is 0.
By default, a fixed value of 1 is used.
Example: when this is set to 30%, the old MC can be scaled down to 70% of desired machines
immediately when the rolling update starts. Once new machines are ready, old MC
can be scaled down further, followed by scaling up the new MC, ensuring
Example: when this is set to 30%, the old machine set can be scaled down to 70% of desired machines
immediately when the rolling update starts. Once new machines are ready, old machine set
can be scaled down further, followed by scaling up the new machine set, ensuring
that the total number of machines available at all times during the update is at
least 70% of desired machines.
x-kubernetes-int-or-string: true
Expand Down
4 changes: 2 additions & 2 deletions pkg/openapi/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/util/provider/machinecontroller/userdata_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0

package controller

import (
Expand Down

0 comments on commit f733669

Please sign in to comment.