Skip to content

🐛 Revert "Make kubebuilder go install-able" #4576

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

Merged
merged 1 commit into from
Feb 21, 2025
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
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ help: ## Display this help
##@ Build

LD_FLAGS=-ldflags " \
-X cmd.kubeBuilderVersion=$(shell git describe --tags --dirty --broken) \
-X cmd.goos=$(shell go env GOOS) \
-X cmd.goarch=$(shell go env GOARCH) \
-X cmd.gitCommit=$(shell git rev-parse HEAD) \
-X cmd.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
-X main.kubeBuilderVersion=$(shell git describe --tags --dirty --broken) \
-X main.goos=$(shell go env GOOS) \
-X main.goarch=$(shell go env GOARCH) \
-X main.gitCommit=$(shell git rev-parse HEAD) \
-X main.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
"
.PHONY: build
build: ## Build the project locally
go build $(LD_FLAGS) -o bin/kubebuilder
go build $(LD_FLAGS) -o bin/kubebuilder ./cmd

.PHONY: install
install: build ## Build and install the binary with the current source code. Use it to test your changes locally.
Expand Down
13 changes: 7 additions & 6 deletions build/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ before:
# Build a binary for each target in targets.
builds:
- id: kubebuilder
main: ./cmd
binary: kubebuilder
mod_timestamp: "{{ .CommitTimestamp }}"
ldflags:
- -X cmd.kubeBuilderVersion={{ .Version }}
- -X cmd.goos={{ .Os }}
- -X cmd.goarch={{ .Arch }}
- -X cmd.gitCommit={{ .Commit }}
- -X cmd.buildDate={{ .Date }}
- -X cmd.kubernetesVendorVersion={{ .Env.KUBERNETES_VERSION }}
- -X main.kubeBuilderVersion={{ .Version }}
- -X main.goos={{ .Os }}
- -X main.goarch={{ .Arch }}
- -X main.gitCommit={{ .Commit }}
- -X main.buildDate={{ .Date }}
- -X main.kubernetesVendorVersion={{ .Env.KUBERNETES_VERSION }}
targets:
- linux_amd64
- linux_arm64
Expand Down
5 changes: 2 additions & 3 deletions cmd/cmd.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd
package main

import (
"github.com/sirupsen/logrus"
Expand All @@ -36,8 +36,7 @@ func init() {
logrus.SetFormatter(&logrus.TextFormatter{DisableTimestamp: true})
}

// Run bootstraps & runs the CLI
func Run() {
func main() {
// Bundle plugin which built the golang projects scaffold with base.go/v4 and kustomize/v2 plugins
gov4Bundle, _ := plugin.NewBundleWithOptions(plugin.WithName(golang.DefaultNameQualifier),
plugin.WithVersion(plugin.Version{Number: 4}),
Expand Down
19 changes: 5 additions & 14 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd
package main

import (
"fmt"
"runtime/debug"
)

const unknown = "unknown"

// var needs to be used instead of const as ldflags is used to fill this
// information in the release process
var (
kubeBuilderVersion = unknown
kubernetesVendorVersion = unknown
goos = unknown
goarch = unknown
kubeBuilderVersion = "unknown"
kubernetesVendorVersion = "unknown"
goos = "unknown"
goarch = "unknown"
gitCommit = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD)

buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
Expand All @@ -47,12 +44,6 @@ type version struct {

// versionString returns the CLI version
func versionString() string {
if kubeBuilderVersion == unknown {
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" {
kubeBuilderVersion = info.Main.Version
}
}

return fmt.Sprintf("Version: %#v", version{
kubeBuilderVersion,
kubernetesVendorVersion,
Expand Down
23 changes: 0 additions & 23 deletions main.go

This file was deleted.

2 changes: 1 addition & 1 deletion test/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:-""}
function build_kb {
header_text "Building kubebuilder"

go build -o "${kb_root_dir}/bin/kubebuilder"
go build -o "${kb_root_dir}/bin/kubebuilder" ./cmd
kb="${kb_root_dir}/bin/kubebuilder"
}

Expand Down
Loading