mirror of
https://github.com/LukeHagar/sailpoint-cli.git
synced 2025-12-06 04:21:15 +00:00
Merge pull request #116 from sailpoint-oss/mtran/PLTCONN-4069
PLTCONN-4069: Limit number of account reads
This commit is contained in:
@@ -7,12 +7,13 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/sailpoint-oss/sailpoint-cli/internal/client"
|
|
||||||
"github.com/sailpoint-oss/sailpoint-cli/internal/config"
|
|
||||||
"github.com/sailpoint-oss/sailpoint-cli/internal/terminal"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
"github.com/sailpoint-oss/sailpoint-cli/internal/client"
|
||||||
|
"github.com/sailpoint-oss/sailpoint-cli/internal/config"
|
||||||
|
"github.com/sailpoint-oss/sailpoint-cli/internal/terminal"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -40,6 +41,7 @@ func NewConnCmd(term terminal.Terminal) *cobra.Command {
|
|||||||
Client := client.NewSpClient(Config)
|
Client := client.NewSpClient(Config)
|
||||||
|
|
||||||
conn.PersistentFlags().StringP("conn-endpoint", "e", connectorsEndpoint, "Override connectors endpoint")
|
conn.PersistentFlags().StringP("conn-endpoint", "e", connectorsEndpoint, "Override connectors endpoint")
|
||||||
|
conn.PersistentFlags().Int64("read-limit", accountReadLimit, "Set read limit for accounts and entitlements read")
|
||||||
|
|
||||||
conn.AddCommand(
|
conn.AddCommand(
|
||||||
newConnInitCommand(),
|
newConnInitCommand(),
|
||||||
|
|||||||
@@ -8,9 +8,14 @@ import (
|
|||||||
|
|
||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/olekukonko/tablewriter"
|
"github.com/olekukonko/tablewriter"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
connvalidate "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/validate"
|
connvalidate "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/validate"
|
||||||
"github.com/sailpoint-oss/sailpoint-cli/internal/client"
|
"github.com/sailpoint-oss/sailpoint-cli/internal/client"
|
||||||
"github.com/spf13/cobra"
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
accountReadLimit = 8
|
||||||
)
|
)
|
||||||
|
|
||||||
func newConnValidateCmd(apiClient client.Client) *cobra.Command {
|
func newConnValidateCmd(apiClient client.Client) *cobra.Command {
|
||||||
@@ -43,9 +48,15 @@ func newConnValidateCmd(apiClient client.Client) *cobra.Command {
|
|||||||
check := cmd.Flags().Lookup("check").Value.String()
|
check := cmd.Flags().Lookup("check").Value.String()
|
||||||
|
|
||||||
isReadOnly, _ := strconv.ParseBool(cmd.Flags().Lookup("read-only").Value.String())
|
isReadOnly, _ := strconv.ParseBool(cmd.Flags().Lookup("read-only").Value.String())
|
||||||
|
readLimitVal, err := getReadLimitVal(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid value of readLimit: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
valid := connvalidate.NewValidator(connvalidate.Config{
|
valid := connvalidate.NewValidator(connvalidate.Config{
|
||||||
Check: check,
|
Check: check,
|
||||||
ReadOnly: isReadOnly,
|
ReadOnly: isReadOnly,
|
||||||
|
ReadLimit: readLimitVal,
|
||||||
}, cc)
|
}, cc)
|
||||||
|
|
||||||
results, err := valid.Run(ctx)
|
results, err := valid.Run(ctx)
|
||||||
@@ -98,3 +109,14 @@ func newConnValidateCmd(apiClient client.Client) *cobra.Command {
|
|||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getReadLimitVal(cmd *cobra.Command) (int64, error) {
|
||||||
|
readLimitVal, err := cmd.Flags().GetInt64("read-limit")
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if readLimitVal <= 0 {
|
||||||
|
return 0, fmt.Errorf("readLimit value cannot be smaller than or equal to 0")
|
||||||
|
}
|
||||||
|
return readLimitVal, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ import (
|
|||||||
|
|
||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/olekukonko/tablewriter"
|
"github.com/olekukonko/tablewriter"
|
||||||
connvalidate "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/validate"
|
|
||||||
"github.com/sailpoint-oss/sailpoint-cli/internal/client"
|
|
||||||
"github.com/sailpoint-oss/sailpoint-cli/internal/util"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"gopkg.in/alessio/shellescape.v1"
|
"gopkg.in/alessio/shellescape.v1"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
connvalidate "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/validate"
|
||||||
|
"github.com/sailpoint-oss/sailpoint-cli/internal/client"
|
||||||
|
"github.com/sailpoint-oss/sailpoint-cli/internal/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Source struct {
|
type Source struct {
|
||||||
@@ -68,6 +69,10 @@ func newConnValidateSourcesCmd(apiClient client.Client) *cobra.Command {
|
|||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
endpoint := cmd.Flags().Lookup("conn-endpoint").Value.String()
|
endpoint := cmd.Flags().Lookup("conn-endpoint").Value.String()
|
||||||
|
readLimitVal, err := getReadLimitVal(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid value of readLimit: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
listOfSources, err := getSourceFromFile(sourceFile)
|
listOfSources, err := getSourceFromFile(sourceFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -83,7 +88,7 @@ func newConnValidateSourcesCmd(apiClient client.Client) *cobra.Command {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := validateConnectors(ctx, apiClient, source, endpoint)
|
res, err := validateConnectors(ctx, apiClient, source, endpoint, readLimitVal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -132,7 +137,7 @@ func getSourceFromFile(filePath string) ([]Source, error) {
|
|||||||
return config, err
|
return config, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateConnectors(ctx context.Context, apiClient client.Client, source Source, endpoint string) (*ValidationResults, error) {
|
func validateConnectors(ctx context.Context, apiClient client.Client, source Source, endpoint string, readLimit int64) (*ValidationResults, error) {
|
||||||
resp, err := apiClient.Get(ctx, endpoint)
|
resp, err := apiClient.Get(ctx, endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -170,8 +175,9 @@ func validateConnectors(ctx context.Context, apiClient client.Client, source Sou
|
|||||||
}
|
}
|
||||||
|
|
||||||
validator := connvalidate.NewValidator(connvalidate.Config{
|
validator := connvalidate.NewValidator(connvalidate.Config{
|
||||||
Check: "",
|
Check: "",
|
||||||
ReadOnly: source.ReadOnly,
|
ReadOnly: source.ReadOnly,
|
||||||
|
ReadLimit: readLimit,
|
||||||
}, cc)
|
}, cc)
|
||||||
|
|
||||||
results, err := validator.Run(ctx)
|
results, err := validator.Run(ctx)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kr/pretty"
|
"github.com/kr/pretty"
|
||||||
|
|
||||||
connclient "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/client"
|
connclient "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ var accountCreateChecks = []Check{
|
|||||||
RequiredCommands: []string{
|
RequiredCommands: []string{
|
||||||
"std:account:create",
|
"std:account:create",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
input := map[string]interface{}{}
|
input := map[string]interface{}{}
|
||||||
_, _, err := cc.AccountCreate(ctx, nil, input, nil)
|
_, _, err := cc.AccountCreate(ctx, nil, input, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -33,7 +34,7 @@ var accountCreateChecks = []Check{
|
|||||||
"std:account:read",
|
"std:account:read",
|
||||||
"std:account:delete",
|
"std:account:delete",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
input := map[string]interface{}{}
|
input := map[string]interface{}{}
|
||||||
for _, field := range spec.AccountCreateTemplate.Fields {
|
for _, field := range spec.AccountCreateTemplate.Fields {
|
||||||
if field.Required {
|
if field.Required {
|
||||||
@@ -79,7 +80,7 @@ var accountCreateChecks = []Check{
|
|||||||
"std:account:read",
|
"std:account:read",
|
||||||
"std:account:delete",
|
"std:account:delete",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
input := map[string]interface{}{}
|
input := map[string]interface{}{}
|
||||||
for _, field := range spec.AccountCreateTemplate.Fields {
|
for _, field := range spec.AccountCreateTemplate.Fields {
|
||||||
input[getFieldName(field)] = genCreateField(field)
|
input[getFieldName(field)] = genCreateField(field)
|
||||||
@@ -124,7 +125,7 @@ var accountCreateChecks = []Check{
|
|||||||
"std:account:delete",
|
"std:account:delete",
|
||||||
"std:account:list",
|
"std:account:list",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
accountsPreCreate, _, _, err := cc.AccountList(ctx, nil, nil, nil)
|
accountsPreCreate, _, _, err := cc.AccountList(ctx, nil, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err(err)
|
res.err(err)
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ package connvalidate
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/kr/pretty"
|
"github.com/kr/pretty"
|
||||||
|
|
||||||
connclient "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/client"
|
connclient "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,20 +20,30 @@ var accountReadChecks = []Check{
|
|||||||
"std:account:read",
|
"std:account:read",
|
||||||
"std:account:list",
|
"std:account:list",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
accounts, _, _, err := cc.AccountList(ctx, nil, nil, nil)
|
accounts, _, _, err := cc.AccountList(ctx, nil, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err(err)
|
res.err(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(accounts) == 0 {
|
||||||
|
res.warnf("no accounts")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, account := range accounts {
|
rand.Shuffle(len(accounts), func(i, j int) {
|
||||||
|
accounts[i], accounts[j] = accounts[j], accounts[i]
|
||||||
|
})
|
||||||
|
|
||||||
|
for index, account := range accounts {
|
||||||
|
if int64(index) == readLimit {
|
||||||
|
break
|
||||||
|
}
|
||||||
acct, _, err := cc.AccountRead(ctx, account.ID(), account.UniqueID(), nil)
|
acct, _, err := cc.AccountRead(ctx, account.ID(), account.UniqueID(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err(err)
|
res.err(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if acct.Identity != account.Identity {
|
if acct.Identity != account.Identity {
|
||||||
res.errf("want %q; got %q", account.Identity, acct.Identity)
|
res.errf("want %q; got %q", account.Identity, acct.Identity)
|
||||||
}
|
}
|
||||||
@@ -55,7 +67,7 @@ var accountReadChecks = []Check{
|
|||||||
RequiredCommands: []string{
|
RequiredCommands: []string{
|
||||||
"std:account:read",
|
"std:account:read",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
_, _, err := cc.AccountRead(ctx, "__sailpoint__not__found__", "", nil)
|
_, _, err := cc.AccountRead(ctx, "__sailpoint__not__found__", "", nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
res.errf("expected error for non-existant identity")
|
res.errf("expected error for non-existant identity")
|
||||||
@@ -69,7 +81,7 @@ var accountReadChecks = []Check{
|
|||||||
RequiredCommands: []string{
|
RequiredCommands: []string{
|
||||||
"std:account:list",
|
"std:account:list",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
additionalAttributes := map[string]string{}
|
additionalAttributes := map[string]string{}
|
||||||
|
|
||||||
attrsByName := map[string]connclient.AccountSchemaAttribute{}
|
attrsByName := map[string]connclient.AccountSchemaAttribute{}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var accountUpdateChecks = []Check{
|
|||||||
"std:account:list",
|
"std:account:list",
|
||||||
"std:account:update",
|
"std:account:update",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
accounts, _, _, err := cc.AccountList(ctx, nil, nil, nil)
|
accounts, _, _, err := cc.AccountList(ctx, nil, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err(err)
|
res.err(err)
|
||||||
@@ -72,7 +72,7 @@ var accountUpdateChecks = []Check{
|
|||||||
"std:account:update",
|
"std:account:update",
|
||||||
"std:account:delete",
|
"std:account:delete",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
entitlementAttr := entitlementAttr(spec)
|
entitlementAttr := entitlementAttr(spec)
|
||||||
if entitlementAttr == "" {
|
if entitlementAttr == "" {
|
||||||
res.warnf("no entitlement attribute")
|
res.warnf("no entitlement attribute")
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type Check struct {
|
|||||||
|
|
||||||
// IsDataModifier determines a checking that will modify connectors data after applying
|
// IsDataModifier determines a checking that will modify connectors data after applying
|
||||||
IsDataModifier bool
|
IsDataModifier bool
|
||||||
Run func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult)
|
Run func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64)
|
||||||
// RequiredCommands represents a list of commands that use for this check
|
// RequiredCommands represents a list of commands that use for this check
|
||||||
RequiredCommands []string
|
RequiredCommands []string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package connvalidate
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
"github.com/kr/pretty"
|
"github.com/kr/pretty"
|
||||||
|
|
||||||
connclient "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/client"
|
connclient "github.com/sailpoint-oss/sailpoint-cli/cmd/connector/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,7 +17,7 @@ var entitlementReadChecks = []Check{
|
|||||||
RequiredCommands: []string{
|
RequiredCommands: []string{
|
||||||
"std:entitlement:read",
|
"std:entitlement:read",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
_, _, err := cc.EntitlementRead(ctx, "__sailpoint__not__found__", "", "group", nil)
|
_, _, err := cc.EntitlementRead(ctx, "__sailpoint__not__found__", "", "group", nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
res.errf("expected error for non-existant entitlement")
|
res.errf("expected error for non-existant entitlement")
|
||||||
@@ -31,7 +33,7 @@ var entitlementReadChecks = []Check{
|
|||||||
"std:entitlement:read",
|
"std:entitlement:read",
|
||||||
"std:entitlement:list",
|
"std:entitlement:list",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
entitlements, _, _, err := cc.EntitlementList(ctx, "group", nil, nil, nil)
|
entitlements, _, _, err := cc.EntitlementList(ctx, "group", nil, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err(err)
|
res.err(err)
|
||||||
@@ -43,13 +45,19 @@ var entitlementReadChecks = []Check{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range entitlements {
|
rand.Shuffle(len(entitlements), func(i, j int) {
|
||||||
|
entitlements[i], entitlements[j] = entitlements[j], entitlements[i]
|
||||||
|
})
|
||||||
|
|
||||||
|
for index, e := range entitlements {
|
||||||
|
if int64(index) == readLimit {
|
||||||
|
break
|
||||||
|
}
|
||||||
eRead, _, err := cc.EntitlementRead(ctx, e.ID(), e.UniqueID(), "group", nil)
|
eRead, _, err := cc.EntitlementRead(ctx, e.ID(), e.UniqueID(), "group", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.errf("failed to read entitlement %q: %s", e.Identity, err.Error())
|
res.errf("failed to read entitlement %q: %s", e.Identity, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.Identity != eRead.Identity {
|
if e.Identity != eRead.Identity {
|
||||||
res.errf("want %q; got %q", e.Identity, eRead.Identity)
|
res.errf("want %q; got %q", e.Identity, eRead.Identity)
|
||||||
}
|
}
|
||||||
@@ -69,7 +77,7 @@ var entitlementReadChecks = []Check{
|
|||||||
RequiredCommands: []string{
|
RequiredCommands: []string{
|
||||||
"std:entitlement:list",
|
"std:entitlement:list",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
additionalAttributes := map[string]string{}
|
additionalAttributes := map[string]string{}
|
||||||
|
|
||||||
attrsByName := map[string]connclient.EntitlementSchemaAttribute{}
|
attrsByName := map[string]connclient.EntitlementSchemaAttribute{}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ var testConnChecks = []Check{
|
|||||||
RequiredCommands: []string{
|
RequiredCommands: []string{
|
||||||
"std:test-connection",
|
"std:test-connection",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
err := cc.TestConnectionWithConfig(ctx, json.RawMessage("{}"))
|
err := cc.TestConnectionWithConfig(ctx, json.RawMessage("{}"))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
res.errf("expected test-connection failure for empty config")
|
res.errf("expected test-connection failure for empty config")
|
||||||
@@ -29,7 +29,7 @@ var testConnChecks = []Check{
|
|||||||
RequiredCommands: []string{
|
RequiredCommands: []string{
|
||||||
"std:test-connection",
|
"std:test-connection",
|
||||||
},
|
},
|
||||||
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult) {
|
Run: func(ctx context.Context, spec *connclient.ConnSpec, cc *connclient.ConnClient, res *CheckResult, readLimit int64) {
|
||||||
_, err := cc.TestConnection(ctx)
|
_, err := cc.TestConnection(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err(err)
|
res.err(err)
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ type Config struct {
|
|||||||
// ReadOnly specifies a type of validation.
|
// ReadOnly specifies a type of validation.
|
||||||
// If ReadOnly set 'true' validator will run all checks that don't make any modifications.
|
// If ReadOnly set 'true' validator will run all checks that don't make any modifications.
|
||||||
ReadOnly bool
|
ReadOnly bool
|
||||||
|
|
||||||
|
// ReadLimit specifies whether to limit the number of account read
|
||||||
|
// If ReadLimit set 'true', check for account and entitlement read will only read 8 accounts
|
||||||
|
ReadLimit int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewValidator creates a new validator with provided config and ConnClient
|
// NewValidator creates a new validator with provided config and ConnClient
|
||||||
@@ -62,7 +66,7 @@ func (v *Validator) Run(ctx context.Context) (results []CheckResult, err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ok, results := isCheckPossible(spec.Commands, check.RequiredCommands); ok {
|
if ok, results := isCheckPossible(spec.Commands, check.RequiredCommands); ok {
|
||||||
check.Run(ctx, spec, v.cc, res)
|
check.Run(ctx, spec, v.cc, res, v.cfg.ReadLimit)
|
||||||
} else {
|
} else {
|
||||||
res.skipf("Skipping check due to unimplemented commands on a connector: %s", strings.Join(results, ", "))
|
res.skipf("Skipping check due to unimplemented commands on a connector: %s", strings.Join(results, ", "))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user