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

PDI-1947: Rename Tool and Cleanup #1

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
  •  
  •  
  •  
4 changes: 0 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@
.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
mkdocs.yml export-ignore
docs export-ignore
install.sh export-ignore
pingctl-test.sh export-ignore
36 changes: 18 additions & 18 deletions .github/workflows/code-analysis-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Code Analysis and Tests

on:
push:
branches: ["main", "go-cli"]
branches: ["main"]
pull_request:
paths:
- ".github/workflows/*"
Expand Down Expand Up @@ -124,27 +124,27 @@ jobs:
runs-on: ubuntu-latest
env:
PING_IDENTITY_CONFIG: ${{ secrets.PING_IDENTITY_CONFIG }}
PINGCTL_PINGONE_WORKER_CLIENT_ID: ${{ secrets.PINGCTL_PINGONE_WORKER_CLIENT_ID }}
PINGCTL_PINGONE_WORKER_CLIENT_SECRET: ${{ secrets.PINGCTL_PINGONE_WORKER_CLIENT_SECRET }}
PINGCTL_PINGONE_REGION_CODE: ${{ secrets.PINGCTL_PINGONE_REGION_CODE }}
PINGCTL_PINGONE_WORKER_ENVIRONMENT_ID: ${{ secrets.PINGCTL_PINGONE_WORKER_ENVIRONMENT_ID }}
PINGCTL_PINGONE_EXPORT_ENVIRONMENT_ID: ${{ secrets.PINGCTL_PINGONE_EXPORT_ENVIRONMENT_ID }}
PINGCLI_PINGONE_WORKER_CLIENT_ID: ${{ secrets.PINGCLI_PINGONE_WORKER_CLIENT_ID }}
PINGCLI_PINGONE_WORKER_CLIENT_SECRET: ${{ secrets.PINGCLI_PINGONE_WORKER_CLIENT_SECRET }}
PINGCLI_PINGONE_REGION_CODE: ${{ secrets.PINGCLI_PINGONE_REGION_CODE }}
PINGCLI_PINGONE_WORKER_ENVIRONMENT_ID: ${{ secrets.PINGCLI_PINGONE_WORKER_ENVIRONMENT_ID }}
PINGCLI_PINGONE_EXPORT_ENVIRONMENT_ID: ${{ secrets.PINGCLI_PINGONE_EXPORT_ENVIRONMENT_ID }}
PINGONE_CLIENT_ID: ${{ secrets.PINGONE_CLIENT_ID }}
PINGONE_CLIENT_SECRET: ${{ secrets.PINGONE_CLIENT_SECRET }}
PINGONE_ENVIRONMENT_ID: ${{ secrets.PINGONE_ENVIRONMENT_ID }}
PINGONE_REGION_CODE: ${{ secrets.PINGONE_REGION_CODE }}
PINGCTL_LOG_LEVEL: ${{ vars.PINGCTL_LOG_LEVEL }}
PINGCTL_LOG_PATH: ${{ vars.PINGCTL_LOG_PATH }}
PINGCTL_PINGONE_PROVIDER_VERSION: ${{ vars.PINGCTL_PINGONE_PROVIDER_VERSION }}
PINGCTL_PINGFEDERATE_ADMIN_API_PATH: ${{ secrets.PINGCTL_PINGFEDERATE_ADMIN_API_PATH }}
PINGCTL_PINGFEDERATE_CLIENT_ID: ${{ secrets.PINGCTL_PINGFEDERATE_CLIENT_ID }}
PINGCTL_PINGFEDERATE_CLIENT_SECRET: ${{ secrets.PINGCTL_PINGFEDERATE_CLIENT_SECRET }}
PINGCTL_PINGFEDERATE_HTTPS_HOST: ${{ secrets.PINGCTL_PINGFEDERATE_HTTPS_HOST }}
PINGCTL_PINGFEDERATE_PASSWORD: ${{ secrets.PINGCTL_PINGFEDERATE_PASSWORD }}
PINGCTL_PINGFEDERATE_SCOPES: ${{ secrets.PINGCTL_PINGFEDERATE_SCOPES }}
PINGCTL_PINGFEDERATE_TOKEN_URL: ${{ secrets.PINGCTL_PINGFEDERATE_TOKEN_URL }}
PINGCTL_PINGFEDERATE_USERNAME: ${{ secrets.PINGCTL_PINGFEDERATE_USERNAME }}
PINGCTL_PINGFEDERATE_PROVIDER_VERSION: ${{ vars.PINGCTL_PINGFEDERATE_PROVIDER_VERSION }}
PINGCLI_LOG_LEVEL: ${{ vars.PINGCLI_LOG_LEVEL }}
PINGCLI_LOG_PATH: ${{ vars.PINGCLI_LOG_PATH }}
PINGCLI_PINGONE_PROVIDER_VERSION: ${{ vars.PINGCLI_PINGONE_PROVIDER_VERSION }}
PINGCLI_PINGFEDERATE_ADMIN_API_PATH: ${{ secrets.PINGCLI_PINGFEDERATE_ADMIN_API_PATH }}
PINGCLI_PINGFEDERATE_CLIENT_ID: ${{ secrets.PINGCLI_PINGFEDERATE_CLIENT_ID }}
PINGCLI_PINGFEDERATE_CLIENT_SECRET: ${{ secrets.PINGCLI_PINGFEDERATE_CLIENT_SECRET }}
PINGCLI_PINGFEDERATE_HTTPS_HOST: ${{ secrets.PINGCLI_PINGFEDERATE_HTTPS_HOST }}
PINGCLI_PINGFEDERATE_PASSWORD: ${{ secrets.PINGCLI_PINGFEDERATE_PASSWORD }}
PINGCLI_PINGFEDERATE_SCOPES: ${{ secrets.PINGCLI_PINGFEDERATE_SCOPES }}
PINGCLI_PINGFEDERATE_TOKEN_URL: ${{ secrets.PINGCLI_PINGFEDERATE_TOKEN_URL }}
PINGCLI_PINGFEDERATE_USERNAME: ${{ secrets.PINGCLI_PINGFEDERATE_USERNAME }}
PINGCLI_PINGFEDERATE_PROVIDER_VERSION: ${{ vars.PINGCLI_PINGFEDERATE_PROVIDER_VERSION }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: "CodeQL"

on:
push:
branches: ["main", "go-cli"]
branches: ["main"]
pull_request:
paths:
- "**.go"
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/docs.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ builds:
# ID of the build.
#
# Default: Project directory name
id: "pingctl"
id: "pingcli"

# Binary name.
# Can be a path (e.g. `bin/app`) to wrap the binary in a directory.
#
# Default: Project directory name
binary: pingctl
binary: pingcli

# GOOS list to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
Expand Down
90 changes: 89 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,91 @@
# pingcli

Ping Identity Command Line Interface (CLI) tool.
The Ping CLI is a unified command line interface for configuring and managing Ping Identity Services.

## Install

<!-- TODO -->

## Configure Ping CLI

Before using the Ping CLI, you need to configure your Ping Identity Service profile(s). The following steps show the quickest path to configuration.

Start by running the command to create a new profile and answering the prompts.

```text
$ pingcli config add-profile
Pingcli configuration file '/Users/<me>/.pingcli/config.yaml' does not exist. - No Action (Warning)
Creating new pingcli configuration file at: /Users/<me>/.pingcli/config.yaml
New profile name: : dev
New profile description: : configuration for development environment
Set new profile as active: : y
Adding new profile 'dev'...
Profile created. Update additional profile attributes via 'pingcli config set' or directly within the config file at '/Users/<me>/.pingcli/config.yaml' - Success
Profile 'dev' set as active. - Success
```

Run `pingcli config view-profile` to generate a set of empty configuration.

```text
$ pingcli config view-profile
Profile: dev

color: true
description: configuration for development environment
export:
format: HCL
outputdirectory: /Users/samirgandhi/projects/terraform/UAT/pingcli-uat/export
overwrite: false
pingone:
environmentid: ""
# additional configuration trimmed
```

The available settings can be configured by editing the empty fields within the generated `~/.pingcli/config.yaml`. General Ping Identity service connection settings are found under the `service` key, and settings relevant to individual commands are found under their command names e.g. `export` and `request`.

To see descriptions for the settings the `export` command's help option.
```
pingcli platform export --help
```

## Commands

Ping CLI commands have the following structure:

```shell
pingcli <command> <subcommand> [options and parameters]
```

To get the version of Ping CLI:

```shell
pingcli --version
```

### Platform Export

The `pingcli platform export` command uses your configured settings to connect to the requested services and generate [Terraform import blocks](https://developer.hashicorp.com/terraform/language/import) for every supported resource available.

An example command to export a PingOne environment for HCL generation looks like:

```shell
pingctl platform export --services "pingone-platform,pingone-sso"

Choose a reason for hiding this comment

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

Reference to pingctl

```

The generated import blocks are organized into one folder with a file per resource type found. These import blocks can be used to [generate terraform configuration](https://developer.hashicorp.com/terraform/language/import/generating-configuration).

### Custom Request

The `pingcli request` command uses your configured settings to authenticate to the desired ping service before executing your API request.

An example command to view PingOne Environments looks like:

```shell
pingcli request --http-method GET --service pingone environments
```

## Getting Help

The best way to interact with our team is through Github. You can [open an issue](https://github.com/pingidentity/pingcli/issues/new) for guidance, bug reports, or feature requests.

Please check for similar open issues before opening a new one.
2 changes: 1 addition & 1 deletion cmd/auth/login.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package auth

import (
"github.com/pingidentity/pingctl/cmd/common"
"github.com/pingidentity/pingcli/cmd/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/auth/logout.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package auth

import (
"github.com/pingidentity/pingctl/cmd/common"
"github.com/pingidentity/pingcli/cmd/common"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/common/cobra_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package common_test
import (
"testing"

"github.com/pingidentity/pingctl/cmd/common"
"github.com/pingidentity/pingctl/internal/testing/testutils"
"github.com/pingidentity/pingcli/cmd/common"
"github.com/pingidentity/pingcli/internal/testing/testutils"
"github.com/spf13/cobra"
)

Expand Down
18 changes: 9 additions & 9 deletions cmd/config/add_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ package config
import (
"os"

"github.com/pingidentity/pingctl/cmd/common"
config_internal "github.com/pingidentity/pingctl/internal/commands/config"
"github.com/pingidentity/pingctl/internal/configuration/options"
"github.com/pingidentity/pingctl/internal/logger"
"github.com/pingidentity/pingcli/cmd/common"
config_internal "github.com/pingidentity/pingcli/internal/commands/config"
"github.com/pingidentity/pingcli/internal/configuration/options"
"github.com/pingidentity/pingcli/internal/logger"
"github.com/spf13/cobra"
)

const (
addProfilecommandExamples = ` pingctl config add-profile
pingctl config add-profile --name myprofile --description "My Profile desc"
pingctl config add-profile --set-active=true`
addProfilecommandExamples = ` pingcli config add-profile
pingcli config add-profile --name myprofile --description "My Profile desc"
pingcli config add-profile --set-active=true`
)

func NewConfigAddProfileCommand() *cobra.Command {
cmd := &cobra.Command{
Args: common.ExactArgs(0),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: addProfilecommandExamples,
Long: `Add a new configuration profile to pingctl.`,
Long: `Add a new configuration profile to pingcli.`,
RunE: configAddProfileRunE,
Short: "Add a new configuration profile to pingctl.",
Short: "Add a new configuration profile to pingcli.",
Use: "add-profile [flags]",
}

Expand Down
20 changes: 10 additions & 10 deletions cmd/config/add_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package config_test
import (
"testing"

"github.com/pingidentity/pingctl/internal/testing/testutils"
"github.com/pingidentity/pingctl/internal/testing/testutils_cobra"
"github.com/pingidentity/pingcli/internal/testing/testutils"
"github.com/pingidentity/pingcli/internal/testing/testutils_cobra"
)

// Test config add profile command executes without issue
func TestConfigAddProfileCmd_Execute(t *testing.T) {
err := testutils_cobra.ExecutePingctl(t, "config", "add-profile",
err := testutils_cobra.ExecutePingcli(t, "config", "add-profile",
"--name", "test-profile",
"--description", "test description",
"--set-active=false")
Expand All @@ -18,29 +18,29 @@ func TestConfigAddProfileCmd_Execute(t *testing.T) {

// Test config add profile command fails when provided too many arguments
func TestConfigAddProfileCmd_TooManyArgs(t *testing.T) {
expectedErrorPattern := `^failed to execute 'pingctl config add-profile': command accepts 0 arg\(s\), received 1$`
err := testutils_cobra.ExecutePingctl(t, "config", "add-profile", "extra-arg")
expectedErrorPattern := `^failed to execute 'pingcli config add-profile': command accepts 0 arg\(s\), received 1$`
err := testutils_cobra.ExecutePingcli(t, "config", "add-profile", "extra-arg")
testutils.CheckExpectedError(t, err, &expectedErrorPattern)
}

// Test config add profile command fails when provided an invalid flag
func TestConfigAddProfileCmd_InvalidFlag(t *testing.T) {
expectedErrorPattern := `^unknown flag: --invalid-flag$`
err := testutils_cobra.ExecutePingctl(t, "config", "add-profile", "--invalid-flag")
err := testutils_cobra.ExecutePingcli(t, "config", "add-profile", "--invalid-flag")
testutils.CheckExpectedError(t, err, &expectedErrorPattern)
}

// Test config add profile command fails when provided an invalid value for a flag
func TestConfigAddProfileCmd_InvalidFlagValue(t *testing.T) {
expectedErrorPattern := `^invalid argument ".*" for ".*" flag: strconv\.ParseBool: parsing ".*": invalid syntax$`
err := testutils_cobra.ExecutePingctl(t, "config", "add-profile", "--set-active", "invalid-value")
err := testutils_cobra.ExecutePingcli(t, "config", "add-profile", "--set-active", "invalid-value")
testutils.CheckExpectedError(t, err, &expectedErrorPattern)
}

// Test config add profile command fails when provided a duplicate profile name
func TestConfigAddProfileCmd_DuplicateProfileName(t *testing.T) {
expectedErrorPattern := `^failed to add profile: invalid profile name: '.*'\. profile already exists$`
err := testutils_cobra.ExecutePingctl(t, "config", "add-profile",
err := testutils_cobra.ExecutePingcli(t, "config", "add-profile",
"--name", "default",
"--description", "test description",
"--set-active=false")
Expand All @@ -50,7 +50,7 @@ func TestConfigAddProfileCmd_DuplicateProfileName(t *testing.T) {
// Test config add profile command fails when provided an invalid profile name
func TestConfigAddProfileCmd_InvalidProfileName(t *testing.T) {
expectedErrorPattern := `^failed to add profile: invalid profile name: '.*'\. name must contain only alphanumeric characters, underscores, and dashes$`
err := testutils_cobra.ExecutePingctl(t, "config", "add-profile",
err := testutils_cobra.ExecutePingcli(t, "config", "add-profile",
"--name", "pname&*^*&^$&@!",
"--description", "test description",
"--set-active=false")
Expand All @@ -60,7 +60,7 @@ func TestConfigAddProfileCmd_InvalidProfileName(t *testing.T) {
// Test config add profile command fails when provided an invalid set-active value
func TestConfigAddProfileCmd_InvalidSetActiveValue(t *testing.T) {
expectedErrorPattern := `^invalid argument ".*" for "-s, --set-active" flag: strconv\.ParseBool: parsing ".*": invalid syntax$`
err := testutils_cobra.ExecutePingctl(t, "config", "add-profile",
err := testutils_cobra.ExecutePingcli(t, "config", "add-profile",
"--name", "test-profile",
"--description", "test description",
"--set-active", "invalid-value")
Expand Down
Loading
Loading