This document explains how to integrate the telco5g-konflux project as a submodule in your repository to reuse the linting targets, catalog management scripts, and utility scripts.
The telco5g-konflux project provides:
- Linting targets: Standardized linting for YAML files and shell scripts
- Download scripts: Parameterizable scripts for downloading common tools (yq, opm, jq, operator-sdk)
- Catalog management: Konflux-specific targets for catalog template validation and generation
- Python virtual environment: Isolated Python dependencies for linting tools
-
Add the submodule to your repository:
git submodule add https://github.com/openshift-kni/telco5g-konflux.git telco5g-konflux git submodule update --init --recursive
-
Include the Makefile in your root Makefile:
# Include linting targets from submodule include scripts/Makefile
lint: Run all linters (yamllint, shellcheck, bashate)yamllint: Run YAML linting using yamllintshellcheck: Run shell script linting using shellcheck-py (errors only)bashate: Run bash style linting using bashate (ignores E006 line length)venv: Create Python virtual environment with linting dependenciesclean: Remove virtual environment and generated artifacts
update-catalog-template: Update catalog template using bundle buildsvalidate-production-images: Validate related images for productionkonflux-validate-catalog-template-bundle: Validate the last bundle entry on the catalog template filekonflux-validate-catalog: Validate the current catalog file using opmkonflux-generate-catalog: Generate a quay.io catalog from templatekonflux-generate-catalog-production: Generate a registry.redhat.io catalog with production overlays
help: Display available targets and descriptions
The submodule includes a requirements.txt file with pinned versions:
bashate==2.1.0
shellcheck-py==0.10.0.1
yamllint==1.35.1
Place a .yamllint.yaml file in your repository root to configure yamllint:
extends: default
rules:
line-length:
max: 120
document-start: disable
truthy: disableThe submodule provides parameterizable download scripts for common tools with automatic dependency management:
scripts/download/download-yq.sh: Download and install yq (YAML processor)scripts/download/download-opm.sh: Download and install opm (Operator Package Manager)scripts/download/download-jq.sh: Download and install jq (JSON processor)scripts/download/download-operator-sdk.sh: Download and install operator-sdk from OpenShift mirror
The scripts/download/Makefile provides convenient targets for downloading tools:
# Download individual tools
make -f scripts/download/Makefile download-yq
make -f scripts/download/Makefile download-opm
make -f scripts/download/Makefile download-jq
make -f scripts/download/Makefile download-operator-sdk
# Download all tools
make -f scripts/download/Makefile download-all
# Clean downloaded tools
make -f scripts/download/Makefile cleanThe scripts/catalog/Makefile provides targets for catalog management with automatic tool dependency resolution:
# Run catalog targets (tools are automatically downloaded if needed)
make -f scripts/catalog/Makefile konflux-validate-catalog-template-bundle
make -f scripts/catalog/Makefile konflux-validate-catalog
make -f scripts/catalog/Makefile konflux-generate-catalog
make -f scripts/catalog/Makefile konflux-generate-catalog-production./scripts/download/download-yq.sh # Install yq v4.45.4 to scripts/bin
./scripts/download/download-opm.sh # Install opm v1.52.0 to scripts/bin
./scripts/download/download-jq.sh # Install jq 1.7.1 to scripts/bin
./scripts/download/download-operator-sdk.sh # Install operator-sdk for OpenShift 4.12 to scripts/bin./scripts/download/download-yq.sh v4.44.2 # Install specific yq version
./scripts/download/download-opm.sh v1.51.0 # Install specific opm version
./scripts/download/download-jq.sh 1.6 # Install specific jq version
./scripts/download/download-operator-sdk.sh v1.38.0 # Install operator-sdk for OpenShift 4.13 (latest)# Using command line option
./scripts/download/download-yq.sh -d /usr/local/bin v4.44.2
./scripts/download/download-opm.sh --install-dir /opt/tools v1.51.0
./scripts/download/download-operator-sdk.sh -d /opt/tools v1.38.0
# Using environment variable
INSTALL_DIR=/opt/bin ./scripts/download/download-yq.sh v4.44.2
INSTALL_DIR=/usr/local/bin ./scripts/download/download-opm.sh
INSTALL_DIR=/opt/tools ./scripts/download/download-operator-sdk.sh v1.38.0./scripts/download/download-yq.sh --help # Show detailed usage information
./scripts/download/download-opm.sh --help # Show detailed usage information
./scripts/download/download-jq.sh --help # Show detailed usage information
./scripts/download/download-operator-sdk.sh --help # Show detailed usage informationThe submodule includes scripts for managing operator catalogs with Konflux:
You can customize catalog operations using these variables:
# File paths
CATALOG_TEMPLATE_FILE ?= .konflux/catalog/catalog-template.in.yaml
BUNDLE_BUILDS_FILE ?= .konflux/catalog/bundle.builds.in.yaml
CATALOG_FILE ?= catalog.yaml
# Konflux-specific variables
CATALOG_TEMPLATE_KONFLUX ?= $(CATALOG_TEMPLATE_FILE)
CATALOG_KONFLUX ?= $(CATALOG_FILE)
PACKAGE_NAME_KONFLUX ?= telco5g-konflux
# Bundle image configuration - can be overridden for different operators
QUAY_TENANT_NAME ?= telco-5g-tenant
BUNDLE_NAME_SUFFIX ?= operator-bundle-4-20
PRODUCTION_NAMESPACE ?= openshift4
PRODUCTION_BUNDLE_NAME ?= operator-bundle
# Constructed bundle image names
QUAY_BUNDLE_IMAGE ?= quay.io/redhat-user-workloads/$(QUAY_TENANT_NAME)/$(PACKAGE_NAME_KONFLUX)-$(BUNDLE_NAME_SUFFIX)
PRODUCTION_BUNDLE_IMAGE ?= registry.redhat.io/$(PRODUCTION_NAMESPACE)/$(PACKAGE_NAME_KONFLUX)-$(PRODUCTION_BUNDLE_NAME)
# Tool versions
OPENSHIFT_VERSION ?= 4.12# Validate catalog template bundle
make -f scripts/catalog/Makefile konflux-validate-catalog-template-bundle
# Generate catalogs
make -f scripts/catalog/Makefile konflux-generate-catalog # quay.io catalog
make -f scripts/catalog/Makefile konflux-generate-catalog-production # registry.redhat.io catalog
# Validate catalog
make -f scripts/catalog/Makefile konflux-validate-catalog
# Custom package name
make -f scripts/catalog/Makefile konflux-generate-catalog PACKAGE_NAME_KONFLUX=my-operator
# Custom OpenShift version for operator-sdk
make -f scripts/catalog/Makefile konflux-validate-catalog-template-bundle OPENSHIFT_VERSION=4.13
# Bundle image customization for different operators
make -f scripts/catalog/Makefile konflux-generate-catalog-production PACKAGE_NAME_KONFLUX=my-operator
make -f scripts/catalog/Makefile konflux-generate-catalog-production QUAY_TENANT_NAME=my-tenant
make -f scripts/catalog/Makefile konflux-generate-catalog-production BUNDLE_NAME_SUFFIX=operator-bundle-4-21
make -f scripts/catalog/Makefile konflux-generate-catalog-production PRODUCTION_NAMESPACE=ubi8Here's an example of how to integrate in your root Makefile:
# Your existing Makefile content...
# Include linting targets from submodule
include scripts/Makefile
# Custom target that depends on linting
.PHONY: ci
ci: lint
@echo "Running CI after linting passes..."
go test ./...
go build ./...
# Custom linting that extends the base linting
.PHONY: lint-extended
lint-extended: lint
@echo "Running additional linting..."
golangci-lint run
hadolint Dockerfile
# Download tools to a custom directory
.PHONY: install-tools
install-tools:
$(MAKE) -f scripts/download/Makefile download-all DOWNLOAD_INSTALL_DIR=./bin
# Use tools with specific versions
.PHONY: install-legacy-tools
install-legacy-tools:
$(MAKE) -f scripts/download/Makefile download-yq DOWNLOAD_YQ_VERSION=v4.35.2 DOWNLOAD_INSTALL_DIR=./bin
$(MAKE) -f scripts/download/Makefile download-jq DOWNLOAD_JQ_VERSION=1.6.0 DOWNLOAD_INSTALL_DIR=./bin
# Catalog management integration
.PHONY: validate-catalog
validate-catalog:
$(MAKE) -f scripts/catalog/Makefile konflux-validate-catalog-template-bundle
$(MAKE) -f scripts/catalog/Makefile konflux-validate-catalog
.PHONY: generate-catalog
generate-catalog:
$(MAKE) -f scripts/catalog/Makefile konflux-generate-catalog PACKAGE_NAME_KONFLUX=my-operatorWhen using as a submodule, the directory structure should look like:
your-repo/
├── Makefile # Your root Makefile
├── .yamllint.yaml # YAML linting configuration (optional)
├── scripts/ # Submodule directory
│ ├── Makefile # Main linting Makefile
│ ├── requirements.txt # Python linting dependencies
│ ├── venv/ # Virtual environment (created automatically)
│ ├── bin/ # Default tool installation directory
│ │ ├── yq # Downloaded tools (if using scripts)
│ │ ├── opm
│ │ ├── jq
│ │ └── operator-sdk
│ ├── catalog/ # Catalog management scripts
│ │ ├── Makefile # Catalog-specific Makefile
│ │ ├── konflux-update-catalog-template.sh
│ │ ├── konflux-validate-related-images-production.sh
│ │ └── ...
│ └── download/ # Download scripts
│ ├── Makefile # Download-specific Makefile
│ ├── download-yq.sh
│ ├── download-opm.sh
│ ├── download-jq.sh
│ └── download-operator-sdk.sh
└── .konflux/ # Konflux configuration (if using catalog features)
└── catalog/
├── catalog-template.in.yaml
├── bundle.builds.in.yaml
└── ...
The linting targets use these environment variables (automatically configured):
TELCO5G_KONFLUX_DIR: Submodule directory pathTELCO5G_KONFLUX_VENV: Python virtual environment pathTELCO5G_KONFLUX_BIN: Virtual environment bin directory
Download scripts and Makefiles support:
DOWNLOAD_INSTALL_DIR: Custom installation directory for all toolsDOWNLOAD_YQ_VERSION: Custom yq version (default: v4.45.4)DOWNLOAD_OPM_VERSION: Custom opm version (default: v1.52.0)DOWNLOAD_JQ_VERSION: Custom jq version (default: 1.7.1)DOWNLOAD_OPENSHIFT_VERSION: Custom OpenShift version for operator-sdk (default: 4.12)
Catalog scripts support:
CATALOG_TEMPLATE_FILE: Path to catalog template fileBUNDLE_BUILDS_FILE: Path to bundle builds fileCATALOG_FILE: Path to catalog filePACKAGE_NAME_KONFLUX: Package name for Konflux operationsOPENSHIFT_VERSION: OpenShift version for operator-sdk downloadsTOOL_DIR: Directory for downloaded tools
QUAY_TENANT_NAME: Quay tenant name (default: telco-5g-tenant)BUNDLE_NAME_SUFFIX: Bundle name suffix (default: operator-bundle-4-20)PRODUCTION_NAMESPACE: Production namespace (default: openshift4)PRODUCTION_BUNDLE_NAME: Production bundle name (default: operator-bundle)QUAY_BUNDLE_IMAGE: Full quay bundle image (constructed from above variables)PRODUCTION_BUNDLE_IMAGE: Full production bundle image (constructed from above variables)
- Standardized Linting: Consistent linting rules and tools across repositories
- Dependency Management: Isolated Python environment with pinned linting tool versions
- Tool Management: Parameterizable scripts for downloading common tools with automatic dependency resolution
- Catalog Management: Konflux-specific targets for catalog operations
- Intelligent Version Discovery: Automatic latest release detection for operator-sdk
- Cross-Platform Support: Works on both macOS and Linux
- Easy Updates: Centralized updates to linting configurations and tool versions
- Flexibility: Customize install directories and tool versions per project
- No Conflicts: Isolated virtual environment prevents conflicts with system tools
To update the submodule to the latest version:
git submodule update --remote scripts
git add scripts
git commit -m "Update scripts submodule to latest version"Create a .yamllint.yaml file in your repository root to customize YAML linting:
extends: default
rules:
line-length:
max: 150
comments:
min-spaces-from-content: 1Pin specific tool versions using Makefile variables:
.PHONY: install-pinned-tools
install-pinned-tools:
$(MAKE) -f scripts/download/Makefile download-all \
DOWNLOAD_YQ_VERSION=v4.35.2 \
DOWNLOAD_OPM_VERSION=v1.50.0 \
DOWNLOAD_JQ_VERSION=1.6.0 \
DOWNLOAD_OPENSHIFT_VERSION=4.12.76 \
DOWNLOAD_INSTALL_DIR=./toolsInstall tools to project-specific directories:
TOOL_DIR := $(PWD)/tools
.PHONY: install-project-tools
install-project-tools:
mkdir -p $(TOOL_DIR)
$(MAKE) -f scripts/download/Makefile download-all DOWNLOAD_INSTALL_DIR=$(TOOL_DIR)Customize catalog operations:
.PHONY: custom-catalog-validation
custom-catalog-validation:
$(MAKE) -f scripts/catalog/Makefile konflux-validate-catalog-template-bundle \
CATALOG_TEMPLATE_KONFLUX=./custom-catalog-template.yaml \
PACKAGE_NAME_KONFLUX=my-custom-operator \
OPENSHIFT_VERSION=4.13
.PHONY: custom-catalog-production
custom-catalog-production:
$(MAKE) -f scripts/catalog/Makefile konflux-generate-catalog-production \
PACKAGE_NAME_KONFLUX=my-custom-operator \
QUAY_TENANT_NAME=my-tenant \
BUNDLE_NAME_SUFFIX=operator-bundle-4-21 \
PRODUCTION_NAMESPACE=ubi8 \
PRODUCTION_BUNDLE_NAME=my-operator-bundle
.PHONY: custom-bundle-images
custom-bundle-images:
$(MAKE) -f scripts/catalog/Makefile konflux-generate-catalog-production \
QUAY_BUNDLE_IMAGE=quay.io/my-org/my-operator-bundle:v1.0.0 \
PRODUCTION_BUNDLE_IMAGE=registry.redhat.io/my-namespace/my-operator-bundle:v1.0.0If linting fails:
- Check the specific linter output for details
- Fix the reported issues in your YAML or shell scripts
- Customize linting rules if needed (e.g.,
.yamllint.yaml)
If the Python virtual environment has issues:
make clean # Remove the virtual environment
make venv # Recreate itIf download scripts fail:
- Check internet connectivity
- Verify the version exists on the project's releases or mirror
- Ensure you have write permissions to the install directory
- Use
--helpto verify correct usage - For operator-sdk, check OpenShift mirror availability
If catalog operations fail:
- Ensure required files exist (catalog template, bundle builds)
- Check that tools are available (yq, opm, operator-sdk)
- Verify OpenShift version is supported
- Use
make helpto see available targets and variables
If operator-sdk version discovery fails:
- Check internet connectivity to OpenShift mirror
- Verify the OpenShift version exists on the mirror
- Try using a full version (X.Y.Z) instead of Major.Minor (X.Y)
- Check the mirror URL: https://mirror.openshift.com/pub/openshift-v4/