Skip to content

Commit

Permalink
Merge branch 'main' into feature/webdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-hagar-sp authored Mar 9, 2023
2 parents c393841 + eb8a6ad commit ec21a69
Show file tree
Hide file tree
Showing 1,211 changed files with 21,018 additions and 590 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Release

on:
push:
branches:
- main
tags:
- "*"

Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ sailpoint-cli

data
.DS_Store
assets/demo_create.json
assets/demo_update.json
cmd/transform/test_data/test_create.json
cmd/transform/test_data/test_update.json
example_transforms
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ Documentation
The SailPoint CLI is a terminal-based tool you can use to to interact with your IdentityNow (IDN) tenant. The CLI provides a text-based environment you can use to run operations known as "commands" to interact with your tenant however you want.

For documentation, please see https://developer.sailpoint.com/idn/tools/cli

22 changes: 20 additions & 2 deletions cmd/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
)

func NewConfigureCmd() *cobra.Command {
var ClientID string
var ClientSecret string
var err error
cmd := &cobra.Command{
Use: "configure",
Short: "Configure PAT Authentication for the currently active environment",
Expand All @@ -16,15 +19,30 @@ func NewConfigureCmd() *cobra.Command {
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {

ClientID := terminal.InputPrompt("Personal Access Token Client ID:")
if ClientID == "" {
ClientID, err = terminal.PromptPassword("Personal Access Token Client ID:")
if err != nil {
return err
}
}

config.SetPatClientID(ClientID)

ClientSecret := terminal.InputPrompt("Personal Access Token Client Secret:")
if ClientSecret == "" {
ClientSecret, err = terminal.PromptPassword("Personal Access Token Client Secret:")
if err != nil {
return err
}
}

config.SetPatClientSecret(ClientSecret)

return nil
},
}

cmd.Flags().StringVarP(&ClientID, "ClientID", "i", "", "The client id to use for PAT authentication")
cmd.Flags().StringVarP(&ClientSecret, "ClientSecret", "s", "", "The client secret to use for PAT authentication")

return cmd
}
20 changes: 17 additions & 3 deletions cmd/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import (
"github.com/sailpoint-oss/sailpoint-cli/internal/log"
"github.com/sailpoint-oss/sailpoint-cli/internal/terminal"
"github.com/sailpoint-oss/sailpoint-cli/internal/tui"
"github.com/sailpoint-oss/sailpoint-cli/internal/util"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/exp/maps"
)

func NewEnvironmentCommand() *cobra.Command {
var env string
var overwrite bool
var erase bool
var show bool
cmd := &cobra.Command{
Use: "environment",
Short: "change currently active environment",
Expand Down Expand Up @@ -41,9 +45,16 @@ func NewEnvironmentCommand() *cobra.Command {
if env != "" {
config.SetActiveEnvironment(env)

if _, exists := environments[env]; exists && !overwrite && config.GetTenantUrl() != "" && config.GetBaseUrl() != "" {

log.Log.Info("Environment changed", "env", env)
if foundEnv, exists := environments[env]; exists && !overwrite && config.GetTenantUrl() != "" && config.GetBaseUrl() != "" {
if show {
log.Log.Warn("printing env", "env", env)
util.PrettyPrint(foundEnv)
} else if erase {
log.Log.Warn("erasing env", "env", env)
viper.Set("environments."+config.GetActiveEnvironment(), config.Environment{})
} else {
log.Log.Info("Environment changed", "env", env)
}

} else {

Expand All @@ -63,6 +74,9 @@ func NewEnvironmentCommand() *cobra.Command {
}

cmd.Flags().BoolVarP(&overwrite, "overwrite", "o", false, "use to overwrite an existing environments configuration")
cmd.Flags().BoolVarP(&erase, "erase", "e", false, "use to erase an existing environments configuration")
cmd.Flags().BoolVarP(&show, "show", "s", false, "use to show an existing environments configuration")
cmd.MarkFlagsMutuallyExclusive("overwrite", "erase", "show")

return cmd

Expand Down
2 changes: 1 addition & 1 deletion cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/spf13/cobra"
)

var version = "0.5.0"
var version = "0.6.0"

func NewRootCmd() *cobra.Command {
root := &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/root/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/golang/mock/gomock"
)

// Expected number of subcommands to `sp` root command
// Expected number of subcommands to `sail` root command
const (
numRootSubcommands = 8
)
Expand Down
95 changes: 95 additions & 0 deletions cmd/search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Search

The `search` command makes it easy to search in identitynow using the SailPoint CLI.

- [Search](#search)
- [Query](#query)
- [Command](#command)
- [Flags](#flags)
- [Indicies](#indicies)
- [Sort](#sort)
- [Output Types](#output-types)
- [Folder Path](#folder-path)
- [Template](#template)
- [Command](#command-1)
- [Flags](#flags-1)
- [Output Types](#output-types-1)
- [Folder Path](#folder-path-1)

## Query

### Command

Run the following command to search with manually provided search attributes.

```shell
sail search query <search query string> -indicies <indicie to search on>
```

### Flags

#### Indicies

Specifies the indicies to run the search operation on

```shell
sail search query "name:a*" -indicies identities
```

You can search multiple indicies by added additional flags

```shell
sail search query "name:a*" -indicies identities -indicies accessprofiles
```

#### Sort

Specified the sort strings used for the search query

```shell
sail search query "name:a*" -indicies identities -sort name -sort "-created"
```

#### Output Types

Specify the output data format currently `json` and `csv` are the only supported types

```shell
sail search query "name:a*" -indicies identities -outputTypes json
```

#### Folder Path

Specify the folder path to save the search results in

```shell
sail search query "name:a*" -indicies identities -folderPath ./local/folder/path
```

## Template

### Command

Run the following command to search with a predefined template.

```shell
sail search template all-provisioning-events-90-days
```

### Flags

#### Output Types

Specify the output data format currently `json` and `csv` are the only supported types

```shell
sail search query "name:a*" -indicies identities -outputTypes json
```

#### Folder Path

Specify the folder path to save the search results in

```shell
sail search query "name:a*" -indicies identities -folderPath ./local/folder/path
```
18 changes: 9 additions & 9 deletions cmd/search/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (

func newQueryCmd() *cobra.Command {
var folderPath string
var indicies []string
var indices []string
var outputTypes []string
var sort []string
var searchQuery string
cmd := &cobra.Command{
Use: "query",
Short: "search using a query",
Long: "Run a search query in identitynow using a query",
Example: "sail search query",
Example: "sail search query \"attributes.location:london\"",
Aliases: []string{"que"},
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -38,19 +38,19 @@ func newQueryCmd() *cobra.Command {
searchQuery = args[0]
fmt.Println(searchQuery)

searchObj, err := search.BuildSearch(searchQuery, sort, indicies)
searchObj, err := search.BuildSearch(searchQuery, sort, indices)
if err != nil {
return err
}

log.Log.Info("Performing Search", "Query", searchQuery, "Indicies", indicies)
log.Log.Info("Performing Search", "Query", searchQuery, "Indices", indices)

formattedResponse, err := search.PerformSearch(*apiClient, searchObj)
if err != nil {
return err
}

err = search.IterateIndicies(formattedResponse, searchQuery, folderPath, outputTypes)
err = search.IterateIndices(formattedResponse, searchQuery, folderPath, outputTypes)
if err != nil {
return err
}
Expand All @@ -59,12 +59,12 @@ func newQueryCmd() *cobra.Command {
},
}

cmd.Flags().StringArrayVarP(&indicies, "indicies", "i", []string{}, "indicies to perform the search query on")
cmd.Flags().StringArrayVarP(&sort, "sort", "s", []string{}, "the sort value for the api call (examples)")
cmd.Flags().StringArrayVarP(&outputTypes, "output types", "o", []string{"json"}, "the sort value for the api call (examples)")
cmd.Flags().StringArrayVarP(&indices, "indices", "i", []string{}, "indices to perform the search query on (accessprofiles, accountactivities, entitlements, events, identities, roles)")
cmd.Flags().StringArrayVarP(&sort, "sort", "s", []string{}, "the sort value for the api call (displayName, +id...)")
cmd.Flags().StringArrayVarP(&outputTypes, "outputTypes", "o", []string{"json"}, "the output types for the results (csv, json)")
cmd.Flags().StringVarP(&folderPath, "folderPath", "f", "search_results", "folder path to save the search results in. If the directory doesn't exist, then it will be automatically created. (default is the current working directory)")

cmd.MarkFlagRequired("indicies")
cmd.MarkFlagRequired("indices")

return cmd
}
11 changes: 5 additions & 6 deletions cmd/search/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"strings"

"github.com/fatih/color"
"github.com/sailpoint-oss/sailpoint-cli/internal/config"
"github.com/sailpoint-oss/sailpoint-cli/internal/log"
"github.com/sailpoint-oss/sailpoint-cli/internal/search"
Expand Down Expand Up @@ -57,21 +56,21 @@ func newTemplateCmd() *cobra.Command {
return fmt.Errorf("no template specified")
}

color.Blue("Selected Template: %s\n", template)
log.Log.Info("Selected Template", "template", template)

matches := types.Filter(searchTemplates, func(st templates.SearchTemplate) bool { return st.Name == template })
if len(matches) < 1 {
return fmt.Errorf("no template matches for %s", template)
} else if len(matches) > 1 {
color.Yellow("multiple template matches for %s", template)
log.Log.Warn("multiple template matches, the first match will be used", "template", template)
}
selectedTemplate = matches[0]
varCount := len(selectedTemplate.Variables)
if varCount > 0 {
for i := 0; i < varCount; i++ {
varEntry := selectedTemplate.Variables[i]
resp := terminal.InputPrompt(fmt.Sprintf("Input %s:", varEntry.Prompt))
selectedTemplate.Raw = []byte(strings.ReplaceAll(string(selectedTemplate.Raw), fmt.Sprintf("{{%s}}", varEntry.Name), resp))
resp := terminal.InputPrompt("Input " + varEntry.Prompt + ":")
selectedTemplate.Raw = []byte(strings.ReplaceAll(string(selectedTemplate.Raw), "{{"+varEntry.Name+"}}", resp))
}
err := json.Unmarshal(selectedTemplate.Raw, &selectedTemplate.SearchQuery)
if err != nil {
Expand All @@ -86,7 +85,7 @@ func newTemplateCmd() *cobra.Command {
return err
}

err = search.IterateIndicies(formattedResponse, selectedTemplate.SearchQuery.Query.GetQuery(), folderPath, outputTypes)
err = search.IterateIndices(formattedResponse, selectedTemplate.SearchQuery.Query.GetQuery(), folderPath, outputTypes)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit ec21a69

Please sign in to comment.