Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ go run ./cmd/rhoas kafka create "test" --provider=aws --region=us-east-1

To use QA environment we need to login using following arguments

```
```shell
rhoas login --api-gateway=stage --mas-auth-url=stage
```


### Development features

To enable development and early access commands please set environment variable in your terminal:
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ endif
binary:=rhoas

amsapi_dir=./pkg/api/ams/amsclient
rbacapi_dir=./pkg/api/rbac/rbacclient

# Enable Go modules:
export GO111MODULE=on

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

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

test: ## Run unit tests
go test ./pkg/...
go test ./pkg/... ./internal/...
.PHONY: test

generate-ams-sdk: ## Generate the Account Management Service SDK
Expand Down Expand Up @@ -92,9 +91,13 @@ generate-modular-docs: generate-docs ## Generate modular command-line reference
SRC_DIR=$$(pwd)/docs/commands DEST_DIR=$$(pwd)/dist go run ./cmd/modular-docs
.PHONY: generate-modular-docs

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
app-services-go-linter ./...
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
Expand Down
5 changes: 2 additions & 3 deletions cmd/modular-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package main

import (
"fmt"
"github.com/redhat-developer/app-services-cli/internal/doc"
"os"

"github.com/redhat-developer/app-services-cli/internal/docs"
)

func main() {
err := docs.CreateModularDocs()
err := doc.CreateModularDocs()
if err != nil {
fmt.Print(err.Error())
os.Exit(1)
Expand Down
22 changes: 11 additions & 11 deletions cmd/rhoas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ package main
import (
"context"
"fmt"
"github.com/redhat-developer/app-services-cli/pkg/cmd/debug"
"github.com/redhat-developer/app-services-cli/pkg/cmd/root"
"os"
"strings"

"github.com/redhat-developer/app-services-cli/pkg/icon"
"github.com/redhat-developer/app-services-cli/internal/telemetry"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/factory"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/factory/defaultfactory"
"github.com/redhat-developer/app-services-cli/pkg/core/config"
"github.com/redhat-developer/app-services-cli/pkg/core/ioutil/icon"
"github.com/redhat-developer/app-services-cli/pkg/core/localize"
"github.com/redhat-developer/app-services-cli/pkg/core/localize/goi18n"

"github.com/spf13/cobra"

"github.com/redhat-developer/app-services-cli/internal/build"
"github.com/redhat-developer/app-services-cli/pkg/localize"
"github.com/redhat-developer/app-services-cli/pkg/localize/goi18n"
"github.com/redhat-developer/app-services-cli/pkg/telemetry"

"github.com/redhat-developer/app-services-cli/internal/config"

"github.com/redhat-developer/app-services-cli/pkg/cmd/debug"
"github.com/redhat-developer/app-services-cli/pkg/cmd/factory"
"github.com/redhat-developer/app-services-cli/pkg/cmd/root"
)

func main() {
Expand All @@ -29,7 +29,7 @@ func main() {
}

buildVersion := build.Version
cmdFactory := factory.New(localizer)
cmdFactory := defaultfactory.New(localizer)

err = initConfig(cmdFactory)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"strings"
"time"

"github.com/redhat-developer/app-services-cli/pkg/core/ioutil/color"
"github.com/redhat-developer/app-services-cli/pkg/core/localize"
"github.com/redhat-developer/app-services-cli/pkg/core/logging"

"github.com/google/go-github/v39/github"
"github.com/redhat-developer/app-services-cli/pkg/color"
"github.com/redhat-developer/app-services-cli/pkg/localize"
"github.com/redhat-developer/app-services-cli/pkg/logging"
)

type buildSource string
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Copyright 2015 Red Hat Inc. All rights reserved.
// Copyright 2021 Red Hat Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,7 +16,6 @@ package doc
import (
"bytes"
"fmt"
"github.com/spf13/pflag"
"io"
"os"
"path/filepath"
Expand All @@ -26,6 +24,8 @@ import (
"text/template"
"time"

"github.com/spf13/pflag"

"github.com/spf13/cobra"
)

Expand Down
24 changes: 13 additions & 11 deletions pkg/doc/modular_adoc_docs.md → internal/doc/modular_adoc_docs.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
``# Generating AsciiDoc Docs For Your Own cobra.Command
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind excluding those changes as well.

There is #1352 that addresses that

# Generating AsciiDoc Docs For Your Own cobra.Command

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

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

import (
"log"
"io/ioutil"
"log"
"os"

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

## Generate AsciiDoc docs for a single command

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`
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`

```go
out := new(bytes.Buffer)
err := doc.GenAsciidoc(cmd, out)
if err != nil {
log.Fatal(err)
}
out := new(bytes.Buffer)
err := doc.GenAsciidoc(cmd, out)
if err != nil {
log.Fatal(err)
}
```

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

```go
func GenAsciidocTreeCustom(cmd *Command, dir string, filePrepender, linkHandler func(string) string) error {
func GenAsciidocTreeCustom(cmd *Command, dir string, filePrepender, linkHandler func (string) string) error {
//...
}
```

```go
func GenAsciidocCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) string) error {
func GenAsciidocCustom(cmd *Command, out *bytes.Buffer, linkHandler func (string) string) error {
//...
}
```

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/):
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/):

```go
const fmTemplate = `---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docs
package doc

import (
"fmt"
Expand All @@ -13,7 +13,7 @@ import (
"github.com/pkg/errors"
)

// Create Modular Documentation from the CLI generated docs
// CreateModularDocs Create Modular Documentation from the CLI generated docs
func CreateModularDocs() error {
srcDir := os.Getenv("SRC_DIR")
if srcDir == "" {
Expand Down
File renamed without changes.
29 changes: 8 additions & 21 deletions internal/mockutil/mockutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"errors"

kafkamgmtclient "github.com/redhat-developer/app-services-sdk-go/kafkamgmt/apiv1/client"
"github.com/redhat-developer/app-services-cli/pkg/core/config"
"github.com/redhat-developer/app-services-cli/pkg/core/connection"
"github.com/redhat-developer/app-services-cli/pkg/core/connection/api"
"github.com/redhat-developer/app-services-cli/pkg/core/connection/kcconnection"

"github.com/redhat-developer/app-services-cli/internal/config"
"github.com/redhat-developer/app-services-cli/pkg/api"
"github.com/redhat-developer/app-services-cli/pkg/connection"
kafkamgmtclient "github.com/redhat-developer/app-services-sdk-go/kafkamgmt/apiv1/client"
)

func NewConfigMock(cfg *config.Config) config.IConfig {
Expand All @@ -30,7 +31,7 @@ func NewConfigMock(cfg *config.Config) config.IConfig {
}
}

func NewConnectionMock(conn *connection.KeycloakConnection, apiClient *kafkamgmtclient.APIClient) connection.Connection {
func NewConnectionMock(conn *kcconnection.Connection, apiClient *kafkamgmtclient.APIClient) connection.Connection {
return &connection.ConnectionMock{
RefreshTokensFunc: func(ctx context.Context) error {
if conn.Token.AccessToken == "" && conn.Token.RefreshToken == "" {
Expand Down Expand Up @@ -62,22 +63,8 @@ func NewConnectionMock(conn *connection.KeycloakConnection, apiClient *kafkamgmt

return conn.Config.Save(cfg)
},
APIFunc: func() *api.API {
a := &api.API{
Kafka: func() kafkamgmtclient.DefaultApi {
return apiClient.DefaultApi
},
}

return a
APIFunc: func() api.API {
return nil
},
}
}

func NewKafkaRequestTypeMock(name string) kafkamgmtclient.KafkaRequest {
var kafkaReq kafkamgmtclient.KafkaRequest
kafkaReq.SetId("1")
kafkaReq.SetName(name)

return kafkaReq
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package telemetry

import (
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/factory"
"os"
"runtime"
"strconv"
"time"

"github.com/AlecAivazis/survey/v2"
"github.com/redhat-developer/app-services-cli/internal/build"
"github.com/redhat-developer/app-services-cli/pkg/cmd/factory"
)

// Telemetry structure
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ams
package accountmgmtutil

type TermsAndConditionsSpec struct {
Kafka ServiceTermsSpec `json:"kafka"`
Expand Down
5 changes: 3 additions & 2 deletions pkg/ams/ams.go → pkg/accountmgmtutil/ams.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package ams
package accountmgmtutil

import (
"context"
"errors"

"github.com/redhat-developer/app-services-cli/pkg/core/connection"

"github.com/redhat-developer/app-services-cli/pkg/api/ams/amsclient"
"github.com/redhat-developer/app-services-cli/pkg/connection"
)

func CheckTermsAccepted(ctx context.Context, spec ServiceTermsSpec, conn connection.Connection) (accepted bool, redirectURI string, err error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/ams/terms.go → pkg/accountmgmtutil/terms.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package ams
package accountmgmtutil

import (
"context"
"encoding/json"
"github.com/redhat-developer/app-services-cli/pkg/core/logging"
"io/ioutil"
"net/http"

"github.com/redhat-developer/app-services-cli/internal/build"
"github.com/redhat-developer/app-services-cli/pkg/logging"
)

// Contains specification for terms and condition parameters
Expand Down
Loading