Skip to content

Commit 573bae5

Browse files
authored
Fix version flags in builds (#402)
* fix version flags in builds * fix npe
1 parent e1294ba commit 573bae5

5 files changed

Lines changed: 26 additions & 7 deletions

File tree

.github/workflows/goreleaser.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
go-version: v1.25.4
2626
- name: Delete non-semver tags
2727
run: 'git tag -d $(git tag -l | grep -v "^v")'
28+
- name: Set LDFLAGS
29+
run: echo LDFLAGS="$(make ldflags)" >> $GITHUB_ENV
2830
- name: Run GoReleaser on tag
2931
if: github.event_name != 'pull_request'
3032
uses: goreleaser/goreleaser-action@v3

.goreleaser.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
version: 2
2+
3+
git:
4+
tag_sort: -version:refname
5+
ignore_tags:
6+
- "cli/*"
7+
- "sdk/*"
8+
29
builds:
310
- id: "kubectl-bind"
411
dir: cli
512
main: ./cmd/kubectl-bind
613
binary: bin/kubectl-bind
14+
ldflags:
15+
- "{{ .Env.LDFLAGS }}"
716
goos:
817
- linux
918
- darwin

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ helm-build-local: ## Build and package Helm charts locally for testing
482482
helm-clean: ## Clean up built helm charts
483483
rm -f ./bin/*.tgz
484484

485+
.PHONY: goreleaser-test
486+
goreleaser-test: ## Test GoReleaser flow locally
487+
@command -v goreleaser >/dev/null 2>&1 || { echo "goreleaser not found. Install from: https://goreleaser.com/install/"; exit 1; }
488+
LDFLAGS="$(LDFLAGS)" goreleaser release --snapshot --clean
489+
485490
.PHONY: helm-push-local
486491
helm-push-local: ## Push Helm charts to IMAGE_REPO registry
487492
@echo "Pushing Helm charts to registry: $(IMAGE_REPO)"

docs/content/setup/kubectl-plugin.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ The `kubectl bind` plugin is the primary command-line interface for interacting
3535

3636
```bash
3737
# Download and install for Linux/macOS
38-
curl -LO https://github.com/kube-bind/kube-bind/releases/latest/download/kubectl-bind-linux-amd64
39-
chmod +x kubectl-bind-linux-amd64
40-
sudo mv kubectl-bind-linux-amd64 /usr/local/bin/kubectl-bind
38+
OS=$(uname | tr '[:upper:]' '[:lower:]')
39+
ARCH=$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
40+
VERSION=$(curl -s https://api.github.com/repos/kube-bind/kube-bind/releases/latest | grep '"tag_name"' | cut -d'"' -f4)
41+
curl -LO https://github.com/kube-bind/kube-bind/releases/download/${VERSION}/kubectl-bind_${VERSION#v}_${OS}_${ARCH}.tar.gz
42+
tar -xzf kubectl-bind_${VERSION#v}_${OS}_${ARCH}.tar.gz
43+
sudo mv bin/kubectl-bind /usr/local/bin/kubectl-bind
4144
```
4245

4346
## Basic Usage

pkg/konnector/controllers/cluster/serviceexport/status/status_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (c *controller) enqueueProvider(logger klog.Logger, obj any) {
185185
// Try to map the provider name back to the consumer name,
186186
// but only to check if we "own" the object; we will actually
187187
// enqueue the provider key after all.
188-
consumerKey, err := c.isolationStrategy.ToConsumerKey(types.NamespacedName{
188+
consumerKey, err := c.reconciler.isolationStrategy.ToConsumerKey(types.NamespacedName{
189189
Namespace: ns,
190190
Name: name,
191191
})
@@ -216,7 +216,7 @@ func (c *controller) enqueueConsumer(logger klog.Logger, obj any) {
216216
return
217217
}
218218

219-
providerKey, err := c.isolationStrategy.ToProviderKey(types.NamespacedName{
219+
providerKey, err := c.reconciler.isolationStrategy.ToProviderKey(types.NamespacedName{
220220
Namespace: ns,
221221
Name: name,
222222
})
@@ -250,7 +250,7 @@ func (c *controller) enqueueServiceNamespace(logger klog.Logger, obj any) {
250250
return // not for us
251251
}
252252

253-
strategy := c.isolationStrategy.(*isolation.ServiceNamespacedStrategy)
253+
strategy := c.reconciler.isolationStrategy.(*isolation.ServiceNamespacedStrategy)
254254
nsOnProviderCluster, err := strategy.ProviderNamespace(name)
255255
if err != nil {
256256
runtime.HandleError(err)
@@ -289,7 +289,7 @@ func (c *controller) Start(ctx context.Context, numThreads int) {
289289
// APIServiceNamespaces are only of interest when syncing namespaced
290290
// objects, and since these event handlers need the appropriate isolation
291291
// strategy, we only start them when necessary.
292-
if _, ok := c.isolationStrategy.(*isolation.ServiceNamespacedStrategy); ok {
292+
if _, ok := c.reconciler.isolationStrategy.(*isolation.ServiceNamespacedStrategy); ok {
293293
c.serviceNamespaceInformer.Informer().AddDynamicEventHandler(ctx, controllerName, cache.ResourceEventHandlerFuncs{
294294
AddFunc: func(obj any) {
295295
c.enqueueServiceNamespace(logger, obj)

0 commit comments

Comments
 (0)