Skip to content

Commit

Permalink
CLI Unification: confluent context refactor (#973)
Browse files Browse the repository at this point in the history
* refactor context

* fix tests

* minor fixes

* fix lint

* fix int tests

* address code review comments

* fix integration test

* trigger build

* change init reference to context create

* remove integration test hacks

* require flag in context update

* fix tests

* remove ccloud_test

* code review

* fix integration tests

* trigger build

* exit on make deps error

* change goreleaser version

* try removing golangci-lint from make deps

* try to fix make deps versions

* make separate jenkins-deps target

* refactor

* make .tar.gz file in jenkinsfile

* clean up tarball packaging

* generate packaging patch

* reset golangci-lint version

* reset other package versions

* generate packaging patch

* try increasing the number of workers

* try 15 again

* try changing muckrake branch

* use unification branch

* trigger build

* trigger build
  • Loading branch information
brianstrauch committed Sep 20, 2021
1 parent a98b5b5 commit f0fe4d4
Show file tree
Hide file tree
Showing 68 changed files with 873 additions and 689 deletions.
15 changes: 7 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,15 @@ def job = {
mkdir -p $GOROOT/bin
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
echo "machine github.com\n\tlogin $GIT_USER\n\tpassword $GIT_TOKEN" > ~/.netrc
make deps
make jenkins-deps || exit 1
make build
cd dist/confluent
targz=$(ls *.tar.gz| head -1)
nn=confluent_SNAPSHOT-${HASH}_linux_amd64.tar.gz
mv $targz $nn
nnn=${nn%.tar.gz}
mkdir $nnn ; tar -C $(pwd)/$nnn -xzvf $nn ; rm $nn ; tar -cvzf ${nn} ${nnn}
aws s3api put-object --bucket confluent.cloud --key confluent-cli-system-test-builds/${nn} --body ${nn}
aws s3api put-object-acl --bucket confluent.cloud --key confluent-cli-system-test-builds/${nn} --acl public-read
dir=confluent_SNAPSHOT-${HASH}_linux_amd64
mv confluent_linux_amd64 $dir
tarball=$dir.tar.gz
tar -czf $tarball $dir
aws s3api put-object --bucket confluent.cloud --key confluent-cli-system-test-builds/$tarball --body $tarball
aws s3api put-object-acl --bucket confluent.cloud --key confluent-cli-system-test-builds/$tarball --acl public-read
'''
}
}
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ deps:
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.30.0 && \
go get github.com/mitchellh/golicense@v0.2.0

.PHONY: jenkins-deps
# Jenkins only depends on goreleaser, so we omit golangci-lint and golicense
jenkins-deps:
go get github.com/goreleaser/goreleaser@v0.164.0

ifeq ($(shell uname),Darwin)
SHASUM ?= gsha256sum
else ifneq (,$(findstring NT,$(shell uname)))
Expand Down
5 changes: 1 addition & 4 deletions cmd/lint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ var rules = []linter.Rule{
linter.ExcludeCommandContains("connect event describe"),
linter.ExcludeCommand("feedback"),
linter.ExcludeCommandContains("cloud-signup"),
// config context commands
linter.ExcludeCommand("config context current"),
linter.ExcludeCommandContains("config context get"),
linter.ExcludeCommandContains("config context set"),
linter.ExcludeCommandContains("context"),
linter.ExcludeCommandContains("audit-log"),
// skip admin commands since they have two args
linter.ExcludeCommandContains("admin"),
Expand Down
9 changes: 7 additions & 2 deletions debian/patches/standard_build_layout.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- cli/Makefile 2021-09-02 14:46:00.000000000 -0700
--- cli/Makefile 2021-09-15 09:46:32.000000000 -0700
+++ debian/Makefile 2021-08-26 16:04:24.000000000 -0700
@@ -1,202 +1,130 @@
@@ -1,207 +1,130 @@
-SHELL := /bin/bash
-ALL_SRC := $(shell find . -name "*.go" | grep -v -e vendor)
-GIT_REMOTE_NAME ?= origin
Expand Down Expand Up @@ -62,6 +62,11 @@
- go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.30.0 && \
- go get github.com/mitchellh/golicense@v0.2.0
-
-.PHONY: jenkins-deps
-# Jenkins only depends on goreleaser, so we omit golangci-lint and golicense
-jenkins-deps:
- go get github.com/goreleaser/goreleaser@v0.164.0
-
-ifeq ($(shell uname),Darwin)
-SHASUM ?= gsha256sum
-else ifneq (,$(findstring NT,$(shell uname)))
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ require (
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.5.2
github.com/golangci/golangci-lint v1.30.0
github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039 // indirect
github.com/google/go-cmp v0.5.5
github.com/google/go-github/v25 v25.0.2
github.com/google/go-github/v28 v28.1.1 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.2.0
github.com/goreleaser/goreleaser v0.164.0
Expand Down
7 changes: 1 addition & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,8 @@ github.com/golangci/misspell v0.0.0-20180809174111-950f5d19e770 h1:EL/O5HGrF7Jaq
github.com/golangci/misspell v0.0.0-20180809174111-950f5d19e770/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPPChZ7PhiVA=
github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21 h1:leSNB7iYzLYSSx3J/s5sVf4Drkc68W2wm4Ixh/mr0us=
github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21/go.mod h1:tf5+bzsHdTM0bsB7+8mt0GUMvjCgwLpTapNZHU8AajI=
github.com/golangci/revgrep v0.0.0-20180526074752-d9c87f5ffaf0 h1:HVfrLniijszjS1aiNg8JbBMO2+E1WIQ+j/gL4SQqGPg=
github.com/golangci/revgrep v0.0.0-20180526074752-d9c87f5ffaf0/go.mod h1:qOQCunEYvmd/TLamH+7LlVccLvUH5kZNhbCgTHoBbp4=
github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039 h1:XQKc8IYQOeRwVs36tDrEmTgDgP88d5iEURwpmtiAlOM=
github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039/go.mod h1:qOQCunEYvmd/TLamH+7LlVccLvUH5kZNhbCgTHoBbp4=
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 h1:zwtduBRr5SSWhqsYNgcuWO2kFlpdOZbP0+yRjmvPGys=
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
Expand All @@ -638,8 +637,6 @@ github.com/google/go-github/v18 v18.2.0 h1:s7Y4I8ZlIL1Ofxpj4AQRJcSGAr0Jl2AHThHgX
github.com/google/go-github/v18 v18.2.0/go.mod h1:Bf4Ut1RTeH0WuX7Z4Zf7N+qp/YqgcFOxvTLuSO+aY/k=
github.com/google/go-github/v25 v25.0.2 h1:MqXE7nOlIF91NJ/PXAcvS2dC+XXCDbY7RvJzjyEPAoU=
github.com/google/go-github/v25 v25.0.2/go.mod h1:6z5pC69qHtrPJ0sXPsj4BLnd82b+r6sLB7qcBoRZqpw=
github.com/google/go-github/v28 v28.1.1 h1:kORf5ekX5qwXO2mGzXXOjMe/g6ap8ahVe0sBEulhSxo=
github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM=
github.com/google/go-github/v35 v35.0.1-0.20210421135231-b235769d1606 h1:+8mvMVu+3yXBi/HdWq39mWbt/60u9qS+dkVZfjqEnt8=
github.com/google/go-github/v35 v35.0.1-0.20210421135231-b235769d1606/go.mod h1:s0515YVTI+IMrDoy9Y4pHt9ShGpzHvHO8rZ7L7acgvs=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
Expand Down Expand Up @@ -693,8 +690,6 @@ github.com/goreleaser/chglog v0.1.2 h1:tdzAb/ILeMnphzI9zQ7Nkq+T8R9qyXli8GydD8plF
github.com/goreleaser/chglog v0.1.2/go.mod h1:tTZsFuSZK4epDXfjMkxzcGbrIOXprf0JFp47BjIr3B8=
github.com/goreleaser/fileglob v1.2.0 h1:OErqbdzeg/eibfDGPHDQDN8jL5u1jNyxA5IQzNPLLoU=
github.com/goreleaser/fileglob v1.2.0/go.mod h1:rFyb2pXaK3YdnYnSjn6lifw0h2Q6s8OfOsx6I6bXkKE=
github.com/goreleaser/goreleaser v0.162.1 h1:NCMY3ZNx/aHpO0rgJIXe4ejd+g3dhxrIodsjTxoApZU=
github.com/goreleaser/goreleaser v0.162.1/go.mod h1:5WElSKi1ft66CyFDfowJdVOhR/JSwUqXeckGme5I4UI=
github.com/goreleaser/goreleaser v0.164.0 h1:w0zTtZSg9exA+eUoaFuZiJ5UuHaMom/TgXQvySAEJiY=
github.com/goreleaser/goreleaser v0.164.0/go.mod h1:gFyE4wWnpj09KPhjnWS3Dm7WJ2u85jylmWy5l/OZEH4=
github.com/goreleaser/nfpm/v2 v2.4.0 h1:OV8F+8XCIpvCUwOSU/aVahQK9UJJRdI5c4YP7NQIUjM=
Expand Down
14 changes: 6 additions & 8 deletions internal/cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@ import (
"github.com/spf13/cobra"

"github.com/confluentinc/cli/internal/cmd/admin"
apikey "github.com/confluentinc/cli/internal/cmd/api-key"
"github.com/confluentinc/cli/internal/cmd/api-key"
"github.com/confluentinc/cli/internal/cmd/audit-log"
cloudsignup "github.com/confluentinc/cli/internal/cmd/cloud-signup"
"github.com/confluentinc/cli/internal/cmd/cloud-signup"
"github.com/confluentinc/cli/internal/cmd/cluster"
"github.com/confluentinc/cli/internal/cmd/completion"
"github.com/confluentinc/cli/internal/cmd/config"
"github.com/confluentinc/cli/internal/cmd/connect"
"github.com/confluentinc/cli/internal/cmd/context"
"github.com/confluentinc/cli/internal/cmd/environment"
"github.com/confluentinc/cli/internal/cmd/iam"
initcontext "github.com/confluentinc/cli/internal/cmd/init"
"github.com/confluentinc/cli/internal/cmd/kafka"
"github.com/confluentinc/cli/internal/cmd/ksql"
"github.com/confluentinc/cli/internal/cmd/local"
"github.com/confluentinc/cli/internal/cmd/login"
"github.com/confluentinc/cli/internal/cmd/logout"
"github.com/confluentinc/cli/internal/cmd/price"
"github.com/confluentinc/cli/internal/cmd/prompt"
schemaregistry "github.com/confluentinc/cli/internal/cmd/schema-registry"
"github.com/confluentinc/cli/internal/cmd/schema-registry"
"github.com/confluentinc/cli/internal/cmd/secret"
serviceaccount "github.com/confluentinc/cli/internal/cmd/service-account"
"github.com/confluentinc/cli/internal/cmd/service-account"
"github.com/confluentinc/cli/internal/cmd/shell"
"github.com/confluentinc/cli/internal/cmd/update"
"github.com/confluentinc/cli/internal/cmd/version"
Expand Down Expand Up @@ -124,11 +123,10 @@ func NewConfluentCommand(cfg *v3.Config, isTest bool, ver *pversion.Version) *co
cli.AddCommand(cluster.New(prerunner, cluster.NewScopedIdService(ver.UserAgent, logger)))
cli.AddCommand(cloudsignup.New(prerunner, logger, ver.UserAgent, ccloudClientFactory).Command)
cli.AddCommand(completion.New(cli))
cli.AddCommand(config.New(cfg.IsCloudLogin(), prerunner, analyticsClient))
cli.AddCommand(context.New(prerunner, flagResolver))
cli.AddCommand(connectCmd.Command)
cli.AddCommand(environmentCmd.Command)
cli.AddCommand(iam.New(cfg, prerunner))
cli.AddCommand(initcontext.New(prerunner, flagResolver, analyticsClient))
cli.AddCommand(kafka.New(cfg, prerunner, logger.Named("kafka"), ver.ClientID, serverCompleter, analyticsClient))
cli.AddCommand(ksql.New(cfg, prerunner, serverCompleter, analyticsClient))
cli.AddCommand(local.New(prerunner))
Expand Down
14 changes: 7 additions & 7 deletions internal/cmd/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestHelp_NoContext(t *testing.T) {
require.NoError(t, err)

commands := []string{
"completion", "config", "help", "kafka", "local", "login", "logout", "signup", "update", "version",
"cloud-signup", "completion", "context", "help", "kafka", "local", "login", "logout", "update", "version",
}
if runtime.GOOS == "windows" {
commands = utils.Remove(commands, "local")
Expand All @@ -49,9 +49,9 @@ func TestHelp_Cloud(t *testing.T) {
require.NoError(t, err)

commands := []string{
"admin", "api-key", "audit-log", "cloud-signup", "completion", "config", "connect", "environment", "help",
"iam", "init", "kafka", "ksql", "login", "logout", "price", "prompt", "schema-registry", "service-account",
"shell", "update", "version",
"admin", "api-key", "audit-log", "cloud-signup", "completion", "context", "connect", "environment", "help",
"iam", "kafka", "ksql", "login", "logout", "price", "prompt", "schema-registry", "service-account", "shell",
"update", "version",
}

for _, command := range commands {
Expand All @@ -75,7 +75,7 @@ func TestHelp_CloudWithAPIKey(t *testing.T) {
require.NoError(t, err)

commands := []string{
"admin", "audit-log", "completion", "config", "help", "init", "kafka", "login", "logout", "signup", "update",
"admin", "audit-log", "cloud-signup", "completion", "context", "help", "kafka", "login", "logout", "update",
"version",
}

Expand All @@ -95,8 +95,8 @@ func TestHelp_OnPrem(t *testing.T) {
require.NoError(t, err)

commands := []string{
"audit-log", "cluster", "completion", "config", "connect", "help", "iam", "kafka", "ksql", "local", "login",
"logout", "schema-registry", "secret", "signup", "update", "version",
"audit-log", "cloud-signup", "cluster", "completion", "context", "connect", "help", "iam", "kafka", "ksql",
"local", "login", "logout", "schema-registry", "secret", "update", "version",
}
if runtime.GOOS == "windows" {
commands = utils.Remove(commands, "local")
Expand Down
33 changes: 0 additions & 33 deletions internal/cmd/config/command.go

This file was deleted.

Loading

0 comments on commit f0fe4d4

Please sign in to comment.