Skip to content

Commit

Permalink
Migration to epam org WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealSpaceShip committed Sep 30, 2022
1 parent 6cd420d commit d61d716
Show file tree
Hide file tree
Showing 138 changed files with 598 additions and 597 deletions.
21 changes: 10 additions & 11 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ builds:
ldflags:
- -s
- -w
- -X 'github.com/agilestacks/hub/cmd/hub/util.ref={{ .Tag }}'
- -X 'github.com/agilestacks/hub/cmd/hub/util.commit={{ .ShortCommit }}'
- -X 'github.com/agilestacks/hub/cmd/hub/util.buildAt={{ time "2006.01.02 15:04:05 MST" }}'
- -X 'github.com/agilestacks/hub/cmd/hub/metrics.DDKey={{ if index .Env "DD_CLIENT_API_KEY" }}{{ .Env.DD_CLIENT_API_KEY }}{{ else }}{{ end }}'
- -X 'github.com/epam/hubctl/cmd/hub/util.ref={{ .Tag }}'
- -X 'github.com/epam/hubctl/cmd/hub/util.commit={{ .ShortCommit }}'
- -X 'github.com/epam/hubctl/cmd/hub/util.buildAt={{ time "2006.01.02 15:04:05 MST" }}'

archives:
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
Expand Down Expand Up @@ -56,23 +55,23 @@ brews:
- name: hub

tap:
owner: agilestacks
owner: epam
name: homebrew-tap
branch: main
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"

commit_author:
name: asibot
email: asibot@users.noreply.github.com
name: epambot
email: epambot@users.noreply.github.com
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Version }}"

folder: Formula

homepage: "https://superhub.io/"
description: "Hub CLI is stack composition and lifecycle tool."
license: "GPLv3"
description: "Hub CTL is stack composition and lifecycle tool."
license: "MPL-2.0"
custom_block: |
head "https://github.com/asibot/hub"
head "https://github.com/epam/hubctl"
caveats: |
hub version
hub help
Expand All @@ -87,7 +86,7 @@ brews:

test: |
output = shell_output("#{bin}/hub version").chomp
assert output.start_with?("Hub CLI git ")
assert output.start_with?("Hub CTL git ")
system "false"
post_install: |
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.13
ARG FULLNAME="Agile Stacks"
LABEL maintainer="${FULLNAME} <support@agilestacks.com>"
ARG FULLNAME="EPAM Systems"
LABEL maintainer="${FULLNAME} <opensource@epam.com>"
RUN \
apk update && apk upgrade && \
apk add --no-cache \
Expand Down
41 changes: 15 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ OS := $(shell go env GOOS)
export GOBIN := $(abspath .)/bin/$(OS)
export PATH := $(GOBIN):$(PATH)

ifeq (,$(METRICS_API_SECRET))
$(info METRICS_API_SECRET is not set - usage metrics won't be submitted to SuperHub API; \
see https://github.com/agilestacks/documentation/wiki/Hub-CLI-Usage-Metrics)
endif

ifeq (,$(DD_CLIENT_API_KEY))
$(info DD_CLIENT_API_KEY is not set - usage metrics won't be submitted to Datadog; \
see https://github.com/agilestacks/documentation/wiki/Hub-CLI-Usage-Metrics)
endif

REF ?= $(shell git rev-parse --abbrev-ref HEAD)
COMMIT ?= $(shell git rev-parse HEAD | cut -c-7)
BUILD_AT ?= $(shell date +"%Y.%m.%d %H:%M %Z")
Expand All @@ -34,51 +24,50 @@ bin/$(OS)/gotests:
$ go get -u github.com/cweill/gotests/...

cel:
go get github.com/agilestacks/hub/cmd/cel
go get github.com/epam/hubctl/cmd/cel
.PHONY: cel

build:
go build \
-o bin/$(OS)/hub \
-ldflags="-s -w \
-X 'github.com/agilestacks/hub/cmd/hub/util.ref=$(REF)' \
-X 'github.com/agilestacks/hub/cmd/hub/util.commit=$(COMMIT)' \
-X 'github.com/agilestacks/hub/cmd/hub/util.buildAt=$(BUILD_AT)' \
-X 'github.com/agilestacks/hub/cmd/hub/metrics.DDKey=$(DD_CLIENT_API_KEY)'" \
github.com/agilestacks/hub/cmd/hub
-X 'github.com/epam/hubctl/cmd/hub/util.ref=$(REF)' \
-X 'github.com/epam/hubctl/cmd/hub/util.commit=$(COMMIT)' \
-X 'github.com/epam/hubctl/cmd/hub/util.buildAt=$(BUILD_AT)'" \
github.com/epam/hubctl/cmd/hub
.PHONY: build

build-with-api:
go build \
-o bin/$(OS)/hub \
-tags="api" \
-ldflags="-s -w \
-X 'github.com/agilestacks/hub/cmd/hub/util.ref=$(REF)' \
-X 'github.com/agilestacks/hub/cmd/hub/util.commit=$(COMMIT)' \
-X 'github.com/agilestacks/hub/cmd/hub/util.buildAt=$(BUILD_AT)' \
-X 'github.com/agilestacks/hub/cmd/hub/metrics.MetricsServiceKey=$(METRICS_API_SECRET)' \
-X 'github.com/agilestacks/hub/cmd/hub/metrics.DDKey=$(DD_CLIENT_API_KEY)'" \
github.com/agilestacks/hub/cmd/hub
-X 'github.com/epam/hubctl/cmd/hub/util.ref=$(REF)' \
-X 'github.com/epam/hubctl/cmd/hub/util.commit=$(COMMIT)' \
-X 'github.com/epam/hubctl/cmd/hub/util.buildAt=$(BUILD_AT)' \
-X 'github.com/epam/hubctl/cmd/hub/metrics.MetricsServiceKey=$(METRICS_API_SECRET)' \
-X 'github.com/epam/hubctl/cmd/hub/metrics.DDKey=$(DD_CLIENT_API_KEY)'" \
github.com/epam/hubctl/cmd/hub
.PHONY: build-with-api

fmt:
go fmt github.com/agilestacks/hub/...
go fmt github.com/epam/hubctl/...
.PHONY: fmt

vet:
go vet -composites=false github.com/agilestacks/hub/...
go vet -composites=false github.com/epam/hubctl/...
.PHONY: vet

loc: bin/$(OS)/gocloc
@$(GOBIN)/gocloc cmd/hub --not-match-d='cmd/hub/bindata'
.PHONY: loc

staticcheck: bin/$(OS)/staticcheck
@$(GOBIN)/staticcheck github.com/agilestacks/hub/...
@$(GOBIN)/staticcheck github.com/epam/hubctl/...
.PHONY: staticcheck

test:
go test -timeout 30s github.com/agilestacks/hub/cmd/hub/...
go test -timeout 30s github.com/epam/hubctl/cmd/hub/...
.PHONY: test

clean:
Expand Down
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hub CLI
# Hub CTL

[Hub CLI](https://superhub.io) is stack composition and lifecycle tool.
[Hub CTL](https://superhub.io) is stack composition and lifecycle tool.

## Example of usage

Expand All @@ -18,17 +18,17 @@ hub help
To download the latest release, run:

```shell
curl -LJ "https://github.com/agilestacks/hub/releases/latest/download/hub_$(uname -s)_$(uname -m).tar.gz" | tar xz -C /tmp
curl -LJ "https://github.com/epam/hubctl/releases/latest/download/hub_$(uname -s)_$(uname -m).tar.gz" | tar xz -C /tmp
sudo mv /tmp/hub /usr/local/bin
```

There are [macOS amd64](https://github.com/agilestacks/hub/releases/latest/download/hub_Darwin_arm64.tar.gz), [macOS arm64](https://github.com/agilestacks/hub/releases/latest/download/hub_Darwin_x86_64.tar.gz), [Linux amd64](https://github.com/agilestacks/hub/releases/latest/download/hub_Linux_arm64.tar.gz), [Linux arm64](https://github.com/agilestacks/hub/releases/latest/download/hub_Linux_x86_64.tar.gz) and [Windows x64](https://github.com/agilestacks/hub/releases/latest/download/hub_Windows_x86_64.zip) binaries.
There are [macOS amd64](https://github.com/epam/hubctl/releases/latest/download/hub_Darwin_arm64.tar.gz), [macOS arm64](https://github.com/epam/hubctl/releases/latest/download/hub_Darwin_x86_64.tar.gz), [Linux amd64](https://github.com/epam/hubctl/releases/latest/download/hub_Linux_arm64.tar.gz), [Linux arm64](https://github.com/epam/hubctl/releases/latest/download/hub_Linux_x86_64.tar.gz) and [Windows x64](https://github.com/epam/hubctl/releases/latest/download/hub_Windows_x86_64.zip) binaries.

### [Homebrew](https://brew.sh/)

```shell
brew tap agilestacks/tap
brew install agilestacks/tap/hub
brew tap epam/tap
brew install epam/tap/hubctl
```

Sorry for the name conflict with [GitHub hub](https://hub.github.com).
Expand All @@ -41,7 +41,7 @@ Optionally, install extensions:
hub extensions install
```

Hub CLI Extensions requires: [jq] and [yq v4].
Hub CTL Extensions requires: [jq] and [yq v4].
Optionally install [Node.js] and NPM for `hub pull` extension, [AWS CLI], [Azure CLI], [GCP SDK] [kubectl], [eksctl] for `hub ext eks` extension.

### macOS users
Expand Down Expand Up @@ -70,7 +70,7 @@ git config core.hooksPath .githooks

### Build

Use `make` to build Hub CLI:
Use `make` to build Hub CTL:

```shell
make
Expand All @@ -79,7 +79,7 @@ make
Or directly with `go`:

```shell
go build -o bin/$(go env GOOS)/hub github.com/agilestacks/hub/cmd/hub
go build -o bin/$(go env GOOS)/hub github.com/epam/hubctl/cmd/hub
```

### Clean up
Expand All @@ -90,7 +90,7 @@ make clean

## Usage metrics

When you use a pre-built binary from the releases page, it will send usage metrics to SuperHub and Datadog.
When you use a pre-built binary from the releases page, it will send usage metrics to HubCTL API and Datadog.

We value your privacy and only send anonymized usage metrics for the following commands:

Expand All @@ -102,7 +102,7 @@ We value your privacy and only send anonymized usage metrics for the following c

A usage metric sample contains:

- Hub CLI command invoked without arguments, ie. 'deploy' or 'backup create', or 'api instance get'
- Hub CTL command invoked without arguments, ie. 'deploy' or 'backup create', or 'api instance get'
- synthetic machine id - an UUID generated in first interactive session (stdout is a TTY)
- usage counter - 1 per invocation

Expand All @@ -121,13 +121,11 @@ You could always review an up-to-date help via `hub util metrics -h`.

## What's next?

Deploy [App Stack](https://github.com/agilestacks/stack-app-eks) or [Machine Learning Stack](https://github.com/agilestacks/stack-ml-eks) on AWS EKS.

More information in the [wiki](https://github.com/agilestacks/hub/wiki).
More information in the [wiki](https://github.com/epam/hubctl/wiki).

[AWS CLI]: https://aws.amazon.com/cli/
[Azure CLI]: https://docs.microsoft.com/en-us/cli/azure/
[GCP SDK CLI]: https://cloud.google.com/sdk/docs/install
[GCP SDK]: https://cloud.google.com/sdk/docs/install
[kubectl]: https://kubernetes.io/docs/reference/kubectl/overview/
[eksctl]: https://eksctl.io
[jq]: https://stedolan.github.io/jq/
Expand Down
32 changes: 16 additions & 16 deletions cmd/hub/api/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"os"
"strings"

"github.com/agilestacks/hub/cmd/hub/config"
"github.com/agilestacks/hub/cmd/hub/util"
"github.com/epam/hubctl/cmd/hub/config"
"github.com/epam/hubctl/cmd/hub/util"
)

const applicationsResource = "hub/api/v1/applications"
Expand Down Expand Up @@ -170,10 +170,10 @@ func applicationById(id string) (*Application, error) {
return nil, nil
}
if err != nil {
return nil, fmt.Errorf("Error querying SuperHub Applications: %v", err)
return nil, fmt.Errorf("Error querying HubCTL Applications: %v", err)
}
if code != 200 {
return nil, fmt.Errorf("Got %d HTTP querying SuperHub Applications, expected 200 HTTP", code)
return nil, fmt.Errorf("Got %d HTTP querying HubCTL Applications, expected 200 HTTP", code)
}
return &jsResp, nil
}
Expand Down Expand Up @@ -204,10 +204,10 @@ func applicationsByName(name string) ([]Application, error) {
return nil, nil
}
if err != nil {
return nil, fmt.Errorf("Error querying SuperHub Applications: %v", err)
return nil, fmt.Errorf("Error querying HubCTL Applications: %v", err)
}
if code != 200 {
return nil, fmt.Errorf("Got %d HTTP querying SuperHub Applications, expected 200 HTTP", code)
return nil, fmt.Errorf("Got %d HTTP querying HubCTL Applications, expected 200 HTTP", code)
}
return jsResp, nil
}
Expand All @@ -216,21 +216,21 @@ func InstallApplication(req ApplicationRequest, waitAndTailDeployLogs bool) {
if req.Platform != "" && !util.IsUint(req.Platform) {
platform, err := stackInstanceByDomain(req.Platform)
if err != nil {
log.Fatalf("Unable to install SuperHub Application: %v", err)
log.Fatalf("Unable to install HubCTL Application: %v", err)
}
req.Platform = platform.Id
}
reqBody, err := json.Marshal(&req)
if err != nil {
log.Fatalf("Unable to install SuperHub Application: %v", err)
log.Fatalf("Unable to install HubCTL Application: %v", err)
}
RawInstallApplication(bytes.NewReader(reqBody), waitAndTailDeployLogs)
}

func RawInstallApplication(body io.Reader, waitAndTailDeployLogs bool) {
application, err := rawInstallApplication(body)
if err != nil {
log.Fatalf("Unable to install SuperHub Application: %v", err)
log.Fatalf("Unable to install HubCTL Application: %v", err)
}
formatApplication(application)
if waitAndTailDeployLogs {
Expand All @@ -248,15 +248,15 @@ func rawInstallApplication(body io.Reader) (*Application, error) {
return nil, err
}
if code != 200 && code != 201 && code != 202 {
return nil, fmt.Errorf("Got %d HTTP installing SuperHub Application, expected [200, 201, 202] HTTP", code)
return nil, fmt.Errorf("Got %d HTTP installing HubCTL Application, expected [200, 201, 202] HTTP", code)
}
return &jsResp, nil
}

func DeleteApplication(selector string, waitAndTailDeployLogs bool) {
err := deleteApplication(selector)
if err != nil {
log.Fatalf("Unable to delete SuperHub Application: %v", err)
log.Fatalf("Unable to delete HubCTL Application: %v", err)
}
if waitAndTailDeployLogs {
if config.Verbose {
Expand Down Expand Up @@ -293,15 +293,15 @@ func deleteApplication(selector string) error {
return err
}
if code != 202 && code != 204 {
return fmt.Errorf("Got %d HTTP deleting SuperHub Application, expected [202, 204] HTTP", code)
return fmt.Errorf("Got %d HTTP deleting HubCTL Application, expected [202, 204] HTTP", code)
}
return nil
}

func PatchApplication(selector string, change ApplicationPatch, waitAndTailDeployLogs bool) {
application, err := patchApplication(selector, change)
if err != nil {
log.Fatalf("Unable to patch SuperHub Application: %v", err)
log.Fatalf("Unable to patch HubCTL Application: %v", err)
}
formatApplication(application)
if waitAndTailDeployLogs {
Expand All @@ -327,15 +327,15 @@ func patchApplication(selector string, change ApplicationPatch) (*Application, e
return nil, err
}
if code != 200 && code != 202 {
return nil, fmt.Errorf("Got %d HTTP patching SuperHub Application, expected [200, 202] HTTP", code)
return nil, fmt.Errorf("Got %d HTTP patching HubCTL Application, expected [200, 202] HTTP", code)
}
return &jsResp, nil
}

func RawPatchApplication(selector string, body io.Reader, waitAndTailDeployLogs bool) {
application, err := rawPatchApplication(selector, body)
if err != nil {
log.Fatalf("Unable to patch SuperHub Application: %v", err)
log.Fatalf("Unable to patch HubCTL Application: %v", err)
}
formatApplication(application)
if waitAndTailDeployLogs {
Expand Down Expand Up @@ -371,7 +371,7 @@ func rawPatchApplication(selector string, body io.Reader) (*Application, error)
return nil, err
}
if code != 200 && code != 202 {
return nil, fmt.Errorf("Got %d HTTP patching SuperHub Application, expected [200, 204] HTTP", code)
return nil, fmt.Errorf("Got %d HTTP patching HubCTL Application, expected [200, 204] HTTP", code)
}
return &jsResp, nil
}
Loading

0 comments on commit d61d716

Please sign in to comment.