-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
90 changed files
with
1,162 additions
and
487 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
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,6 +1,6 @@ | ||
FROM golang:1.16.3 | ||
|
||
ARG BEETLE_VERSION=0.2.2 | ||
ARG BEETLE_VERSION=1.0.0 | ||
|
||
ENV GO111MODULE=on | ||
|
||
|
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 +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/0wCHA2AETwM4NkAANey2V9uWOcG5A5zwywJg9xk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mHEO/4jju4wr6kjXF1TxrVps21HuLLDzQ/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+vasUYH21DNccw12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y9SoahoQOY0LxjD0C73h+sBkmOJ6XuQFP12tLNoYKttTEWlXqLuz4RiaoVvwPNgFZyZfKYBx+qZl7lHHAvSSf2DrK1kKKwuyp2EMB/V+TiME+AKyLusY+iAb/fqHWVp9eS8su3xMu4wXqNs6wGt9U7CJe0MgAQ12sP379esVKvqHpgpCbF4pUF7NRdkt6xzN4L04i95/F5dnKuwtC/8vwr89Ld/iet/A8FosrhYSLX6R8sFEiNQTll4s7M0qa79OV0dBIzhZG/Ss0GtAtjobZwXCdomS4fSkRjPlOa8wmAMUpe4q0SzvBBpr0c4DlO1hVcTJVcSrKOhcnW/XYXiW87QVap694kbA9BYoGq+2o64Sterfqv10jrLIg4fMxe3ub35hxtO0vzbwM+HgXx/4SR3zgP6LoFvGWOsLVM2Rcm5JxO8KVHW5/uDdX5O2vI8Pz/wM=</diagram></mxfile> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,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) | ||
} |
Oops, something went wrong.