Skip to content

Commit

Permalink
Merge pull request #13 from konstructio/get-physical
Browse files Browse the repository at this point in the history
Get physical
  • Loading branch information
jarededwards authored Nov 14, 2024
2 parents 682b165 + 021f562 commit ce762e6
Show file tree
Hide file tree
Showing 24 changed files with 1,793 additions and 169 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/testing.yaml
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 ./...
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ go.work.sum
.env
tmp/
dist/
.vscode
./templates
colony.yaml
colony.yaml.tmpl
vendor/
113 changes: 113 additions & 0 deletions .golangci.yaml
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
8 changes: 8 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ brews:
repository:
owner: konstructio
name: homebrew-taps

blobs:
- provider: s3
disable_ssl: true
endpoint: https://objectstore.nyc1.civo.com
region: nyc1
bucket: konstruct-assets
acl: public-read
64 changes: 62 additions & 2 deletions README.md
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
```
53 changes: 53 additions & 0 deletions cmd/destroy.go
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
}
Loading

0 comments on commit ce762e6

Please sign in to comment.