Skip to content

Commit

Permalink
Easy RX CLI Install (#87)
Browse files Browse the repository at this point in the history
* move main and read build info

* set version

* tweaks

* Tweak readme
  • Loading branch information
Richard87 authored Mar 12, 2024
1 parent 8f0dd69 commit 01969bf
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/vendor/*
debug
radix-cli
rx
rx-test
/rx
/rx-test
.idea/
.dccache
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
builds:
- id: rx
binary: rx
main: ./cli/rx

env:
- CGO_ENABLED=0
goos:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ COPY . /app
RUN addgroup -S -g 1000 radix && adduser -S -u 1000 -G radix radix

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -a -installsuffix cgo -o ./rootfs/rx
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -a -installsuffix cgo -o ./rootfs/rx ./cli/rx

## Run operator
FROM scratch
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Radix CLI in the [Radix documentation](https://radix.equinor.com/docs/topic-radi

## Installation

### If using Go:
```sh
go install github.com/equinor/radix-cli/cli/rx@latest
```

### Linux or Mac

#### Binaries
Expand Down Expand Up @@ -166,7 +171,7 @@ We are making releases available as GitHub releases using [go-releaser](https://
To generate a local version for debugging purposes, it can be built using:

```
CGO_ENABLED=0 GOOS=darwin go build -ldflags "-s -w" -a -installsuffix cgo -o ./rx
CGO_ENABLED=0 GOOS=darwin go build -ldflags "-s -w" -a -installsuffix cgo -o ./rx ./cli/rx
```

### Security
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime/debug"
"strings"
"time"

Expand Down Expand Up @@ -38,6 +39,15 @@ func Execute() {
}
}

func init() {
if Version == "dev" {
if info, ok := debug.ReadBuildInfo(); ok {
Version = info.Main.Version
rootCmd.Version = info.Main.Version
}
}
}

func setVerbosePersistentFlag(cmd *cobra.Command) *bool {
return cmd.PersistentFlags().Bool(flagnames.Verbose, false, "Verbose output")
}
Expand Down

0 comments on commit 01969bf

Please sign in to comment.