Skip to content

Commit

Permalink
Move commands to cmd dir (#188)
Browse files Browse the repository at this point in the history
* cmd: Move cmd directory out of pkg

Signed-off-by: Din Music <din.music@din-cloud.com>

* github: Update build commands

Signed-off-by: Din Music <din.music@din-cloud.com>

* docs: Update required go version and build command

Signed-off-by: Din Music <din.music@din-cloud.com>

---------

Signed-off-by: Din Music <din.music@din-cloud.com>
  • Loading branch information
MusicDin authored Apr 13, 2024
1 parent ee637a7 commit 553fa62
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/actions/runner-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ runs:
- name: Build Kubitect
shell: bash
run: |
go build -ldflags "-s -w" -trimpath .
go build -ldflags "-s -w" -trimpath -o kubitect ./cmd
sudo mv kubitect /usr/local/bin/kubitect
kubitect --version
6 changes: 3 additions & 3 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jobs:
exclude:
- goarch: "386"
goos: darwin
env:
go-version: 1.21
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -36,5 +34,7 @@ jobs:
extra_files: LICENSE
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: ${{ env.go-version }}
goversion: go.mod
github_token: ${{ github.token }}
project_path: ./cmd

2 changes: 1 addition & 1 deletion pkg/cmd/cmd.go → cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"github.com/MusicDin/kubitect/pkg/env"
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/cmd_apply.go → cmd/cmd_apply.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"github.com/MusicDin/kubitect/pkg/app"
Expand All @@ -18,10 +18,10 @@ var (
applyExample = Example(`
Create a new cluster or modify an existing one:
> kubitect apply --config cluster.yaml
To upgrade an existing cluster, bump the Kubernetes version in current cluster config and run:
> kubitect apply --config cluster.yaml --action upgrade
To scale an existing cluster, add or remove node instances in current cluster config and run:
> kubitect apply --config cluster.yaml --action scale`)
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cmd_destroy.go → cmd/cmd_destroy.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cmd_export.go → cmd/cmd_export.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import "github.com/spf13/cobra"

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cmd_export_config.go → cmd/cmd_export_config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"fmt"
Expand All @@ -18,7 +18,7 @@ var (
exportKcExample = Example(`
To save a kubeconfig to the specific file, redirect command output to that file:
> kubitect export kubeconfig --cluster lake > lake.yaml
Use kubeconfig with kubectl to access cluster:
> kubectl --kubeconfig lake.yaml get nodes`)
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cmd_export_preset.go → cmd/cmd_export_preset.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"fmt"
Expand All @@ -18,7 +18,7 @@ var (
exportPresetExample = Example(`
To list available presets run:
> kubitect list presets
To export a preset to the specific file run:
> kubitect export preset --name minimal > cluster.yaml`)
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cmd_list.go → cmd/cmd_list.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"github.com/spf13/cobra"
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cmd_list_clusters.go → cmd/cmd_list_clusters.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"strings"
Expand All @@ -12,7 +12,7 @@ import (
var (
listClustersShort = "List clusters"
listClustersLong = LongDesc(`
Command list clusters lists all clusters including local clusters if
Command list clusters lists all clusters including local clusters if
a current (working) directory is Kubitect project.`)

listClusterExample = Example(`
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cmd_list_presets.go → cmd/cmd_list_presets.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"github.com/MusicDin/kubitect/embed"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cmd_test.go → cmd/cmd_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"testing"
Expand Down
7 changes: 3 additions & 4 deletions main.go → cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package main

import (
"github.com/MusicDin/kubitect/pkg/cmd"
"github.com/MusicDin/kubitect/pkg/ui"
"os"

"github.com/MusicDin/kubitect/pkg/ui"
)

func main() {
err := cmd.NewRootCmd().Execute()

err := NewRootCmd().Execute()
if err != nil {
ui.PrintBlockE(err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/meta_clusters.go → cmd/meta_clusters.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"os"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/utils.go → cmd/utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/utils_test.go → cmd/utils_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package main

import (
"testing"
Expand Down
49 changes: 0 additions & 49 deletions doc.go

This file was deleted.

4 changes: 2 additions & 2 deletions docs/getting-started/other/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This document shows how to build a CLI tool manually and how to use the project
## Prerequisites

+ [Git](https://git-scm.com/)
+ [Go 1.18](https://go.dev/dl/) or greater
+ [Go 1.22](https://go.dev/dl/) or greater

## Step 1: Clone the project

Expand All @@ -28,7 +28,7 @@ cd kubitect
The Kubitect CLI tool can be manually built using Go.
Running the following command will produce a `kubitect` binary file.
```sh
go build .
go build -o kubitect ./cmd
```

To make the binary file globally accessible, move it to the `/usr/local/bin/` directory.
Expand Down

0 comments on commit 553fa62

Please sign in to comment.