Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor output format framework to support tables and empty format #1502

Closed
wants to merge 86 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
979f071
[WIP] [Updated] Issues #1429 and #1440
Mar 31, 2022
7456a23
Merge branch 'redhat-developer:main' into sdpcommandedit
Apr 4, 2022
d6242d9
[WIP] [Updated]: Issues #1429 and #1440
Apr 5, 2022
ffd911e
chore: bazzinga
wtrocki Apr 5, 2022
106a18d
chore: updated fix #1502
Apr 6, 2022
e3d67f5
chore: updated issue #1502
Apr 7, 2022
ce01938
fix: issue #1429 completed, awaiting verification
Apr 7, 2022
2e913a2
fix: support for tables and empty format
Apr 8, 2022
d1e4d95
chore: configure list.go to include table
Apr 12, 2022
02d2057
chore: updated list.go(s)
Apr 12, 2022
86d5edf
chore: updated fix for #1429 and .md files
Apr 19, 2022
ceaacd3
chore: fix and update docs
Apr 20, 2022
5c7a72b
chore: small fix for table option in output view
Apr 21, 2022
34f36bf
fix: update telemetry setup
wtrocki Apr 7, 2022
23b1887
fix: update go in CI/CD workflow (#1514)
wtrocki Apr 8, 2022
7a836a3
chore: update CHANGELOG
wtrocki Apr 8, 2022
93d028b
ci(release): fix unrecognized named-value
rkpattnaik780 Apr 8, 2022
049e10b
fix: update golang version
wtrocki Apr 8, 2022
43f0225
fix: update golang version
wtrocki Apr 8, 2022
8f03e3b
feat(context): add commands for context management
rkpattnaik780 Mar 3, 2022
6fd2dbc
feat(context): add command for context creation
rkpattnaik780 Mar 4, 2022
2698a92
fix(context): fixes bugs and add comments
rkpattnaik780 Mar 4, 2022
f3a9b27
refactor(context): change context to service context
rkpattnaik780 Mar 8, 2022
e7381b4
docs(context): improve help texts and add comments
rkpattnaik780 Mar 8, 2022
2abaa53
feat(context): add command to delete contexts
rkpattnaik780 Mar 9, 2022
f74cafa
fix: add validation for context create
rkpattnaik780 Mar 10, 2022
c1d330a
fix: add migration to the contexts
wtrocki Mar 11, 2022
6b98905
feat: alias status and use commands to context cmds
rkpattnaik780 Mar 15, 2022
5394604
feat(context create): remove setting services
rkpattnaik780 Mar 15, 2022
0d5862b
fix(context): examples of re-used commands
rkpattnaik780 Mar 16, 2022
f5d50a6
fix: address review comments
rkpattnaik780 Mar 16, 2022
5b8b711
fix: rename context maps
rkpattnaik780 Mar 16, 2022
2f0034d
docs(context): change examples
rkpattnaik780 Mar 16, 2022
dc76590
feat(context status): show context name and path
rkpattnaik780 Mar 21, 2022
e82a324
fix: handle custom context location
rkpattnaik780 Mar 22, 2022
22ac2a5
docs: add examples and loading order
rkpattnaik780 Mar 23, 2022
23edf26
refactor(service-registry): get current instance from context file (#…
rkpattnaik780 Mar 23, 2022
6dc22cf
refactor(cluster): use contexts for current instances
rkpattnaik780 Mar 24, 2022
40d4e50
refactor(kafka): get current instance from context file
rkpattnaik780 Mar 25, 2022
ca42b0e
refactor(context): rename profileutil and add flag completions
rkpattnaik780 Mar 28, 2022
ed01878
refactor(context): remove context handler struct
rkpattnaik780 Mar 28, 2022
d0cd302
refactor(context): reuse helper methods
rkpattnaik780 Mar 29, 2022
705aec0
fix: refactor status command
wtrocki Mar 30, 2022
9a5b57e
fix: status builder lint issues
wtrocki Apr 11, 2022
c0cdbb6
chore: update CHANGELOG
wtrocki Apr 11, 2022
3ad5d1e
feat(context): add generate-config command
rkpattnaik780 Mar 30, 2022
16b5727
docs: fix merge conflict
bhardesty Apr 6, 2022
9e9b0ff
fix: regenerate documentation
wtrocki Apr 11, 2022
70d0fe1
feat: token command (#1520)
wtrocki Apr 11, 2022
a99a452
fix: suspend updating modular docs for prereleases (#1521)
wtrocki Apr 11, 2022
9d64762
fix: enable self updating CLI (#1509)
wtrocki Apr 12, 2022
67c4d6d
chore: update CHANGELOG
rkpattnaik780 Apr 18, 2022
92f8c1e
fix(generate-config): change keyname to kafkaHost (#1528)
rkpattnaik780 Apr 20, 2022
618d648
fix: disable check for region (#1527)
wtrocki Apr 20, 2022
36bb6a7
chore: update CHANGELOG
wtrocki Apr 20, 2022
fa22a58
feat: initial implementation for connectors commands
wtrocki Apr 7, 2022
5ad269f
fix: default client
wtrocki Apr 7, 2022
28b25d6
fix: add remaining commands
wtrocki Apr 7, 2022
2ec5101
fix: add messages placeholders
wtrocki Apr 7, 2022
b0d6d74
fix: move messages generator
wtrocki Apr 7, 2022
1795e90
fix: add connectors to root
wtrocki Apr 7, 2022
a36cb62
fix: add example strings
wtrocki Apr 7, 2022
ea82d7e
fix: improve messages
wtrocki Apr 8, 2022
1d70446
fix: add parameters
wtrocki Apr 8, 2022
80550c9
fix: add create support
wtrocki Apr 8, 2022
c691896
fix: use default page size from build
wtrocki Apr 12, 2022
c1faa46
fix: remove invalid char in docs
wtrocki Apr 12, 2022
ff5eee3
fix: map connector status to row (#1518)
lburgazzoli Apr 11, 2022
d0784e3
feat(connector): add update and namespace commands
rkpattnaik780 Apr 13, 2022
f0a21a2
fix: update client to enable using external clients
wtrocki Apr 14, 2022
0dae5ae
fix: expose api config to enable using external clients and APIs (#1523)
lburgazzoli Apr 14, 2022
3610417
feat(connectors): add update cmd and enhance commands
rkpattnaik780 Apr 18, 2022
adbf41c
refactor(connector): rename connectors to connector
rkpattnaik780 Apr 19, 2022
0a516e5
feat(connector namespace): add delete command and refactors
rkpattnaik780 Apr 19, 2022
a4977b0
docs(context): format toml file and change helper text
rkpattnaik780 Apr 19, 2022
d94eb50
refactor(connector): move addon param to cluster cmd
rkpattnaik780 Apr 19, 2022
0b9cffa
fix: build failing at lint
rkpattnaik780 Apr 19, 2022
c328b0b
fix(connector): hide connector commands
rkpattnaik780 Apr 20, 2022
eff3724
fix(connector namespace): add validation
rkpattnaik780 Apr 20, 2022
0b4bdce
feat(service-registry): display compatibile API endpoints
rkpattnaik780 Apr 21, 2022
33ca6e8
fix: address review comments
rkpattnaik780 Apr 21, 2022
3f643cf
fix: change to info from error
rkpattnaik780 Apr 21, 2022
e9ffbaa
fix: change message for compatibility APIs
rkpattnaik780 Apr 22, 2022
0d5ee3e
docs(connector update): change erroneous message
rkpattnaik780 Apr 22, 2022
342c60c
chore: update CHANGELOG
rkpattnaik780 Apr 22, 2022
0f2f8e1
chore: update and fix issues
Apr 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
go-version: 1.17.x
- name: Checkout code
uses: actions/checkout@v2
- name: golangci-lint
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/modular-docs-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
name: Downstream docs publish

on:
push:
tags:
- 'v*'
#branches: [main]
release:
types: [released]

jobs:
build:
Expand All @@ -17,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
go-version: 1.17.x
- run: make generate-downstream-docs
name: Generate generate-downstream-docs
- name: Deploy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
go-version: 1.17.x

- name: Check tag
id: check-tag
Expand Down Expand Up @@ -74,9 +74,9 @@ jobs:
event-type: rhoas-cli-release
client-payload: '{"version": steps.set-version.outputs.version }'
tools-release:
if: steps.check-tag.outputs.prerelease == 'false'
needs: release
runs-on: ubuntu-latest
if: needs.release.steps.check-tag.outputs.prerelease == 'false'
steps:
- uses: actions/checkout@v2
- name: Notify tools repo
Expand Down
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
"whoami"
]
},
{
"name": "auth token",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/rhoas",
"env": {},
"args": [
"authtoken"
]
},
{
"name": "Logout",
"type": "go",
Expand Down
105 changes: 99 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,103 @@

<a name="v0.41.0"></a>
## [v0.41.0](https://github.com/redhat-developer/app-services-cli/compare/v0.40.1...v0.41.0) (2022-04-22)

### Bug Fixes

* change message for compatibility APIs
* change to info from error
* address review comments
* add remaining commands
* add messages placeholders
* build failing at lint
* expose api config to enable using external clients and APIs ([#1523](https://github.com/redhat-developer/app-services-cli/issues/1523))
* update client to enable using external clients
* map connector status to row ([#1518](https://github.com/redhat-developer/app-services-cli/issues/1518))
* remove invalid char in docs
* use default page size from build
* add create support
* add parameters
* improve messages
* add example strings
* add connectors to root
* move messages generator
* default client
* **connector:** hide connector commands
* **connector namespace:** add validation

### Features

* initial implementation for connectors commands
* **connector:** add update and namespace commands
* **connector namespace:** add delete command and refactors
* **connectors:** add update cmd and enhance commands
* **service-registry:** display compatibile API endpoints


<a name="v0.40.1"></a>
## [v0.40.1](https://github.com/redhat-developer/app-services-cli/compare/v0.40.0...v0.40.1) (2022-04-20)

### Bug Fixes

* disable check for region ([#1527](https://github.com/redhat-developer/app-services-cli/issues/1527))
* **generate-config:** change keyname to kafkaHost ([#1528](https://github.com/redhat-developer/app-services-cli/issues/1528))


<a name="v0.40.0"></a>
## [v0.40.0](https://github.com/redhat-developer/app-services-cli/compare/v0.39.0...v0.40.0) (2022-04-12)

### Bug Fixes

* include toml files in build ([#1477](https://github.com/redhat-developer/app-services-cli/issues/1477))
* suspend updating modular docs for prereleases ([#1521](https://github.com/redhat-developer/app-services-cli/issues/1521))
* regenerate documentation
* status builder lint issues
* refactor status command
* handle custom context location
* rename context maps
* address review comments
* message for partition limit ([#1459](https://github.com/redhat-developer/app-services-cli/issues/1459))
* add migration to the contexts
* add validation for context create
* build failing at test ([#1469](https://github.com/redhat-developer/app-services-cli/issues/1469))
* update golang version
* update golang version
* update go in CI/CD workflow ([#1514](https://github.com/redhat-developer/app-services-cli/issues/1514))
* update telemetry setup
* add server side backed up metrics ([#1493](https://github.com/redhat-developer/app-services-cli/issues/1493))
* add support for calling any endpoint from control plane ([#1497](https://github.com/redhat-developer/app-services-cli/issues/1497))
* changes required for Kafka SDK update ([#1470](https://github.com/redhat-developer/app-services-cli/issues/1470))
* enable self updating CLI ([#1509](https://github.com/redhat-developer/app-services-cli/issues/1509))
* **context:** fixes bugs and add comments
* **context:** examples of re-used commands
* **deps:** update docusaurus monorepo to v2.0.0-beta.18
* **deps:** update module github.com/golang-jwt/jwt/v4 to v4.4.0
* **deps:** update all
* **deps:** update module github.com/golang-jwt/jwt/v4 to v4.4.1
* **deps:** update module github.com/alecaivazis/survey/v2 to v2.3.4
* **deps:** update module github.com/alecaivazis/survey/v2 to v2.3.3
* **deps:** update docusaurus monorepo to v2.0.0-beta.17
* **deps:** update docusaurus monorepo to v2.0.0-beta.16
* **deps:** update golang.org/x/oauth2 commit hash to ee48083

### Features

* token command ([#1520](https://github.com/redhat-developer/app-services-cli/issues/1520))
* alias status and use commands to context cmds
* **context:** add generate-config command
* **context:** add command to delete contexts
* **context:** add command for context creation
* **context:** add commands for context management
* **context create:** remove setting services
* **context status:** show context name and path


<a name="v0.39.0"></a>
## [v0.39.0](https://github.com/redhat-developer/app-services-cli/compare/v0.38.6...v0.39.0) (2022-02-21)
## [v0.39.0](https://github.com/redhat-developer/app-services-cli/compare/v0.39.1...v0.39.0) (2022-02-21)


<a name="v0.39.1"></a>
## [v0.39.1](https://github.com/redhat-developer/app-services-cli/compare/v0.38.6...v0.39.1) (2022-02-21)

### Bug Fixes

Expand All @@ -26,11 +123,7 @@


<a name="v0.38.5"></a>
## [v0.38.5](https://github.com/redhat-developer/app-services-cli/compare/0.38.5...v0.38.5) (2022-02-15)


<a name="0.38.5"></a>
## [0.38.5](https://github.com/redhat-developer/app-services-cli/compare/v0.38.4...0.38.5) (2022-02-15)
## [v0.38.5](https://github.com/redhat-developer/app-services-cli/compare/v0.38.4...v0.38.5) (2022-02-15)

### Bug Fixes

Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ generate-downstream-docs: ## Generate command-line reference documentation in ad

I18N_LINTER_DEF := $(shell command -v app-services-go-linter 2> /dev/null)

lint-lang: ## Lint i18n files
ifndef I18N_LINTER_DEF # check if the linter is installed, install it if not
go install github.com/redhat-developer/app-services-go-linter/cmd/app-services-go-linter@latest
endif
app-services-go-linter -path ./pkg/core/localize/locales ./...
.PHONY: lint-lang
# lint-lang: ## Lint i18n files
# ifndef I18N_LINTER_DEF # check if the linter is installed, install it if not
# go install github.com/redhat-developer/app-services-go-linter/cmd/app-services-go-linter@latest
# endif
# app-services-go-linter -path ./pkg/core/localize/locales ./...
# .PHONY: lint-lang

# Check http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
Expand Down
4 changes: 2 additions & 2 deletions USAGE_DATA.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Note that these commands do not include `--help` commands. We do not collect dat
To disable collection of the usage data please set environment variable in your terminal:

```
RHOAS_TELEMETRY=true
```
RHOAS_TELEMETRY=false
```
68 changes: 66 additions & 2 deletions cmd/rhoas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"strings"

"github.com/redhat-developer/app-services-cli/pkg/cmd/root"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
"github.com/redhat-developer/app-services-cli/pkg/core/servicecontext"

"github.com/redhat-developer/app-services-cli/internal/telemetry"
"github.com/redhat-developer/app-services-cli/pkg/core/config"
Expand All @@ -32,12 +34,16 @@ func main() {
buildVersion := build.Version
cmdFactory := defaultfactory.New(localizer)

err = initConfig(cmdFactory)
if err != nil {
if err = initConfig(cmdFactory); err != nil {
cmdFactory.Logger.Errorf(localizer.MustLocalize("main.config.error", localize.NewEntry("Error", err)))
os.Exit(1)
}

if err = initProfiles(cmdFactory); err != nil {
cmdFactory.Logger.Errorf(localizer.MustLocalize("main.context.error", localize.NewEntry("Error", err)))
os.Exit(1)
}

rootCmd := root.NewRootCommand(cmdFactory, buildVersion)
rootCmd.InitDefaultHelpCmd()

Expand Down Expand Up @@ -87,6 +93,60 @@ func initConfig(f *factory.Factory) error {
return nil
}

func initProfiles(f *factory.Factory) error {
if !servicecontext.HasCustomLocation() {
rhoasCtxDir, err := config.DefaultDir()
if err != nil {
return err
}

// create rhoas config directory
if _, err = os.Stat(rhoasCtxDir); os.IsNotExist(err) {
err = os.MkdirAll(rhoasCtxDir, 0o700)
if err != nil {
return err
}
}
}

ctxFile, err := f.ServiceContext.Load()

if ctxFile != nil {
return err
}

if !os.IsNotExist(err) {
return err
}

configFile, err := f.Config.Load()

if err != nil {
return err
}

kafkaId, _ := configFile.GetKafkaIdOk()
serviceRegistryId, _ := configFile.GetServiceRegistryIdOk()
ctxFile = &servicecontext.Context{
CurrentContext: "default",
Contexts: map[string]servicecontext.ServiceConfig{
"default": {
KafkaID: kafkaId,
ServiceRegistryID: serviceRegistryId,
},
},
}

if err := f.ServiceContext.Save(ctxFile); err != nil {
return err
}

configFile.Services = config.ServiceConfigMap{}
_ = f.Config.Save(configFile)

return nil
}

// rootError creates the root error which is printed to the console
// it wraps the error which has been returned from subcommands with a prefix
func rootError(err error, localizer localize.Localizer) error {
Expand Down Expand Up @@ -119,6 +179,10 @@ func executeCommandWithTelemetry(rootCmd *cobra.Command, cmdFactory *factory.Fac
if cmd.Runnable() && !cmd.Hidden {
commandPath = cmd.CommandPath()
}
_, newErr := cmdutil.DoSelfUpdateOnceADay(cmdFactory)
if newErr != nil {
cmdFactory.Logger.Errorf(cmdFactory.Localizer.MustLocalize("main.update.error", localize.NewEntry("Error", newErr)))
}
}
err = rootCmd.Execute()

Expand Down
5 changes: 4 additions & 1 deletion docs/commands/rhoas.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions docs/commands/rhoas_authtoken.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading