Skip to content

Commit b748693

Browse files
author
Enda Phelan
committed
refactor: refactor the package structure and layout
1 parent 902fe5a commit b748693

506 files changed

Lines changed: 5596 additions & 5657 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ go run ./cmd/rhoas kafka create "test" --provider=aws --region=us-east-1
2626

2727
To use QA environment we need to login using following arguments
2828

29-
```
29+
```shell
3030
rhoas login --api-gateway=stage --mas-auth-url=stage
3131
```
3232

33-
3433
### Development features
3534

3635
To enable development and early access commands please set environment variable in your terminal:

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ endif
3333
# The details of the application:
3434
binary:=rhoas
3535

36-
amsapi_dir=./pkg/api/ams/amsclient
37-
rbacapi_dir=./pkg/api/rbac/rbacclient
36+
amsapi_dir=./pkg/apis/ams/amsclient
3837

3938
# Enable Go modules:
4039
export GO111MODULE=on
4140

4241
# Requires golangci-lint to be installed @ $(go env GOPATH)/bin/golangci-lint
4342
# https://golangci-lint.run/usage/install/
44-
lint: ## Lint Go files for errors
43+
lint: lint-lang ## Lint Go files for errors
4544
golangci-lint run cmd/... pkg/... internal/...
4645

4746
generate: ## Scan code for generate comments and run generators
@@ -58,7 +57,7 @@ install: ## Compile and install rhoas and add it to the PAth
5857
.PHONY: install
5958

6059
test: ## Run unit tests
61-
go test ./pkg/...
60+
go test ./pkg/... ./internal/...
6261
.PHONY: test
6362

6463
generate-ams-sdk: ## Generate the Account Management Service SDK
@@ -94,7 +93,7 @@ generate-modular-docs: generate-docs ## Generate modular command-line reference
9493

9594
lint-lang: ## Lint i18n files
9695
go install github.com/redhat-developer/app-services-go-linter/cmd/app-services-go-linter@latest
97-
app-services-go-linter ./...
96+
app-services-go-linter -path ./pkg/core/localize/locales ./...
9897
.PHONY: lint-lang
9998

10099
# Check http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html

cmd/modular-docs/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ package main
22

33
import (
44
"fmt"
5+
"github.com/redhat-developer/app-services-cli/internal/doc"
56
"os"
6-
7-
"github.com/redhat-developer/app-services-cli/internal/docs"
87
)
98

109
func main() {
11-
err := docs.CreateModularDocs()
10+
err := doc.CreateModularDocs()
1211
if err != nil {
1312
fmt.Print(err.Error())
1413
os.Exit(1)

cmd/rhoas/main.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ package main
33
import (
44
"context"
55
"fmt"
6+
"github.com/redhat-developer/app-services-cli/pkg/cmd/debug"
7+
"github.com/redhat-developer/app-services-cli/pkg/cmd/root"
68
"os"
79
"strings"
810

9-
"github.com/redhat-developer/app-services-cli/pkg/icon"
11+
"github.com/redhat-developer/app-services-cli/internal/telemetry"
12+
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/factory"
13+
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/factory/defaultfactory"
14+
"github.com/redhat-developer/app-services-cli/pkg/core/config"
15+
"github.com/redhat-developer/app-services-cli/pkg/core/ioutil/icon"
16+
"github.com/redhat-developer/app-services-cli/pkg/core/localize"
17+
"github.com/redhat-developer/app-services-cli/pkg/core/localize/goi18n"
18+
1019
"github.com/spf13/cobra"
1120

1221
"github.com/redhat-developer/app-services-cli/internal/build"
13-
"github.com/redhat-developer/app-services-cli/pkg/localize"
14-
"github.com/redhat-developer/app-services-cli/pkg/localize/goi18n"
15-
"github.com/redhat-developer/app-services-cli/pkg/telemetry"
16-
17-
"github.com/redhat-developer/app-services-cli/internal/config"
18-
19-
"github.com/redhat-developer/app-services-cli/pkg/cmd/debug"
20-
"github.com/redhat-developer/app-services-cli/pkg/cmd/factory"
21-
"github.com/redhat-developer/app-services-cli/pkg/cmd/root"
2222
)
2323

2424
func main() {
@@ -29,7 +29,7 @@ func main() {
2929
}
3030

3131
buildVersion := build.Version
32-
cmdFactory := factory.New(localizer)
32+
cmdFactory := defaultfactory.New(localizer)
3333

3434
err = initConfig(cmdFactory)
3535
if err != nil {

internal/build/build.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import (
66
"strings"
77
"time"
88

9+
"github.com/redhat-developer/app-services-cli/pkg/core/ioutil/color"
10+
"github.com/redhat-developer/app-services-cli/pkg/core/localize"
11+
"github.com/redhat-developer/app-services-cli/pkg/core/logging"
12+
913
"github.com/google/go-github/v39/github"
10-
"github.com/redhat-developer/app-services-cli/pkg/color"
11-
"github.com/redhat-developer/app-services-cli/pkg/localize"
12-
"github.com/redhat-developer/app-services-cli/pkg/logging"
1314
)
1415

1516
type buildSource string
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Copyright 2015 Red Hat Inc. All rights reserved.
21
// Copyright 2021 Red Hat Inc. All rights reserved.
32
//
43
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,7 +16,6 @@ package doc
1716
import (
1817
"bytes"
1918
"fmt"
20-
"github.com/spf13/pflag"
2119
"io"
2220
"os"
2321
"path/filepath"
@@ -26,6 +24,8 @@ import (
2624
"text/template"
2725
"time"
2826

27+
"github.com/spf13/pflag"
28+
2929
"github.com/spf13/cobra"
3030
)
3131

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
``# Generating AsciiDoc Docs For Your Own cobra.Command
1+
# Generating AsciiDoc Docs For Your Own cobra.Command
22

33
Generating AsciiDoc pages from a cobra command is incredibly easy. An example is as follows:
44

@@ -34,8 +34,8 @@ This program can actually generate docs for the kubectl command in the kubernete
3434
package main
3535

3636
import (
37-
"log"
3837
"io/ioutil"
38+
"log"
3939
"os"
4040

4141
"k8s.io/kubernetes/pkg/kubectl/cmd"
@@ -57,14 +57,15 @@ This will generate a whole series of files, one for each command in the tree, in
5757

5858
## Generate AsciiDoc docs for a single command
5959

60-
You may wish to have more control over the output, or only generate for a single command, instead of the entire command tree. If this is the case you may prefer to `GenAsciidoc` instead of `GenAsciidocTree`
60+
You may wish to have more control over the output, or only generate for a single command, instead of the entire command
61+
tree. If this is the case you may prefer to `GenAsciidoc` instead of `GenAsciidocTree`
6162

6263
```go
63-
out := new(bytes.Buffer)
64-
err := doc.GenAsciidoc(cmd, out)
65-
if err != nil {
66-
log.Fatal(err)
67-
}
64+
out := new(bytes.Buffer)
65+
err := doc.GenAsciidoc(cmd, out)
66+
if err != nil {
67+
log.Fatal(err)
68+
}
6869
```
6970

7071
This will write the AsciiDoc doc for ONLY "cmd" into the out, buffer.
@@ -74,18 +75,19 @@ This will write the AsciiDoc doc for ONLY "cmd" into the out, buffer.
7475
Both `GenAsciidoc` and `GenAsciidocTree` have alternate versions with callbacks to get some control of the output:
7576

7677
```go
77-
func GenAsciidocTreeCustom(cmd *Command, dir string, filePrepender, linkHandler func(string) string) error {
78+
func GenAsciidocTreeCustom(cmd *Command, dir string, filePrepender, linkHandler func (string) string) error {
7879
//...
7980
}
8081
```
8182

8283
```go
83-
func GenAsciidocCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) string) error {
84+
func GenAsciidocCustom(cmd *Command, out *bytes.Buffer, linkHandler func (string) string) error {
8485
//...
8586
}
8687
```
8788

88-
The `filePrepender` will prepend the return value given the full filepath to the rendered Asciidoc file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/):
89+
The `filePrepender` will prepend the return value given the full filepath to the rendered Asciidoc file. A common use
90+
case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/):
8991

9092
```go
9193
const fmTemplate = `---
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package docs
1+
package doc
22

33
import (
44
"fmt"
@@ -13,7 +13,7 @@ import (
1313
"github.com/pkg/errors"
1414
)
1515

16-
// Create Modular Documentation from the CLI generated docs
16+
// CreateModularDocs Create Modular Documentation from the CLI generated docs
1717
func CreateModularDocs() error {
1818
srcDir := os.Getenv("SRC_DIR")
1919
if srcDir == "" {

0 commit comments

Comments
 (0)