Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion .github/renovate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ module.exports = {
"depNameTemplate": "kubernetes-sigs/external-dns",
"datasourceTemplate": "github-releases",
"versioningTemplate": "semver"
}
},
{
"customType": "regex",
"fileMatch": [".*"],
"matchStrings": [
"datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s.*?_VERSION=(?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}",
},
]
};
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ jobs:
with:
path-to-profile: profile.cov
if: github.actor != 'nektos/act'
continue-on-error: true
24 changes: 11 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,26 @@ cover-html: cover
@go tool cover -html=cover.out

#? controller-gen: download controller-gen if necessary
controller-gen:
controller-gen-install:
@scripts/install-tools.sh --generator
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
go install sigs.k8s.io/controller-tools/cmd/[email protected] ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

#? golangci-lint: Install golangci-lint tool
golangci-lint:
@command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.0.2
#? controller-gen-install: download controller-gen if necessary
controller-gen-install:
@scripts/install-tools.sh --generator

#? golangci-lint-verify: Verify golangci-lint configuration
golangci-lint-verify: golangci-lint
@golangci-lint config verify
#? golangci-lint-install: Install golangci-lint tool
golangci-lint-install:
@scripts/install-tools.sh --golangci

#? go-lint: Run the golangci-lint tool
.PHONY: go-lint
go-lint: golangci-lint
go-lint: golangci-lint-install
golangci-lint config verify
gofmt -l -s -w .
golangci-lint run --timeout=30m --fix ./...

Expand All @@ -71,7 +69,7 @@ lint: licensecheck go-lint oas-lint

#? crd: Generates CRD using controller-gen
.PHONY: crd
crd: controller-gen
crd: controller-gen-install
${CONTROLLER_GEN} crd:crdVersions=v1 paths="./endpoint/..." output:crd:stdout > docs/contributing/crd-source/crd-manifest.yaml

#? test: The verify target runs tasks similar to the CI tasks, but without code coverage
Expand Down
95 changes: 95 additions & 0 deletions scripts/install-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env bash

# Copyright 2025 The Kubernetes Authors.
#
# 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.

# renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools
CONTROLLER_TOOLS_GENERATOR_VERSION=v0.15.0
# renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANG_CI_LINTER_VERSION=v2.0.2

# Execute
# scripts/install-tools.sh
# scripts/install-tools.sh -h
# scripts/install-tools.sh --generator
# scripts/install-tools.sh --golangci

show_help() {
cat << EOF
'external-dns' helm linter helper commands

Usage: $(basename "$0") <options>
-h, --help Display help
--generator Install generator
--golangci Install golangci linter
EOF
}

install_generator() {
# https://github.com/kubernetes-sigs/controller-tools/blob/main/cmd/controller-gen/main.go
local install=false
if [[ -x $(which controller-gen) ]]; then
local version=$(controller-gen --version | sed 's/Version: //')
if [[ "${version}" == "${CONTROLLER_TOOLS_GENERATOR_VERSION}" ]]; then
install=false
else
install=true
fi
else
install=true
fi
if [[ "$install" == true ]]; then
set -ex ;\
go install sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_TOOLS_GENERATOR_VERSION} ;
fi
}

install_golangci() {
local install=false
if [[ -x $(which golangci-lint) ]]; then
local version=$(golangci-lint version --short)
if [[ "${version}" == "${GOLANG_CI_LINTER_VERSION#v}" ]]; then
install=false
else
install=true
fi
else
install=true
fi
if [[ "$install" == true ]]; then
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/cc3567e3127d8530afb69be1b7bd20ba9ebcc7c1/install.sh \
| sh -s -- -b $(go env GOPATH)/bin "${GOLANG_CI_LINTER_VERSION}"
fi
}

function main() {
case $1 in
--generator)
install_generator
;;
--golangci)
install_golangci
;;
-h|--help)
show_help
;;
*)
echo "unknown sub-command" >&2
show_help
exit 1
;;
esac
}

main "$@"
Loading