Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpk: bring back Makefile and add support for internal topics in describe #23487

Merged
merged 2 commits into from
Sep 27, 2024
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
90 changes: 90 additions & 0 deletions src/go/rpk/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copyright 2024 Redpanda Data, Inc.
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.md
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0

GOCMD=go
GOLANGCILINTCMD=golangci-lint
GOFUMPTCMD=gofumpt
BAZELCMD=bazel

GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
OUTDIR := $(GOOS)-$(GOARCH)

REV := $(shell git rev-parse --short HEAD)
VER := $(or $(VERSION),local-dev)
IMG_TAG:= $(or $(VERSION),latest)
BUILD_TIME=$(shell date -Iseconds)
VER_PKG='github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version'
CONT_PKG='github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common'

LDFLAGS=-X $(VER_PKG).version=$(VER) -X $(VER_PKG).rev=$(REV) -X $(CONT_PKG).tag=$(IMG_TAG) -X ${VER_PKG}.hostOs=${GOOS} -X ${VER_PKG}.hostArch=${GOARCH} -X ${VER_PKG}.buildTime=${BUILD_TIME}

all: help

ready: build test fmt lint bazel check_diff ## Runs all. Ensures commit is ready.

build: ## Build rpk.
$(shell mkdir -p $(OUTDIR))
$(GOCMD) build -ldflags '$(LDFLAGS)' -o $(OUTDIR) ./...

test: ## Run rpk unit tests.
$(GOCMD) test ./... -count=1

tidy: ## Run go mod tidy.
$(GOCMD) mod tidy

lint: install_golangci_lint run_linter ## Run golangci-lint linter.

fmt: install_gofumpt run_gofumpt ## Run Gofumpt formatter.

bazel: install_bazelisk bazel_generate_build bazel_tidy ## Autogenerates BUILD files and resolve bazel dependencies.

install_gofumpt:
@echo "installing gofumpt..."
@$(GOCMD) install mvdan.cc/gofumpt@latest

run_gofumpt:
@echo "running gofumpt"
$(shell find -type f -name '*.go' | xargs -n1 $(GOFUMPTCMD) -w)

install_golangci_lint:
@echo "installing golangci-lint"
@$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

run_linter:
$(GOLANGCILINTCMD) run

install_bazelisk:
@echo "installing bazelisk"
@$(GOCMD) install github.com/bazelbuild/bazelisk@latest

bazel_generate_build: install_bazelisk
@$(BAZELCMD) run //:gazelle

bazel_tidy: install_bazelisk
@$(BAZELCMD) mod tidy

check_diff:
git diff --exit-code

GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)

help: ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)
2 changes: 1 addition & 1 deletion src/go/rpk/pkg/cli/topic/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func parseKVs(in []string) (map[string]string, error) {

func regexTopics(adm *kadm.Client, expressions []string) ([]string, error) {
// Now we list all topics to match against our expressions.
topics, err := adm.ListTopics(context.Background())
topics, err := adm.ListTopicsWithInternal(context.Background())
if err != nil {
return nil, fmt.Errorf("unable to list topics: %w", err)
}
Expand Down
Loading