-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from konstructio/get-physical
Get physical
- Loading branch information
Showing
24 changed files
with
1,793 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Go unit tests | ||
|
||
on: [push, workflow_dispatch] | ||
|
||
permissions: | ||
checks: write | ||
contents: read | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
- name: Run GolangCI-Lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.60 | ||
- name: Test application | ||
run: go test -short -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,8 @@ go.work.sum | |
.env | ||
tmp/ | ||
dist/ | ||
.vscode | ||
./templates | ||
colony.yaml | ||
colony.yaml.tmpl | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
run: | ||
tests: false | ||
concurrency: 5 | ||
timeout: 3m | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- unused | ||
- asasalint | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- contextcheck | ||
- decorder | ||
- dogsled | ||
- dupl | ||
- dupword | ||
- durationcheck | ||
- errchkjson | ||
- errname | ||
- errorlint | ||
- exhaustive | ||
- copyloopvar | ||
- forcetypeassert | ||
- ginkgolinter | ||
- gocheckcompilerdirectives | ||
- gochecksumtype | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- gofumpt | ||
- goheader | ||
- goimports | ||
- gomodguard | ||
- goprintffuncname | ||
- gosec | ||
- gosmopolitan | ||
- grouper | ||
- importas | ||
- ireturn | ||
- loggercheck | ||
- makezero | ||
- mirror | ||
- misspell | ||
- musttag | ||
- nakedret | ||
- nilerr | ||
- nilnil | ||
- noctx | ||
- nolintlint | ||
- nonamedreturns | ||
- nosprintfhostport | ||
- paralleltest | ||
- perfsprint | ||
- prealloc | ||
- predeclared | ||
- promlinter | ||
- protogetter | ||
- reassign | ||
- revive | ||
- rowserrcheck | ||
- sloglint | ||
- spancheck | ||
- sqlclosecheck | ||
- stylecheck | ||
- tenv | ||
- testableexamples | ||
- testifylint | ||
- testpackage | ||
- thelper | ||
- tparallel | ||
- unconvert | ||
- unparam | ||
- usestdlibvars | ||
- wastedassign | ||
- whitespace | ||
- wrapcheck | ||
- zerologlint | ||
|
||
linters-settings: | ||
perfsprint: | ||
int-conversion: false | ||
err-error: false | ||
errorf: true | ||
sprintf1: true | ||
strconcat: false | ||
|
||
ireturn: | ||
allow: | ||
- ssh.PublicKey | ||
- tea.Model | ||
- error | ||
|
||
gosec: | ||
confidence: medium | ||
excludes: | ||
- G107 # Potential HTTP request made with variable url: these are often false positives or intentional | ||
- G110 # Decompression bombs: we can check these manually when submitting code | ||
- G306 # Poor file permissions used when creating a directory: we can check these manually when submitting code | ||
- G404 # Use of weak random number generator (math/rand instead of crypto/rand): we can live with these | ||
|
||
stylecheck: | ||
checks: | ||
- "all" | ||
- "-ST1003" # this is covered by a different linter | ||
|
||
gocyclo: | ||
min-complexity: 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,62 @@ | ||
# colony | ||
colony cli | ||
# Colony Scout | ||
|
||
## Report | ||
|
||
```bash | ||
go build -o colony-scout | ||
|
||
./colony-scout report \ | ||
--validate=k8s,cloud-init \ | ||
--type=server \ # server, node, agent | ||
# --colony-api="http://localhost:8080" \ | ||
--token=123456 \ | ||
--cluster-id=00000000-0000-0000-0000-000000000000 \ | ||
--workflow-id=00000000-0000-0000-0000-000000000000 \ | ||
--hardware-id=00000000-0000-0000-0000-000000000000 \ | ||
--host-ip-port=192.168.0.43:6443 \ | ||
--kubeconfig=~/.kube/config \ | ||
--k3s-token=00000000-0000-0000-0000-000000000000 | ||
|
||
``` | ||
|
||
## Discovery | ||
|
||
```bash | ||
go build -o colony-scout | ||
|
||
./colony-scout discovery \ | ||
# --colony-api="http://localhost:8080" \ | ||
--token=123456 \ | ||
--hardware-id=00000000-0000-0000-0000-000000000000 | ||
|
||
``` | ||
|
||
## Running test | ||
|
||
Validate and install [kwok](https://kwok.sigs.k8s.io/) | ||
|
||
### Run tests in CI | ||
|
||
```bash | ||
make test | ||
``` | ||
|
||
### Run tests locally | ||
|
||
```bash | ||
make start_kwok && make test | ||
``` | ||
|
||
## Development with Docker | ||
|
||
### Build | ||
|
||
```bash | ||
docker compose build | ||
``` | ||
|
||
### Run | ||
|
||
```bash | ||
docker compose up | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/konstructio/colony/internal/constants" | ||
"github.com/konstructio/colony/internal/docker" | ||
"github.com/konstructio/colony/internal/exec" | ||
"github.com/konstructio/colony/internal/logger" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func getDestroyCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "destroy", | ||
Short: "remove colony deployment from your host", | ||
Long: `remove colony deployment from your host`, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
ctx := cmd.Context() | ||
log := logger.New(logger.Debug) | ||
|
||
log.Info("creating docker client") | ||
dockerCLI, err := docker.New(log) | ||
if err != nil { | ||
return fmt.Errorf("error creating docker client: %w", err) | ||
} | ||
defer dockerCLI.Close() | ||
|
||
pwd, err := os.Getwd() | ||
if err != nil { | ||
return fmt.Errorf("error getting current working directory: %w", err) | ||
} | ||
|
||
err = dockerCLI.RemoveColonyK3sContainer(ctx) | ||
if err != nil { | ||
return fmt.Errorf("error: failed to remove colony container %w", err) | ||
} | ||
|
||
err = exec.DeleteFile(filepath.Join(pwd, constants.KubeconfigHostPath)) | ||
if err != nil { | ||
return fmt.Errorf("error: failed to delete kubeconfig file %w", err) | ||
} | ||
|
||
//! templates directory is not removed | ||
|
||
log.Info("colony installation removed from host") | ||
return nil | ||
}, | ||
} | ||
return cmd | ||
} |
Oops, something went wrong.