Skip to content

Commit 8a6139a

Browse files
authored
Update boilerplate, fix linting issues (#290)
* Update boilerplate * Fixes for newly failing linter rules
1 parent 25b8154 commit 8a6139a

File tree

15 files changed

+106
-37
lines changed

15 files changed

+106
-37
lines changed

OWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ reviewers:
22
- abyrne55
33
- reedcort
44
- dakotalongRH
5-
- lnguyen1401
65
- luis-falcon
76
- joshbranham
87
approvers:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
image-v5.0.0
1+
image-v6.0.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
04db2d972cb7ea3fc0ec9aea4993e33ddbf22a77
1+
8563add3b7f509de3b49ba04863d2708d965b489

boilerplate/_lib/boilerplate-commit

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env bash
22

33
set -e
4+
if [ "$BOILERPLATE_SET_X" ]; then
5+
set -x
6+
fi
47

58
REPO_ROOT=$(git rev-parse --show-toplevel)
69
source $REPO_ROOT/boilerplate/_lib/common.sh
@@ -53,8 +56,14 @@ elif grep -q '^ M boilerplate/_data/last-boilerplate-commit$' $git_status; then
5356
bp_compare_url="https://github.com/openshift/boilerplate/compare/$bp_commit_change"
5457
# Generate the commit history for this range. This will go in the commit message.
5558
(
56-
$BOILERPLATE_GIT_CLONE $bp_clone
57-
cd $bp_clone
59+
if [[ -z "${BOILERPLATE_IN_CI}" ]]; then
60+
git clone "${BOILERPLATE_GIT_REPO}" "${bp_clone}"
61+
else
62+
# HACK: We can't get around safe.directory in CI, so just leverage cp instead of git
63+
cp -r /go/src/github.com/openshift/boilerplate/* "${bp_clone}"
64+
cp -r /go/src/github.com/openshift/boilerplate/.git "${bp_clone}"
65+
fi
66+
cd "${bp_clone}"
5867
# Matches promote.sh
5968
git log --no-merges --pretty=format:'commit: %H%nauthor: %an%n%s%n%n%b%n%n' $bp_commit_change > $bp_log
6069
)

boilerplate/_lib/common.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ image_exists_in_repo() {
107107
fi
108108
echo "Image ${image_uri} exists with digest $digest."
109109
return 0
110-
elif [[ "$stderr" == *"manifest unknown"* ]]; then
110+
elif [[ "$output" == *"manifest unknown"* || "$stderr" == *"manifest unknown"* ]]; then
111111
# We were able to talk to the repository, but the tag doesn't exist.
112112
# This is the normal "green field" case.
113113
echo "Image ${image_uri} does not exist in the repository."
114114
return 1
115-
elif [[ "$stderr" == *"was deleted or has expired"* ]]; then
115+
elif [[ "$output" == *"manifest unknown"* || "$stderr" == *"was deleted or has expired"* ]]; then
116116
# This should be rare, but accounts for cases where we had to
117117
# manually delete an image.
118118
echo "Image ${image_uri} was deleted from the repository."
@@ -177,9 +177,6 @@ fi
177177
if [ -z "$BOILERPLATE_GIT_REPO" ]; then
178178
export BOILERPLATE_GIT_REPO=https://github.com/openshift/boilerplate.git
179179
fi
180-
if [ -z "$BOILERPLATE_GIT_CLONE" ]; then
181-
export BOILERPLATE_GIT_CLONE="git clone $BOILERPLATE_GIT_REPO"
182-
fi
183180

184181
# The namespace of the ImageStream by which prow will import the image.
185182
IMAGE_NAMESPACE=openshift

boilerplate/_lib/freeze-check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ git reset --hard FETCH_HEAD
6767
# close a security hole whereby the latter is overridden.
6868
echo "Running update"
6969
cd $REPO_ROOT
70-
BOILERPLATE_GIT_CLONE="git clone $TMPD" boilerplate/update
70+
BOILERPLATE_GIT_REPO="${TMPD}" boilerplate/update
7171

7272
# Okay, if anything has changed, that's bad.
7373
if [[ $(git status --porcelain -- ':!build/Dockerfile*' | wc -l) -ne 0 ]]; then

boilerplate/openshift/golang-lint/ensure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -eo pipefail
55
REPO_ROOT=$(git rev-parse --show-toplevel)
66
source $REPO_ROOT/boilerplate/_lib/common.sh
77

8-
GOLANGCI_LINT_VERSION="1.54.2"
8+
GOLANGCI_LINT_VERSION="1.59.1"
99
DEPENDENCY=${1:-}
1010
GOOS=$(go env GOOS)
1111

boilerplate/openshift/golang-lint/golangci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@ linters:
1717
disable-all: true
1818
enable:
1919
- errcheck
20+
- gosec
2021
- gosimple
2122
- govet
2223
- ineffassign
24+
- misspell
2325
- staticcheck
2426
- typecheck
2527
- unused
28+
29+
linters-settings:
30+
misspell:
31+
extra-words:
32+
- typo: "openshit"
33+
correction: "OpenShift"

boilerplate/update

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
set -e
1313
if [ "$BOILERPLATE_SET_X" ]; then
14-
set -x
14+
set -x
1515
fi
1616

1717
# The directory in which this script lives is the CONVENTION_ROOT. Export
@@ -105,10 +105,17 @@ EOF
105105
BOILERPLATE_GIT_REPO=git@github.com:openshift/boilerplate.git
106106
fi
107107
if [ -z "$BOILERPLATE_GIT_CLONE" ]; then
108-
BOILERPLATE_GIT_CLONE="git clone $BOILERPLATE_GIT_REPO"
108+
BOILERPLATE_GIT_CLONE="git clone"
109109
fi
110110
BP_CLONE="$(mktemp -d)"
111-
$BOILERPLATE_GIT_CLONE "${BP_CLONE}"
111+
112+
if [[ -z "${BOILERPLATE_IN_CI}" ]]; then
113+
${BOILERPLATE_GIT_CLONE} "${BOILERPLATE_GIT_REPO}" "${BP_CLONE}"
114+
else
115+
# HACK: We can't get around safe.directory in CI, so just leverage cp instead of git
116+
cp -rf /go/src/github.com/openshift/boilerplate/* "${BP_CLONE}"
117+
cp -rf /go/src/github.com/openshift/boilerplate/.git "${BP_CLONE}"
118+
fi
112119
echo "Updating the update script."
113120
rsync -a "${BP_CLONE}/boilerplate/update" "$0"
114121
echo "Copying utilities"
@@ -159,7 +166,9 @@ if [ ! -f "$CONFIG_FILE" ]; then
159166
fi
160167

161168
# The most recent build image tag. Export this for individual `update` scripts.
162-
export LATEST_IMAGE_TAG=$(cd $BP_CLONE; git describe --tags --abbrev=0 --match image-v*)
169+
if [[ -z "$LATEST_IMAGE_TAG" ]]; then
170+
export LATEST_IMAGE_TAG=$(cd $BP_CLONE; git describe --tags --abbrev=0 --match image-v*)
171+
fi
163172

164173
# Prepare the "nexus makefile include".
165174
NEXUS_MK="${CONVENTION_ROOT}/generated-includes.mk"

cmd/egress/cmd.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,15 @@ are set correctly before execution.
248248
validateEgressCmd.Flags().StringSliceVar(&config.securityGroupIDs, "security-group-ids", []string{}, "(optional) comma-separated list of sec. group IDs to attach to the created EC2 instance. If absent, one will be created")
249249
validateEgressCmd.Flags().StringVar(&config.egressListLocation, "egress-list-location", "", "(optional) the location of the egress URL list to use. Can either be a local file path or an external URL starting with http(s). This value is ignored for the legacy probe.")
250250
validateEgressCmd.Flags().StringVar(&config.region, "region", "", fmt.Sprintf("(optional) compute instance region. If absent, environment var %[1]v = %[2]v and %[3]v = %[4]v will be used", awsRegionEnvVarStr, awsRegionDefault, gcpRegionEnvVarStr, gcpRegionDefault))
251-
validateEgressCmd.Flags().StringToStringVar(&config.cloudTags, "cloud-tags", map[string]string{}, "(optional) comma-seperated list of tags to assign to cloud resources e.g. --cloud-tags key1=value1,key2=value2")
251+
validateEgressCmd.Flags().StringToStringVar(&config.cloudTags, "cloud-tags", map[string]string{}, "(optional) comma-separated list of tags to assign to cloud resources e.g. --cloud-tags key1=value1,key2=value2")
252252
validateEgressCmd.Flags().BoolVar(&config.debug, "debug", false, "(optional) if true, enable additional debug-level logging")
253253
validateEgressCmd.Flags().DurationVar(&config.timeout, "timeout", time.Duration(0), "(optional) timeout for individual egress verification requests")
254254
validateEgressCmd.Flags().StringVar(&config.kmsKeyID, "kms-key-id", "", "(optional) ID of KMS key used to encrypt root volumes of compute instances. Defaults to cloud account default key")
255255
validateEgressCmd.Flags().StringVar(&config.httpProxy, "http-proxy", "", "(optional) http-proxy to be used upon http requests being made by verifier, format: http://user:pass@x.x.x.x:8978")
256256
validateEgressCmd.Flags().StringVar(&config.httpsProxy, "https-proxy", "", "(optional) https-proxy to be used upon https requests being made by verifier, format: https://user:pass@x.x.x.x:8978")
257257
validateEgressCmd.Flags().StringVar(&config.CaCert, "cacert", "", "(optional) path to cacert file to be used upon https requests being made by verifier")
258258
validateEgressCmd.Flags().BoolVar(&config.noTls, "no-tls", false, "(optional) if true, skip client-side SSL certificate validation")
259-
validateEgressCmd.Flags().StringSliceVar(&config.noProxy, "no-proxy", []string{}, "(optional) comma-seperated list of domains or IPs to not pass through the configured http/https proxy e.g. --no-proxy example.com,test.example.com")
259+
validateEgressCmd.Flags().StringSliceVar(&config.noProxy, "no-proxy", []string{}, "(optional) comma-separated list of domains or IPs to not pass through the configured http/https proxy e.g. --no-proxy example.com,test.example.com")
260260
validateEgressCmd.Flags().StringVar(&config.awsProfile, "profile", "", "(optional) AWS profile. If present, any credentials passed with CLI will be ignored")
261261
validateEgressCmd.Flags().StringVar(&config.gcpVpcName, "vpc-name", "", "(optional unless --platform='gcp') VPC name where GCP cluster is installed")
262262
validateEgressCmd.Flags().BoolVar(&config.skipAWSInstanceTermination, "skip-termination", false, "(optional) Skip instance termination to allow further debugging")
@@ -321,12 +321,18 @@ func getCustomLocalEgressList(filePath string) (string, error) {
321321
return string(file), nil
322322
}
323323

324-
func getCustomExternalEgressList(url string) (string, error) {
325-
response, err := http.Get(url)
324+
func getCustomExternalEgressList(uri string) (string, error) {
325+
req, err := http.NewRequest(http.MethodGet, uri, nil)
326326
if err != nil {
327327
return "", err
328328
}
329-
b, err := io.ReadAll(response.Body)
329+
330+
res, err := http.DefaultClient.Do(req)
331+
if err != nil {
332+
return "", err
333+
}
334+
335+
b, err := io.ReadAll(res.Body)
330336
if err != nil {
331337
return "", err
332338
}

0 commit comments

Comments
 (0)