mirror of
https://github.com/LukeHagar/sailpoint-cli.git
synced 2025-12-06 12:47:44 +00:00
Changed the configuration to follow the new sail command
This commit is contained in:
51
README.md
51
README.md
@@ -24,7 +24,7 @@ make install
|
|||||||
After that, make sure you can run the `sail` command.
|
After that, make sure you can run the `sail` command.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sail -h
|
sail
|
||||||
```
|
```
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
@@ -44,45 +44,62 @@ C:\Program Files\sailpoint
|
|||||||
Once installed, make sure PowerShell can run the `sail` command.
|
Once installed, make sure PowerShell can run the `sail` command.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sail -h
|
sail
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Create a [personal access token](https://developer.sailpoint.com/docs/authentication.html#personal-access-tokens), which will be used to authenticate the SP CLI to your IdentityNow tenant.
|
Create a [personal access token](https://developer.sailpoint.com/idn/api/authentication#personal-access-tokens), which will be used to authenticate the SP CLI to your IdentityNow tenant.
|
||||||
|
|
||||||
Create a configuration file in your home directory to save your credentials.
|
Run the configure command to configure the CLI for your tenant. This command will create a configuration file in your home directory to store your tenant's connection details.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sail configure
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, you can manually create a configuration file in your home directory.
|
||||||
|
|
||||||
On Linux/Mac, run:
|
On Linux/Mac, run:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
mkdir ~/.sp
|
mkdir ~/.sailpoint
|
||||||
touch ~/.sp/config.yaml
|
touch ~/.sailpoint/config.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
On Windows PowerShell, run:
|
On Windows PowerShell, run:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
New-Item -ItemType Directory -Path 'C:\Users\<username>\.sp'
|
||||||
|
New-Item -ItemType File -Path 'C:\Users\<username>\.sp\config.yaml'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `config.yaml` should contain the following information.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
baseURL: https://{org}.api.cloud.sailpoint.com # or baseURL: https://localhost:7100
|
baseURL: https://{org}.api.identitynow.com # or baseURL: https://localhost:7100
|
||||||
tokenURL: https://{org}.api.cloud.sailpoint.com/oauth/token
|
tokenURL: https://{org}.api.identitynow.com/oauth/token
|
||||||
clientSecret: [clientSecret]
|
clientSecret: {clientSecret}
|
||||||
clientID: [clientID]
|
clientID: {clientID}
|
||||||
```
|
```
|
||||||
|
|
||||||
You may also specify the config as environment variables:
|
> TODO: Env variables aren't working yet
|
||||||
|
|
||||||
|
You may specify environment variables for your configuration. This can useful when using the CLI in an automated environment, like a CI/CD pipeline, where consuming the configuration from environment variables would be easier than creating the config file. Environment variables will override values defined in a config file.
|
||||||
|
|
||||||
|
On Linux/Mac, set the following environment variables:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ SP_CLI_BASEURL=http://localhost:7100 \
|
SAIL_BASEURL=https://{org}.api.identitynow.com
|
||||||
SP_CLI_TOKENURL=http://{org}.api.cloud.sailpoint.com \
|
SAIL_TOKENURL=https://{org}.api.identitynow.com/oauth/token
|
||||||
SP_CLI_CLIENTSECRET=xxxx sp conn list
|
SAIL_CLIENTID={clientID}
|
||||||
|
SAIL_CLIENTSECRET={clientSecret}
|
||||||
```
|
```
|
||||||
|
|
||||||
This can useful for cases like CI pipelines to avoid having to write the config
|
On Windows PowerShell run:
|
||||||
file.
|
|
||||||
|
```powershell
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const (
|
|||||||
func NewConnCmd(client client.Client) *cobra.Command {
|
func NewConnCmd(client client.Client) *cobra.Command {
|
||||||
conn := &cobra.Command{
|
conn := &cobra.Command{
|
||||||
Use: "connectors",
|
Use: "connectors",
|
||||||
Short: "Manage Connectors",
|
Short: "Manage connectors",
|
||||||
Aliases: []string{"conn"},
|
Aliases: []string{"conn"},
|
||||||
Run: func(command *cobra.Command, args []string) {
|
Run: func(command *cobra.Command, args []string) {
|
||||||
_, _ = fmt.Fprintf(command.OutOrStdout(), command.UsageString())
|
_, _ = fmt.Fprintf(command.OutOrStdout(), command.UsageString())
|
||||||
|
|||||||
@@ -16,18 +16,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
baseURLTemplate = "https://%s.api.cloud.sailpoint.com"
|
baseURLTemplate = "https://%s.api.identitynow.com"
|
||||||
tokenURLTemplate = "%s/oauth/token"
|
tokenURLTemplate = "%s/oauth/token"
|
||||||
configFolder = ".sp"
|
configFolder = ".sailpoint"
|
||||||
configYamlFile = "config.yaml"
|
configYamlFile = "config.yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrgConfig struct {
|
type OrgConfig struct {
|
||||||
Org string `mapstructure:"org"`
|
|
||||||
BaseUrl string `mapstructure:"baseURL"`
|
BaseUrl string `mapstructure:"baseURL"`
|
||||||
TokenUrl string `mapstructure:"tokenURL"`
|
TokenUrl string `mapstructure:"tokenURL"`
|
||||||
ClientSecret string `mapstructure:"clientSecret"`
|
ClientSecret string `mapstructure:"clientSecret"`
|
||||||
ClientID string `mapstructure:"clientID"`
|
ClientID string `mapstructure:"clientID"`
|
||||||
|
Debug bool `mapstructure:"debug"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConfigureCmd(client client.Client) *cobra.Command {
|
func newConfigureCmd(client client.Client) *cobra.Command {
|
||||||
@@ -65,18 +65,18 @@ func updateConfigFile(conf *OrgConfig) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(filepath.Join(home, ".sp")); os.IsNotExist(err) {
|
if _, err := os.Stat(filepath.Join(home, configFolder)); os.IsNotExist(err) {
|
||||||
err = os.Mkdir(filepath.Join(home, ".sp"), 0777)
|
err = os.Mkdir(filepath.Join(home, configFolder), 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to create .sp folder for config. %v", err)
|
log.Printf("failed to create %s folder for config. %v", configFolder, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("org", conf.Org)
|
|
||||||
viper.Set("baseUrl", conf.BaseUrl)
|
viper.Set("baseUrl", conf.BaseUrl)
|
||||||
viper.Set("tokenUrl", conf.TokenUrl)
|
viper.Set("tokenUrl", conf.TokenUrl)
|
||||||
viper.Set("clientSecret", conf.ClientSecret)
|
viper.Set("clientSecret", conf.ClientSecret)
|
||||||
viper.Set("clientID", conf.ClientID)
|
viper.Set("clientID", conf.ClientID)
|
||||||
|
viper.Set("debug", false)
|
||||||
|
|
||||||
err = viper.WriteConfig()
|
err = viper.WriteConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -97,7 +97,7 @@ func getConfigureParamsFromStdin() (*OrgConfig, error) {
|
|||||||
conf := &OrgConfig{}
|
conf := &OrgConfig{}
|
||||||
|
|
||||||
paramsNames := []string{
|
paramsNames := []string{
|
||||||
"Org Name: ",
|
"Base URL (ex. https://{org}.api.identitynow.com): ",
|
||||||
"Personal Access Token Client ID: ",
|
"Personal Access Token Client ID: ",
|
||||||
"Personal Access Token Client Secret: ",
|
"Personal Access Token Client Secret: ",
|
||||||
}
|
}
|
||||||
@@ -114,8 +114,7 @@ func getConfigureParamsFromStdin() (*OrgConfig, error) {
|
|||||||
|
|
||||||
switch pm {
|
switch pm {
|
||||||
case paramsNames[0]:
|
case paramsNames[0]:
|
||||||
conf.Org = value
|
conf.BaseUrl = value
|
||||||
conf.BaseUrl = fmt.Sprintf(baseURLTemplate, value)
|
|
||||||
conf.TokenUrl = fmt.Sprintf(tokenURLTemplate, conf.BaseUrl)
|
conf.TokenUrl = fmt.Sprintf(tokenURLTemplate, conf.BaseUrl)
|
||||||
case paramsNames[1]:
|
case paramsNames[1]:
|
||||||
conf.ClientID = value
|
conf.ClientID = value
|
||||||
|
|||||||
5
main.go
5
main.go
@@ -20,10 +20,11 @@ func initConfig() {
|
|||||||
home, err := os.UserHomeDir()
|
home, err := os.UserHomeDir()
|
||||||
cobra.CheckErr(err)
|
cobra.CheckErr(err)
|
||||||
|
|
||||||
viper.AddConfigPath(filepath.Join(home, ".sp"))
|
viper.AddConfigPath(filepath.Join(home, ".sailpoint"))
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigName("config")
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
viper.SetEnvPrefix("SP_CLI")
|
viper.SetEnvPrefix("sail")
|
||||||
|
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
if err := viper.ReadInConfig(); err != nil {
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user