Skip to content

Commit

Permalink
Close #123
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Apr 3, 2021
1 parent 01f0d82 commit ae26bf9
Show file tree
Hide file tree
Showing 90 changed files with 1,162 additions and 487 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- Review existing issues and provide feedback or react to them.

- With pull requests:
- Open your pull request against `master`
- Open your pull request against `main`
- Your pull request should have no more than two commits, if not you should squash them.
- It should pass all tests in the available continuous integrations systems such as TravisCI.
- You should add/modify tests to cover your proposed code changes.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.16.3

ARG BEETLE_VERSION=0.2.2
ARG BEETLE_VERSION=1.0.0

ENV GO111MODULE=on

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ check_license:
## test_short: Run test cases with short flag.
test_short:
@echo ">> ============= Running Short Tests ============= <<"
$(GO) test -short $(pkgs)
$(GO) test -mod=readonly -short $(pkgs)


## test: Run test cases.
test:
@echo ">> ============= Running All Tests ============= <<"
$(GO) test -v -cover $(pkgs)
$(GO) test -mod=readonly -v -cover $(pkgs)


## lint: Lint the code.
Expand Down Expand Up @@ -83,7 +83,7 @@ vet:
coverage:
@echo ">> ============= Coverage ============= <<"
rm -f coverage.html cover.out
$(GO) test -coverprofile=cover.out $(pkgs)
$(GO) test -mod=readonly -coverprofile=cover.out $(pkgs)
go tool cover -html=cover.out -o coverage.html


Expand Down
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<p align="center">
<a href="https://www.youtube.com/watch?v=54qQIYTZiAw" target="_blank">
<img src="https://raw.githubusercontent.com/clivern/Beetle/master/assets/img/gopher.png?v=0.2.2" width="180" />
<img src="https://raw.githubusercontent.com/clivern/Beetle/main/assets/img/gopher.png?v=1.0.0" width="180" />
</a>
<h3 align="center">Beetle</h3>
<p align="center">Kubernetes multi-cluster deployment automation service</p>
<p align="center">
<a href="https://travis-ci.com/Clivern/Beetle"><img src="https://travis-ci.com/Clivern/Beetle.svg?branch=master"></a>
<a href="https://github.com/Clivern/Beetle/releases"><img src="https://img.shields.io/badge/Version-v0.2.2-red.svg"></a>
<a href="https://goreportcard.com/report/github.com/Clivern/Beetle"><img src="https://goreportcard.com/badge/github.com/clivern/Beetle?v=0.2.2"></a>
<a href="https://travis-ci.com/Clivern/Beetle"><img src="https://travis-ci.com/Clivern/Beetle.svg?branch=main"></a>
<a href="https://github.com/Clivern/Beetle/releases"><img src="https://img.shields.io/badge/Version-v1.0.0-red.svg"></a>
<a href="https://goreportcard.com/report/github.com/Clivern/Beetle"><img src="https://goreportcard.com/badge/github.com/clivern/Beetle?v=1.0.0"></a>
<a href="https://hub.docker.com/r/clivern/beetle"><img src="https://img.shields.io/badge/Docker-Latest-orange"></a>
<a href="https://github.com/Clivern/Beetle/blob/master/LICENSE"><img src="https://img.shields.io/badge/LICENSE-MIT-orange.svg"></a>
<a href="https://github.com/Clivern/Beetle/blob/main/LICENSE"><img src="https://img.shields.io/badge/LICENSE-MIT-orange.svg"></a>
</p>
</p>
<br/>
<p align="center">
<a href="https://www.youtube.com/watch?v=54qQIYTZiAw" target="_blank"><img src="https://raw.githubusercontent.com/Clivern/Beetle/master/assets/img/chart.png?v=0.2.2" width="100%" /></a>
<a href="https://www.youtube.com/watch?v=54qQIYTZiAw" target="_blank"><img src="https://raw.githubusercontent.com/Clivern/Beetle/main/assets/img/chart.png?v=1.0.0" width="100%" /></a>
</p>

<h4 align="center">
Expand Down Expand Up @@ -114,12 +114,10 @@ app:
name: ${BEETLE_KUBE_CLUSTER_01_NAME:-production}
inCluster: ${BEETLE_KUBE_CLUSTER_01_IN_CLUSTER:-false}
kubeconfig: ${BEETLE_KUBE_CLUSTER_01_CONFIG_FILE:-/app/configs/production-cluster-kubeconfig.yaml}
configMapName: ${BEETLE_KUBE_CLUSTER_01_CONFIG_MAP:-beetle-configs}
-
name: ${BEETLE_KUBE_CLUSTER_02_NAME:-staging}
inCluster: ${BEETLE_KUBE_CLUSTER_02_IN_CLUSTER:-false}
kubeconfig: ${BEETLE_KUBE_CLUSTER_02_CONFIG_FILE:-/app/configs/staging-cluster-kubeconfig.yaml}
configMapName: ${BEETLE_KUBE_CLUSTER_02_CONFIG_MAP:-beetle-configs}

# HTTP Webhook
webhook:
Expand Down Expand Up @@ -153,14 +151,9 @@ $ go run beetle.go serve -c /custom/path/config.prod.yml
```


## Beetle Terraform Provider

You can find the terraform provider here https://github.com/Clivern/terraform-provider-beetle. It is preferred to use it in order to interact with beetle API server or build your own thing using the [SDK](https://github.com/Clivern/Beetle/tree/master/sdk).


## API Documentation

Go to https://editor.swagger.io/ and import this file https://raw.githubusercontent.com/Clivern/Beetle/master/swagger.yaml.
Go to https://editor.swagger.io/ and import this file https://raw.githubusercontent.com/Clivern/Beetle/main/swagger.yaml.


## Versioning
Expand Down
40 changes: 0 additions & 40 deletions app/kubernetes/config.go

This file was deleted.

45 changes: 0 additions & 45 deletions app/model/configs.go

This file was deleted.

2 changes: 1 addition & 1 deletion assets/img/chart.drawio
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<mxfile modified="2020-06-14T12:26:56.748Z" host="app.diagrams.net" agent="5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" etag="yMTx39YcGas92sVVpEq4" version="13.2.4" type="device"><diagram id="d1ab7348-05c3-a1e3-ca4d-12c340fd6b49" name="Page-1">7VxRc5s6Fv41nrn7AAMSwvAYJ3Gb27Q3u+netvclg0G2aTDygpzE/fUrgcAgYZsk4KSJ3ZnUHIQQ+j59OjpHeABPFw8fEm85/0wCHA2AETwM4NkAANey2V9uWOcG5A5zwywJg9xkbgzX4S8sjIawr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kjXF1TxrVps21HuLLDzQ/z5oq8+fFjeP5/</diagram></mxfile>
<mxfile modified="2021-04-03T21:36:16.551Z" host="app.diagrams.net" agent="5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36" etag="mCddqXOVAB87riqQZXYU" version="14.5.7" type="device"><diagram id="d1ab7348-05c3-a1e3-ca4d-12c340fd6b49" name="Page-1">7Vxdd5s6Fv01XmvmwSyQ+HyMk7jtNOnkXvfetvclC4Nsq8HIA3IS99ePBAKDhG2SgJMmcddqjBBCaG9tHZ1z8ACeLu8/JP5qcUlCFA2AHt4P4NkAAMPQbfaHl2zyEgc6ecE8waGotC2Y4F9IFOqidI1DlNYqUkIiilf1woDEMQporcxPEnJXrzYjUf2uK3+OlIJJ4Edq6Tcc0kXxXLa3PfER4flC3NoF4vmmfnAzT8g6FvcbADjLPvnppV+0JR40XfghuasUwfMBPE0Iofm35f0pivjYFsOWXzfecbbsd4Ji2uYCN55MJ+58/un6P2jpe7/Qt0syNGwBX0o3xYigkA2QOCQJXZA5if3ofFs6yp4a8XZ1drStc0HIihUarPAnonQj0PbXlLCiBV1G4iy6x/Q7v1yzxNGPypmze9FydrARB+rziiHg/a0UiKf/gMgS0WTDKiQo8im+rQPuC97My3rlpVcEs1sAXXDchVZ+iWA48PR6EylZJwESV1UReGhD1E/miCoNsS+V59kWZQA/CGznHew3A7YD8/vd+tEaFRIloc80acW/Lu/nXN21ebACWkjW0wj9mYntqFQtjldKE3JTyiQvmeEoOiURSdhxTGLOlxmJaVHENFHPPqz8FiUUM909ifA85vfEYZgRLG9VamUnAXgz6H4vBcRZx5IQsEUTd1udB7pAZVGReFvfzZoaTA/HxGzAxI6oGLZsmStGzv7fmi8NbCSg4fN/1SJ7zv9eJSRcBxSTeMDFP29omhSnP6+nKIkRZcsr0E+jdUpRUtRi/c/vmFdVmBH66aKc9GLt9afZWb0+vasUYH21DNccw12wNhLupuzndcS0hVVj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C73h+sBkmOJ6XuQFP12tLNoYKttTEWlXqLuz4RiaoVvwPNgFZyZfKYBx+qZl7lHHAvSSf2DrK1kKKwuyp2EMB/V+TiME+AKyLusY+iAb/fqHWVp9eS8su3xMu4wXqNs6wGt9U7CJe0MgAQ12sP379esVKvqHpgpCbF4pUF7NRdkt6xzN4L04i95/F5dnKuwtC/8vwr89Ld/iet/A8FosrhYSLX6R8sFEiNQTll4s7M0qa79OV0dBIzhZG/Ss0GtAtjobZwXCdomS4fSkRjPlOa8wmAMUpe4q0SzvBBpr0c4DlO1hVcTJVcSrKOhcnW/XYXiW87QVap694kbA9BYoGq+2o64Sterfqv10jrLIg4fMxe3ub35hxtO0vzbwM+HgXx/4SR3zgP6LoFvGWOsLVM2Rcm5JxO8KVHW5/uDdX5O2vI8Pz/wM=</diagram></mxfile>
Binary file modified assets/img/chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion beetle.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package main

import (
"github.com/clivern/beetle/app/cmd"
"github.com/clivern/beetle/core/cmd"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion beetle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"path/filepath"
"testing"

"github.com/clivern/beetle/app/module"
"github.com/clivern/beetle/core/module"
"github.com/clivern/beetle/pkg"

"github.com/drone/envsubst"
Expand Down
2 changes: 0 additions & 2 deletions config.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ app:
name: ${BEETLE_KUBE_CLUSTER_01_NAME:-production}
inCluster: ${BEETLE_KUBE_CLUSTER_01_IN_CLUSTER:-false}
kubeconfig: ${BEETLE_KUBE_CLUSTER_01_CONFIG_FILE:-/app/configs/production-cluster-kubeconfig.yaml}
configMapName: ${BEETLE_KUBE_CLUSTER_01_CONFIG_MAP:-beetle-configs}
-
name: ${BEETLE_KUBE_CLUSTER_02_NAME:-staging}
inCluster: ${BEETLE_KUBE_CLUSTER_02_IN_CLUSTER:-false}
kubeconfig: ${BEETLE_KUBE_CLUSTER_02_CONFIG_FILE:-/app/configs/staging-cluster-kubeconfig.yaml}
configMapName: ${BEETLE_KUBE_CLUSTER_02_CONFIG_MAP:-beetle-configs}

# HTTP Webhook
webhook:
Expand Down
2 changes: 0 additions & 2 deletions config.testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ app:
name: ${BEETLE_KUBE_CLUSTER_01_NAME:-production}
inCluster: ${BEETLE_KUBE_CLUSTER_01_IN_CLUSTER:-false}
kubeconfig: ${BEETLE_KUBE_CLUSTER_01_CONFIG_FILE:-/app/configs/production-cluster-kubeconfig.yaml}
configMapName: ${BEETLE_KUBE_CLUSTER_01_CONFIG_MAP:-beetle-configs}
-
name: ${BEETLE_KUBE_CLUSTER_02_NAME:-staging}
inCluster: ${BEETLE_KUBE_CLUSTER_02_IN_CLUSTER:-false}
kubeconfig: ${BEETLE_KUBE_CLUSTER_02_CONFIG_FILE:-/app/configs/staging-cluster-kubeconfig.yaml}
configMapName: ${BEETLE_KUBE_CLUSTER_02_CONFIG_MAP:-beetle-configs}

# HTTP Webhook
webhook:
Expand Down
115 changes: 115 additions & 0 deletions core/cmd/apps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright 2020 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package cmd

import (
"context"
"fmt"
"os"

"github.com/clivern/beetle/core/module"
"github.com/clivern/beetle/sdk"

"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)

var (
// Beetle API Server URL
apiURL string

// Beetle API Server API Key
apiKey string

// The Kubernetes Cluster
cluster string

// The Kubernetes Cluster Namespace
namespace string
)

var getCmd = &cobra.Command{
Use: "get",
Short: "Get resources",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(`You must specify the type of resource to get. Current supported resources are (apps).`)
},
}

var appsCmd = &cobra.Command{
Use: "apps",
Short: "Get a list of applications with cluster id and namespace",
Run: func(cmd *cobra.Command, aras []string) {
// Usage
// $ ./beetle get apps -u "http://localhost:8080" -k "" -c "production" -n "default"

data := [][]string{}

client := sdk.Client{}
client.SetHTTPClient(module.NewHTTPClient(20))
client.SetAPIURL(apiURL)
client.SetAPIKey(apiKey)

apps, err := client.GetApplications(context.TODO(), cluster, namespace)

if err != nil {
data = append(data, []string{
fmt.Sprintf("Error: %s", err.Error()),
"",
"",
"",
})
} else {
for _, app := range apps.Applications {
version := "N/A"

if len(app.Containers) > 0 {
version = app.Containers[0].Version
}

data = append(data, []string{
app.ID,
app.Name,
fmt.Sprintf("%d", len(app.Containers)),
version,
})
}
}

table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"ID", "Name", "Containers", "Version"})
table.SetAutoWrapText(false)
table.SetAutoFormatHeaders(true)
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
table.SetAlignment(tablewriter.ALIGN_LEFT)
table.SetCenterSeparator("")
table.SetColumnSeparator("")
table.SetRowSeparator("")
table.SetHeaderLine(false)
table.SetBorder(false)
table.SetTablePadding("\t")
table.SetNoWhiteSpace(true)
table.AppendBulk(data)
table.Render()
},
}

func init() {
rootCmd.AddCommand(getCmd)

appsCmd.Flags().StringVarP(&namespace, "namespace", "n", "default", "The Kubernetes Cluster Namespace (eg. default)")
appsCmd.MarkFlagRequired("namespace")

appsCmd.Flags().StringVarP(&cluster, "cluster", "c", "", "The Kubernetes Cluster (eg. production)")
appsCmd.MarkFlagRequired("cluster")

appsCmd.Flags().StringVarP(&apiKey, "api_key", "k", "", "API Key of the Beetle API Server")
appsCmd.MarkFlagRequired("api_key")

appsCmd.Flags().StringVarP(&apiURL, "api_url", "u", "", "Beetle API Server URL (eg. https://example.com/)")
appsCmd.MarkFlagRequired("api_url")

getCmd.AddCommand(appsCmd)
}
Loading

0 comments on commit ae26bf9

Please sign in to comment.