Skip to content

Commit 6659d12

Browse files
authored
Enhance monoctl (#98)
* Cleanup config * Allow forcing authentication * add wide option * Enahnce output * Update kubeconfig with overwrite * Allow to create multiple rolebindings * Bump to go 1.19
1 parent 06a2fdc commit 6659d12

34 files changed

+383
-270
lines changed

.github/workflows/golang.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ name: Golang CI
1616

1717
on:
1818
push:
19-
branches: [ main, develop ]
20-
tags: [ '!*' ]
19+
branches: [main, develop]
20+
tags: ["!*"]
2121
pull_request:
22-
branches: [ main, develop ]
22+
branches: [main, develop]
2323

2424
env:
2525
GO_MODULE: github.com/finleap-connect/monoctl
26-
GO_VERSION: 1.18.x
26+
GO_VERSION: 1.19.x
2727
GINKGO_VERSION: v1.16.5
28-
GO_CI_LINT_VERSION: v1.46.1
28+
GO_CI_LINT_VERSION: v1.48.0
2929

3030
jobs:
3131
lint:
@@ -66,4 +66,4 @@ jobs:
6666
uses: coverallsapp/[email protected]
6767
with:
6868
github-token: ${{ secrets.github_token }}
69-
path-to-lcov: coverage.lcov
69+
path-to-lcov: coverage.lcov

.github/workflows/publish.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ name: Publish CI
1616

1717
on:
1818
push:
19-
tags: [ 'v*' ]
19+
tags: ["v*"]
2020

2121
env:
22-
GO_VERSION: 1.18.x
22+
GO_VERSION: 1.19.x
2323

2424
jobs:
2525
build:
@@ -29,8 +29,8 @@ jobs:
2929

3030
strategy:
3131
matrix:
32-
os: [ "linux", "osx", "win" ]
33-
32+
os: ["linux", "osx", "win"]
33+
3434
steps:
3535
- name: Install Go
3636
uses: actions/setup-go@v2

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ LATEST_TAG=$(shell git describe --tags $(LATEST_REV))
1111

1212
export
1313

14-
clean: go-clean tools-clean
15-
1614
# go
1715
include *go.mk
1816

cmd/monoctl/create/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"context"
1919
"errors"
2020
"fmt"
21-
"io/ioutil"
2221
"net/url"
22+
"os"
2323

2424
"github.com/finleap-connect/monoctl/cmd/monoctl/flags"
2525
"github.com/finleap-connect/monoctl/internal/config"
@@ -68,7 +68,7 @@ func NewCreateClusterCmd() *cobra.Command {
6868
displayName = name
6969
}
7070

71-
caCertBundle, err := ioutil.ReadFile(caCertBundleFile)
71+
caCertBundle, err := os.ReadFile(caCertBundleFile)
7272
if err != nil {
7373
return fmt.Errorf("failed to read CA certificates from '%s': %s", caCertBundleFile, err)
7474
}

cmd/monoctl/create/create.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func NewCreateCmd() *cobra.Command {
3131
cmd.AddCommand(NewCreateUserCmd())
3232
cmd.AddCommand(NewCreateClusterCmd())
3333
cmd.AddCommand(NewCreateTenantCmd())
34-
cmd.AddCommand(NewCreateKubeConfigCmd())
3534
cmd.AddCommand(NewCreateAPITokenCmd())
3635

3736
return cmd

cmd/monoctl/create/rolebinding.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ func NewCreateRoleBindingCmd() *cobra.Command {
3131
var resource string
3232

3333
cmd := &cobra.Command{
34-
Use: "rolebinding <EMAIL>",
34+
Use: "rolebinding <EMAIL> [<EMAIL>,...]",
3535
Short: "Create rolebinding.",
3636
Long: `Creates a rolebinding for the given user.`,
3737
Args: cobra.ExactArgs(1),
3838
RunE: func(cmd *cobra.Command, args []string) error {
3939
configManager := config.NewLoaderFromExplicitFile(flags.ExplicitFile)
4040
return auth_util.RetryOnAuthFail(cmd.Context(), configManager, func(ctx context.Context) error {
41-
return usecases.NewCreateRoleBindingUseCase(configManager.GetConfig(), args[0], role, scope, resource).Run(ctx)
41+
return usecases.NewCreateRoleBindingUseCase(configManager.GetConfig(), args, role, scope, resource).Run(ctx)
4242
})
4343
},
4444
}

cmd/monoctl/flags/flags.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ import "time"
1919
var (
2020
Timeout time.Duration
2121
ExplicitFile string
22+
ForceAuth bool
2223
)

cmd/monoctl/get/get.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var showDeleted bool
2323
var sortBy string
2424
var sortDescending bool
2525
var exportFile string
26+
var wide bool
2627

2728
func getOutputOptions() *output.OutputOptions {
2829
sortOpt := output.SortOptions{SortByColumn: sortBy}
@@ -33,7 +34,7 @@ func getOutputOptions() *output.OutputOptions {
3334
Format: output.CSV,
3435
File: exportFile,
3536
}
36-
return &output.OutputOptions{ShowDeleted: showDeleted, SortOptions: sortOpt, ExportOptions: exportOpt}
37+
return &output.OutputOptions{ShowDeleted: showDeleted, SortOptions: sortOpt, ExportOptions: exportOpt, Wide: wide}
3738
}
3839

3940
func NewGetCmd() *cobra.Command {
@@ -62,6 +63,7 @@ func NewGetCmd() *cobra.Command {
6263
flags.BoolVar(&sortDescending, "descending", false, "Sort result in descending order.")
6364
flags.StringVar(&exportFile, "export", "", "exports the output to a file in CSV format. If no file is specified m8-output.csv will be written in the current directory if it doesn't exists")
6465
flags.Lookup("export").NoOptDefVal = "m8-output.csv"
66+
flags.BoolVar(&wide, "wide", false, "Show more information on the resources.")
6567

6668
return cmd
6769
}

cmd/monoctl/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ users and their roles in a Kubernetes multi-cluster environment.`,
4444
fl.AddGoFlagSet(flag.CommandLine)
4545
fl.StringVar(&flags.ExplicitFile, "monoconfig", "", "Path to explicit monoskope config file to use for CLI requests")
4646
fl.DurationVar(&flags.Timeout, "command-timeout", 10*time.Second, "Timeout for long running commands")
47+
fl.BoolVar(&flags.ForceAuth, "force-auth", false, "Force authentication even if authenticated")
4748

4849
rootCmd.AddCommand(NewVersionCmd())
4950
rootCmd.AddCommand(NewCompletionCommand())

cmd/monoctl/update/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"context"
1919
"errors"
2020
"fmt"
21-
"io/ioutil"
2221
"net/url"
22+
"os"
2323

2424
"github.com/finleap-connect/monoctl/cmd/monoctl/flags"
2525
"github.com/finleap-connect/monoctl/internal/config"
@@ -49,7 +49,7 @@ func NewUpdateClusterCmd() *cobra.Command {
4949
}
5050

5151
if caCertBundleFile != "" {
52-
caCertBundle, err = ioutil.ReadFile(caCertBundleFile)
52+
caCertBundle, err = os.ReadFile(caCertBundleFile)
5353
if err != nil {
5454
return fmt.Errorf("failed to read CA certificates from '%s': %s", caCertBundleFile, err)
5555
}

0 commit comments

Comments
 (0)