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.
|
||||
|
||||
```shell
|
||||
sail -h
|
||||
sail
|
||||
```
|
||||
|
||||
### Windows
|
||||
@@ -44,45 +44,62 @@ C:\Program Files\sailpoint
|
||||
Once installed, make sure PowerShell can run the `sail` command.
|
||||
|
||||
```shell
|
||||
sail -h
|
||||
sail
|
||||
```
|
||||
|
||||
## 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:
|
||||
|
||||
```shell
|
||||
mkdir ~/.sp
|
||||
touch ~/.sp/config.yaml
|
||||
mkdir ~/.sailpoint
|
||||
touch ~/.sailpoint/config.yaml
|
||||
```
|
||||
|
||||
On Windows PowerShell, run:
|
||||
|
||||
```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
|
||||
baseURL: https://{org}.api.cloud.sailpoint.com # or baseURL: https://localhost:7100
|
||||
tokenURL: https://{org}.api.cloud.sailpoint.com/oauth/token
|
||||
clientSecret: [clientSecret]
|
||||
clientID: [clientID]
|
||||
baseURL: https://{org}.api.identitynow.com # or baseURL: https://localhost:7100
|
||||
tokenURL: https://{org}.api.identitynow.com/oauth/token
|
||||
clientSecret: {clientSecret}
|
||||
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
|
||||
$ SP_CLI_BASEURL=http://localhost:7100 \
|
||||
SP_CLI_TOKENURL=http://{org}.api.cloud.sailpoint.com \
|
||||
SP_CLI_CLIENTSECRET=xxxx sp conn list
|
||||
SAIL_BASEURL=https://{org}.api.identitynow.com
|
||||
SAIL_TOKENURL=https://{org}.api.identitynow.com/oauth/token
|
||||
SAIL_CLIENTID={clientID}
|
||||
SAIL_CLIENTSECRET={clientSecret}
|
||||
```
|
||||
|
||||
This can useful for cases like CI pipelines to avoid having to write the config
|
||||
file.
|
||||
On Windows PowerShell run:
|
||||
|
||||
```powershell
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ const (
|
||||
func NewConnCmd(client client.Client) *cobra.Command {
|
||||
conn := &cobra.Command{
|
||||
Use: "connectors",
|
||||
Short: "Manage Connectors",
|
||||
Short: "Manage connectors",
|
||||
Aliases: []string{"conn"},
|
||||
Run: func(command *cobra.Command, args []string) {
|
||||
_, _ = fmt.Fprintf(command.OutOrStdout(), command.UsageString())
|
||||
|
||||
@@ -16,18 +16,18 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
baseURLTemplate = "https://%s.api.cloud.sailpoint.com"
|
||||
baseURLTemplate = "https://%s.api.identitynow.com"
|
||||
tokenURLTemplate = "%s/oauth/token"
|
||||
configFolder = ".sp"
|
||||
configFolder = ".sailpoint"
|
||||
configYamlFile = "config.yaml"
|
||||
)
|
||||
|
||||
type OrgConfig struct {
|
||||
Org string `mapstructure:"org"`
|
||||
BaseUrl string `mapstructure:"baseURL"`
|
||||
TokenUrl string `mapstructure:"tokenURL"`
|
||||
ClientSecret string `mapstructure:"clientSecret"`
|
||||
ClientID string `mapstructure:"clientID"`
|
||||
Debug bool `mapstructure:"debug"`
|
||||
}
|
||||
|
||||
func newConfigureCmd(client client.Client) *cobra.Command {
|
||||
@@ -65,18 +65,18 @@ func updateConfigFile(conf *OrgConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := os.Stat(filepath.Join(home, ".sp")); os.IsNotExist(err) {
|
||||
err = os.Mkdir(filepath.Join(home, ".sp"), 0777)
|
||||
if _, err := os.Stat(filepath.Join(home, configFolder)); os.IsNotExist(err) {
|
||||
err = os.Mkdir(filepath.Join(home, configFolder), 0777)
|
||||
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("tokenUrl", conf.TokenUrl)
|
||||
viper.Set("clientSecret", conf.ClientSecret)
|
||||
viper.Set("clientID", conf.ClientID)
|
||||
viper.Set("debug", false)
|
||||
|
||||
err = viper.WriteConfig()
|
||||
if err != nil {
|
||||
@@ -97,7 +97,7 @@ func getConfigureParamsFromStdin() (*OrgConfig, error) {
|
||||
conf := &OrgConfig{}
|
||||
|
||||
paramsNames := []string{
|
||||
"Org Name: ",
|
||||
"Base URL (ex. https://{org}.api.identitynow.com): ",
|
||||
"Personal Access Token Client ID: ",
|
||||
"Personal Access Token Client Secret: ",
|
||||
}
|
||||
@@ -114,8 +114,7 @@ func getConfigureParamsFromStdin() (*OrgConfig, error) {
|
||||
|
||||
switch pm {
|
||||
case paramsNames[0]:
|
||||
conf.Org = value
|
||||
conf.BaseUrl = fmt.Sprintf(baseURLTemplate, value)
|
||||
conf.BaseUrl = value
|
||||
conf.TokenUrl = fmt.Sprintf(tokenURLTemplate, conf.BaseUrl)
|
||||
case paramsNames[1]:
|
||||
conf.ClientID = value
|
||||
|
||||
5
main.go
5
main.go
@@ -20,10 +20,11 @@ func initConfig() {
|
||||
home, err := os.UserHomeDir()
|
||||
cobra.CheckErr(err)
|
||||
|
||||
viper.AddConfigPath(filepath.Join(home, ".sp"))
|
||||
viper.AddConfigPath(filepath.Join(home, ".sailpoint"))
|
||||
viper.SetConfigName("config")
|
||||
viper.SetConfigType("yaml")
|
||||
viper.SetEnvPrefix("SP_CLI")
|
||||
viper.SetEnvPrefix("sail")
|
||||
|
||||
viper.AutomaticEnv()
|
||||
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user