Skip to content

Commit

Permalink
Merge pull request #140 from akamai/release/1.4.0
Browse files Browse the repository at this point in the history
Release/1.4.0
  • Loading branch information
robertolopezlopez authored Mar 14, 2022
2 parents e86a288 + be50d6d commit 7f7a9f4
Show file tree
Hide file tree
Showing 75 changed files with 2,047 additions and 570 deletions.
42 changes: 42 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
linters:
disable-all: true
enable:
- revive

output:
sort-results: true

issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0

linters-settings:
revive:
ignore-generated-header: true
severity: warning
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# 1.4.0 (March 14, 2022)

## Enhancements

* [IMPORTANT] Refactor Python support, making use of virtual environments to isolate dependencies for each Python package.
* Refer to README.md for new system dependencies.

# 1.3.1 (December 8, 2021)

## Enhancements

* Improved message for updating CLI version

# 1.3.0 (October 6, 2021)

## Fixes

* Remove old binary in PowerShell terminal ([#125](https://github.com/akamai/cli/issues/125)).
* Document CLI exit codes.
* Review exit code when trying to install an already installed command ([#83](https://github.com/akamai/cli/issues/83)).
Expand Down
113 changes: 87 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,102 @@
BIN = $(CURDIR)/bin
GOCMD = go
GOTEST = $(GOCMD) test
GOBUILD = $(GOCMD) build
M = $(shell echo ">")

$(BIN):
@mkdir -p $@
$(BIN)/%: | $(BIN) ; $(info $(M) Installing $(PACKAGE)...)
@tmp=$$(mktemp -d); \
env GO111MODULE=off GOPATH=$$tmp GOBIN=$(BIN) $(GOCMD) get $(PACKAGE) \
|| ret=$$?; \
rm -rf $$tmp ; exit $$ret

GOIMPORTS = $(BIN)/goimports
$(BIN)/goimports: PACKAGE=golang.org/x/tools/cmd/goimports

GOCOV = $(BIN)/gocov
$(BIN)/gocov: PACKAGE=github.com/axw/gocov/...

GOCOVXML = $(BIN)/gocov-xml
$(BIN)/gocov-xml: PACKAGE=github.com/AlekSi/gocov-xml

GOJUNITREPORT = $(BIN)/go-junit-report
$(BIN)/go-junit-report: PACKAGE=github.com/jstemmer/go-junit-report

GOLANGCILINT = $(BIN)/golangci-lint
GOLANGCI_LINT_VERSION = v1.41.1
$(BIN)/golangci-lint: ; $(info $(M) Installing golangci-lint...)
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN) $(GOLANGCI_LINT_VERSION)

COVERAGE_MODE = atomic
COVERAGE_DIR = $(CURDIR)/test/coverage
COVERAGE_PROFILE = $(COVERAGE_DIR)/profile.out
COVERAGE_XML = $(COVERAGE_DIR)/coverage.xml
COVERAGE_HTML = $(COVERAGE_DIR)/index.html

.PHONY: all
all: fmt lint vet coverage
all: clean fmt-check lint coverage create-junit-report create-coverage-files clean-tools

.PHONY: build
build:
go build -o akamai cli/main.go
build: ; $(info $(M) Building 'akamai' binary...) @ ## Build the binary from source
$(GOBUILD) -o $(CURDIR)/akamai cli/main.go

.PHONY: test
test:
go test -count=1 ./...

.PHONY: coverage-ui
coverage-ui:
go test -covermode=count -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
test: ; $(info $(M) Running tests...) ## Run all unit tests
$(GOTEST) -count=1 ./...

.PHONY: coverage
coverage:
go test -coverprofile coverage.out ./...
go tool cover -func coverage.out | grep total
coverage: ; $(info $(M) Running tests with coverage...) @ ## Run tests and generate coverage profile
@mkdir -p $(COVERAGE_DIR)
@$(GOTEST) -v -covermode=$(COVERAGE_MODE) \
-coverprofile="$(COVERAGE_PROFILE)" ./... | tee test/tests.output

.PHONY: lint
lint:
golint -set_exit_status ./...
.PHONY: create-junit-report
create-junit-report: | $(GOJUNITREPORT) ; $(info $(M) Creating juint xml report) @ ## Generate junit-style coverage report
@cat $(CURDIR)/test/tests.output | $(GOJUNITREPORT) > $(CURDIR)/test/tests.xml
@sed -i -e 's/skip=/skipped=/g;s/ failures=/ errors="0" failures=/g' $(CURDIR)/test/tests.xml

.PHONY: create-coverage-files
create-coverage-files: | $(GOCOV) $(GOCOVXML); $(info $(M) Creating coverage files...) @ ## Generate coverage report files
@$(GOCMD) tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML)
@$(GOCOV) convert $(COVERAGE_PROFILE) | $(GOCOVXML) > $(COVERAGE_XML)

.PHONY: vet
vet:
go vet ./...
.PHONY: lint
lint: | $(GOLANGCILINT); $(info $(M) Running linter...) @ ## Run golangci-lint on all source files
@$(BIN)/golangci-lint run

.PHONY: fmt
fmt:
go fmt ./...
fmt: | $(GOIMPORTS); $(info $(M) Running goimports...) @ ## Run goimports on all source files
@$(GOIMPORTS) -w .

.PHONY: release
release:
./build.sh
.PHONY: fmt-check
fmt-check: | $(GOIMPORTS); $(info $(M) Running format and imports check...) @ ## Run goimports on all source files (do not modify files)
$(eval OUTPUT = $(shell $(GOIMPORTS) -l .))
@if [ "$(OUTPUT)" != "" ]; then\
echo "Found following files with incorrect format and/or imports:";\
echo "$(OUTPUT)";\
false;\
fi

.PHONY: release
release: ; $(info $(M) Generating release binaries and signatures...) @ ## Generate release binaries
@./build.sh

.PHONY: pack
pack:
tar -zcvf cli.tar.gz .
pack: ; $(info $(M) Generating tarball...) @ ## Create cli tarball
@tar -zcf cli.tar.gz *

.PHONY: ; clean
clean: ; $(info $(M) Removing 'bin' directory and test results...) @ ## Cleanup installed packages and test reports
@rm -rf $(BIN)
@rm -rf $(BIN)/test/tests.* $(BIN)/test/coverage

clean-tools: ## Cleanup installed packages
@rm -rf $(BIN)/go*

.PHONY: help
help: ## List all make targets
echo $(MAKEFILE_LIST)
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">
<h1 style="text-align: center">
<br>
<img src="assets/screen-1.png">
<img alt="Akamai CLI usage" src="assets/screen-1.png">
<br>
</h1>

Expand Down Expand Up @@ -29,6 +29,15 @@ Install Akamai CLI by downloading a [release binary](https://github.com/akamai/c

You can also use [Homebrew](#install-with-homebrew), [Docker](#install-with-docker), or compile from [source](#compile-from-source).

### System dependencies for Python-based packages

If you're using a Python-based CLI package, install these extra dependencies:

- Python 3.3 or above
- [Python 3 `pip` package installer](https://pip.pypa.io/en/stable/installation)
- [Python 3 `venv` module](https://docs.python.org/3/library/venv.html)
- Up-to-date common CA certificates for your operating system (PEM files)

### Install from binaries

Follow the instructions for your operating system.
Expand Down Expand Up @@ -284,16 +293,16 @@ The package you install needs a `cli.json` file. This is where you specify the c
- `commands`: Lists commands included in the package.
- `name`: The command name, used as the executable name.
- `aliases`: An array of aliases that invoke the same command.
- `version`: The command version.
- `version`: The command version.
- `description`: A short description for the command.
- `bin`: A URL to fetch a binary package from if it cannot be installed from source.

The `bin` URL may contain the following placeholders:

- `{{.Version}}`: The command version.
- `{{.Name}}`: The command name.
- `{{.Version}}`: The command version.
- `{{.Name}}`: The command name.
- `{{.OS}}`: The current operating system, either `windows`, `mac`, or `linux`.
- `{{.Arch}}`: The current OS architecture, either `386` or `amd64`.
- `{{.Arch}}`: The current OS architecture, either `386` or `amd64`.
- `{{.BinSuffix}}`: The binary suffix for the current OS: `.exe` for `windows`.

### Example
Expand Down
25 changes: 18 additions & 7 deletions assets/package-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,24 @@


{
"title": "Certificate Provisioning Service (CPS)",
"name": "cps",
"version": "v1.0.8",
"url": "https://github.com/akamai/cli-cps",
"issues": "https://github.com/akamai/cli-cps/issues",
"commands": [{"name":"cps","aliases":["certs"],"version":"1.0.8","description":"Access Certificate Provisioning System (CPS) Information"}],
"requirements": {"python":"3.0.0"}
"title": "Certificate Provisioning Service (CPS)",
"name": "cps",
"version": "v1.0.9",
"url": "https://github.com/akamai/cli-cps",
"issues": "https://github.com/akamai/cli-cps/issues",
"commands": [
{
"name": "cps",
"aliases": [
"certs"
],
"version": "1.0.9",
"description": "Access Certificate Provisioning System (CPS) Information"
}
],
"requirements": {
"python": "3.0.0"
}
},


Expand Down
1 change: 1 addition & 0 deletions cli/app/access_nix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

// Copyright 2018. Akamai Technologies, Inc
Expand Down
9 changes: 4 additions & 5 deletions cli/app/firstrun.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !nofirstrun
//go:build !nofirstrun
// +build !nofirstrun

// Copyright 2018. Akamai Technologies, Inc
//
Expand All @@ -23,14 +24,12 @@ import (
"runtime"
"strings"

"github.com/fatih/color"
"github.com/kardianos/osext"

"github.com/akamai/cli/pkg/config"

"github.com/akamai/cli/pkg/stats"
"github.com/akamai/cli/pkg/terminal"
"github.com/akamai/cli/pkg/tools"
"github.com/fatih/color"
"github.com/kardianos/osext"
)

const (
Expand Down
4 changes: 3 additions & 1 deletion cli/app/firstrun_noinstall.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build nofirstrun
//go:build nofirstrun
// +build nofirstrun

// Copyright 2018. Akamai Technologies, Inc
//
Expand All @@ -18,6 +19,7 @@ package app

import (
"context"

"github.com/akamai/cli/pkg/stats"
)

Expand Down
10 changes: 2 additions & 8 deletions cli/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,12 @@ func findCollisions(availableCmds []*cli.Command, args []string) error {
metaCmds := []string{"help", "uninstall", "update"}
for _, c := range metaCmds {
if c == args[1] && len(args) > 2 {
if err := findDuplicate(availableCmds, args[2]); err != nil {
return err
}

return nil
return findDuplicate(availableCmds, args[2])
}
}

// rest of commands: we need to check the first parameter (args[1])
if err := findDuplicate(availableCmds, args[1]); err != nil {
return err
}
return findDuplicate(availableCmds, args[1])
}

return nil
Expand Down
Loading

0 comments on commit 7f7a9f4

Please sign in to comment.