Skip to content

Commit 01969bf

Browse files
authored
Easy RX CLI Install (#87)
* move main and read build info * set version * tweaks * Tweak readme
1 parent 8f0dd69 commit 01969bf

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/vendor/*
1616
debug
1717
radix-cli
18-
rx
19-
rx-test
18+
/rx
19+
/rx-test
2020
.idea/
2121
.dccache

.goreleaser.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
builds:
44
- id: rx
55
binary: rx
6+
main: ./cli/rx
7+
68
env:
79
- CGO_ENABLED=0
810
goos:

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ COPY . /app
1818
RUN addgroup -S -g 1000 radix && adduser -S -u 1000 -G radix radix
1919

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

2323
## Run operator
2424
FROM scratch

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Radix CLI in the [Radix documentation](https://radix.equinor.com/docs/topic-radi
66

77
## Installation
88

9+
### If using Go:
10+
```sh
11+
go install github.com/equinor/radix-cli/cli/rx@latest
12+
```
13+
914
### Linux or Mac
1015

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

168173
```
169-
CGO_ENABLED=0 GOOS=darwin go build -ldflags "-s -w" -a -installsuffix cgo -o ./rx
174+
CGO_ENABLED=0 GOOS=darwin go build -ldflags "-s -w" -a -installsuffix cgo -o ./rx ./cli/rx
170175
```
171176

172177
### Security

main.go cli/rx/main.go

File renamed without changes.

cmd/root.go

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8+
"runtime/debug"
89
"strings"
910
"time"
1011

@@ -38,6 +39,15 @@ func Execute() {
3839
}
3940
}
4041

42+
func init() {
43+
if Version == "dev" {
44+
if info, ok := debug.ReadBuildInfo(); ok {
45+
Version = info.Main.Version
46+
rootCmd.Version = info.Main.Version
47+
}
48+
}
49+
}
50+
4151
func setVerbosePersistentFlag(cmd *cobra.Command) *bool {
4252
return cmd.PersistentFlags().Bool(flagnames.Verbose, false, "Verbose output")
4353
}

0 commit comments

Comments
 (0)