Skip to content

Commit e964202

Browse files
runtime list command (#16)
* runtime list command * up * Update cmd/commands/runtime.go Co-authored-by: Noam Gal <noam.gal@codefresh.io> * update sdk * wip * bump * wip * wip * codegen Co-authored-by: Noam Gal <noam.gal@codefresh.io>
1 parent 9e7eaf6 commit e964202

File tree

8 files changed

+107
-4
lines changed

8 files changed

+107
-4
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ RUN adduser \
1313
--uid 10001 \
1414
codefresh
1515

16+
ARG GITHUB_TOKEN
17+
RUN git config \
18+
--global \
19+
url."https://github:${GITHUB_TOKEN}@github.com".insteadOf \
20+
"https://github.com"
1621
COPY go.mod .
1722
COPY go.sum .
1823

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.21
1+
VERSION=v0.0.23
22
OUT_DIR=dist
33
YEAR?=$(shell date +"%Y")
44

cmd/commands/runtime.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ package commands
1717
import (
1818
"context"
1919
"fmt"
20+
"os"
2021
"time"
2122

2223
"github.com/codefresh-io/cli-v2/pkg/cdUtils"
2324
"github.com/codefresh-io/cli-v2/pkg/eventUtils"
2425
"github.com/codefresh-io/cli-v2/pkg/log"
2526
"github.com/codefresh-io/cli-v2/pkg/store"
2627
"github.com/codefresh-io/cli-v2/pkg/util"
28+
"github.com/juju/ansiterm"
2729

2830
appset "github.com/argoproj-labs/applicationset/api/v1alpha1"
2931
apcmd "github.com/argoproj-labs/argocd-autopilot/cmd/commands"
@@ -74,6 +76,7 @@ func NewRuntimeCommand() *cobra.Command {
7476
}
7577

7678
cmd.AddCommand(NewRuntimeCreateCommand())
79+
cmd.AddCommand(NewRuntimeListCommand())
7780
cmd.AddCommand(NewRuntimeDeleteCommand())
7881

7982
return cmd
@@ -195,6 +198,65 @@ func RunRuntimeCreate(ctx context.Context, opts *RuntimeCreateOptions) error {
195198
return nil
196199
}
197200

201+
func NewRuntimeListCommand() *cobra.Command {
202+
203+
204+
cmd := &cobra.Command{
205+
Use: "list ",
206+
Short: "List all Codefresh runtimes",
207+
Example: util.Doc(`<BIN> runtime list`),
208+
RunE: func(cmd *cobra.Command, args []string) error {
209+
return listRuntimes(cmd.Context())
210+
},
211+
}
212+
return cmd
213+
}
214+
215+
func listRuntimes(ctx context.Context) error {
216+
runtimes, err := cfConfig.NewClient().ArgoRuntime().List()
217+
if err != nil {
218+
return err
219+
}
220+
tb := ansiterm.NewTabWriter(os.Stdout, 0, 0, 4, ' ', 0)
221+
_, err = fmt.Fprintln(tb, "NAME\tNAMESPACE\tCLUSTER\tSTATUS\tVERSION")
222+
if err != nil {
223+
return err
224+
}
225+
for _, rt := range runtimes {
226+
status := "N/A"
227+
namespace:= "N/A"
228+
name := "N/A"
229+
cluster := "N/A"
230+
version := "N/A"
231+
if rt.Status != nil {
232+
status = rt.Status.String()
233+
}
234+
if rt.Namespace != nil {
235+
namespace = *rt.Namespace
236+
}
237+
if rt.ObjectMeta != nil && rt.ObjectMeta.Name != nil {
238+
name = *rt.ObjectMeta.Name
239+
}
240+
if rt.Cluster != nil {
241+
cluster = *rt.Cluster
242+
}
243+
if rt.Version != nil {
244+
version = *rt.Version
245+
}
246+
_, err = fmt.Fprintf(tb, "%s\t%s\t%s\t%s\t%s\n",
247+
name,
248+
namespace,
249+
cluster,
250+
status,
251+
version,
252+
)
253+
if err != nil {
254+
return err
255+
}
256+
}
257+
return tb.Flush()
258+
}
259+
198260
func NewRuntimeDeleteCommand() *cobra.Command {
199261
var (
200262
f kube.Factory

docs/commands/cli-v2_runtime.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ cli-v2 runtime [flags]
2626
* [cli-v2](cli-v2.md) - cli-v2 is used for installing and managing codefresh installations using gitops
2727
* [cli-v2 runtime create](cli-v2_runtime_create.md) - Create a new Codefresh runtime
2828
* [cli-v2 runtime delete](cli-v2_runtime_delete.md) - Deletes a Codefresh runtime
29+
* [cli-v2 runtime list](cli-v2_runtime_list.md) - List all Codefresh runtimes
2930

docs/commands/cli-v2_runtime_list.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## cli-v2 runtime list
2+
3+
List all Codefresh runtimes
4+
5+
```
6+
cli-v2 runtime list [flags]
7+
```
8+
9+
### Examples
10+
11+
```
12+
cli-v2 runtime list
13+
```
14+
15+
### Options
16+
17+
```
18+
-h, --help help for list
19+
```
20+
21+
### Options inherited from parent commands
22+
23+
```
24+
--auth-context string Run the next command using a specific authentication context
25+
--cfconfig string Custom path for authentication contexts config file (default "/home/user")
26+
--insecure Disable certificate validation for TLS connections (e.g. to g.codefresh.io)
27+
--request-timeout duration Request timeout (default 30s)
28+
```
29+
30+
### SEE ALSO
31+
32+
* [cli-v2 runtime](cli-v2_runtime.md) - Manage Codefresh runtimes
33+

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/argoproj/argo-events v1.3.1
1010
github.com/argoproj/argo-workflows/v3 v3.1.0
1111
github.com/briandowns/spinner v1.13.0
12-
github.com/codefresh-io/go-sdk v0.26.2
12+
github.com/codefresh-io/go-sdk v0.26.5
1313
github.com/fatih/color v1.12.0
1414
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
1515
github.com/go-git/go-billy/v5 v5.3.1

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,10 @@ github.com/clusterhq/flocker-go v0.0.0-20160920122132-2b8b7259d313/go.mod h1:P1w
257257
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
258258
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
259259
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
260-
github.com/codefresh-io/go-sdk v0.26.2 h1:nGiLEOXaYGd7DbwKpqeTm1XXVCATayQm/pU3DwA6wqc=
261-
github.com/codefresh-io/go-sdk v0.26.2/go.mod h1:0m0ATMmbFzvrc3CwUTB10MGO6hydsZdzLeHCAOyAvyM=
260+
github.com/codefresh-io/argo-platform v1.13.0 h1:eWAWkxtO0nGZuekrQJsfFT5KfBMdWby0cOucy4yTExs=
261+
github.com/codefresh-io/argo-platform v1.13.0/go.mod h1:u/eLWAySJ1nRzNWnB5baeyIc5vqINghwYJvydU+EC3c=
262+
github.com/codefresh-io/go-sdk v0.26.5 h1:3apUfIyE4BSGWAwTGwO0yeP0XF4P3VKh7sOqwlDyRSs=
263+
github.com/codefresh-io/go-sdk v0.26.5/go.mod h1:WxoYUrd9ZF7yvBohEdQfANEhD59a7eq6DNOkbpLP7Lw=
262264
github.com/colinmarc/hdfs v1.1.4-0.20180802165501-48eb8d6c34a9/go.mod h1:0DumPviB681UcSuJErAbDIOx6SIaJWj463TymfZG02I=
263265
github.com/colinmarc/hdfs v1.1.4-0.20180805212432-9746310a4d31/go.mod h1:vSBumefK4HA5uiRSwNP+3ofgrEoScpCS2MMWcWXEuQ4=
264266
github.com/container-storage-interface/spec v1.3.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=

out.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)