utils

package
v0.0.0-...-9c4b67b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName       = "IAM-CTL"
	ShortAppDesc  = "Service Provider configuration"
	LongAPPConfig = "Service Provider configuration"
)
View Source
const ALLOW_DELETE_CONFIG = "ALLOW_DELETE"
View Source
const APPLICATIONS = "Applications"

Resource types

View Source
const APPLICATIONS_CONFIG = "APPLICATIONS"

Resource type configs

View Source
const CLAIMS = "Claims"
View Source
const CLAIM_CONFIG = "CLAIMS"
View Source
const CLIENT_ID_CONFIG = "CLIENT_ID"
View Source
const CLIENT_SECRET_CONFIG = "CLIENT_SECRET"
View Source
const CONSOLE = "Console"
View Source
const DEFAULT_TENANT_DOMAIN = "carbon.super"
View Source
const DELETE = "delete"
View Source
const EXCLUDE_CONFIG = "EXCLUDE"

Tool configs

View Source
const EXCLUDE_SECRETS_CONFIG = "EXCLUDE_SECRETS"
View Source
const EXPORT = "export"
View Source
const IDENTITY_PROVIDERS = "IdentityProviders"
View Source
const IDP_CONFIG = "IDENTITY_PROVIDERS"
View Source
const IMPORT = "import"
View Source
const INCLUDE_ONLY_CONFIG = "INCLUDE_ONLY"
View Source
const KEYWORD_CONFIG_FILE = "keywordConfig.json"
View Source
const KEYWORD_CONFIG_PATH = "KEYWORD_CONFIG_PATH"
View Source
const KEYWORD_MAPPINGS_CONFIG = "KEYWORD_MAPPINGS"

Keyword configs

View Source
const LIST = "list"
View Source
const MEDIA_TYPE_FORM = "application/x-www-form-urlencoded"
View Source
const MEDIA_TYPE_JSON = "application/json"

Media types

View Source
const MEDIA_TYPE_XML = "application/xml"
View Source
const MEDIA_TYPE_YAML = "application/yaml"
View Source
const MY_ACCOUNT = "My Account"
View Source
const OAUTH2 = "oauth2"
View Source
const RESIDENT_IDP_NAME = "LOCAL"
View Source
const SCOPE string = "" /* 411-byte string literal not displayed */
View Source
const SENSITIVE_FIELD_MASK = "'********'"
View Source
const SERVER_CONFIG_FILE = "serverConfig.json"

Config file names

View Source
const SERVER_URL_CONFIG = "SERVER_URL"

Server configs

View Source
const TENANT_DOMAIN_CONFIG = "TENANT_DOMAIN"
View Source
const TOKEN_CONFIG = "TOKEN"
View Source
const TOOL_CONFIG_FILE = "toolConfig.json"
View Source
const TOOL_CONFIG_PATH = "TOOL_CONFIG_PATH"
View Source
const UPDATE = "update"
View Source
const USERSTORES = "UserStores"
View Source
const USERSTORES_CONFIG = "USERSTORES"

Variables

View Source
var ErrorCodes = map[int]string{

	400: "Bad request. Provided parameters are not in correct format.",
	401: "Unauthorized access.\nPlease check your server configurations.",
	403: "Forbidden request.",
	404: "Resource not found for the given ID.",
	409: "A resource with the same name already exists.",
	500: "Internal server error.",
}

Error codes

View Source
var Path = dir + "/iamctl.json"
View Source
var PathSampleSPDetails = dir + "/init.json"

Functions

func AddKeywords

func AddKeywords(exportedYaml interface{}, localFileData []byte, keywordMapping map[string]interface{}, resourceType string) (interface{}, error)

func AddNewSecretIndicatorToSummary

func AddNewSecretIndicatorToSummary(appName string)

func AddTypeTags

func AddTypeTags(data []byte) []byte

func AreSecretsExcluded

func AreSecretsExcluded(resourceConfigs map[string]interface{}) bool

func Contains

func Contains(slice []string, item string) bool

func ContainsKeywords

func ContainsKeywords(data string, keywordMapping map[string]interface{}) bool

func CreateFile

func CreateFile()

func CreateSampleSPFile

func CreateSampleSPFile()

func GetArrayIdentifiers

func GetArrayIdentifiers(resourceType string) map[string]string

func GetArrayIndex

func GetArrayIndex(arrayMap []interface{}, elementIdentifier string) (int, error)

func GetKeywordLocations

func GetKeywordLocations(fileData interface{}, path []string, keywordMapping map[string]interface{}, resourceType string) []string

func GetPathKeys

func GetPathKeys(pathString string) []string

func GetValue

func GetValue(data interface{}, key string) string

func InitializeResourceSummary

func InitializeResourceSummary()

func IsResourceExcluded

func IsResourceExcluded(resourceName string, resourceConfigs map[string]interface{}) bool

func IsResourceTypeExcluded

func IsResourceTypeExcluded(resourceType string) bool

func LoadConfigs

func LoadConfigs(envConfigPath string) (baseDir string)

func ModifyFieldsWithKeywords

func ModifyFieldsWithKeywords(exportedFileData interface{}, localFileData interface{},
	keywordLocations []string, keywordMap map[string]interface{}) interface{}

func PrintExportSummary

func PrintExportSummary()

func PrintFailedResources

func PrintFailedResources(summary ResourceSummary)

func PrintImportSummary

func PrintImportSummary()

func PrintSummary

func PrintSummary(Operation string)

func ProcessExportedContent

func ProcessExportedContent(exportedFileName string, exportedFileContent []byte, keywordMapping map[string]interface{}, resourceType string) ([]byte, error)

func ReadFile

func ReadFile() string

func ReadSPConfig

func ReadSPConfig() (string, string, string, string)

func RemoveDeletedLocalResources

func RemoveDeletedLocalResources(filePath string, deployedResourceNames []string)

func RemoveSecretMasks

func RemoveSecretMasks(modifiedFileData string) string

func ReplaceKeywords

func ReplaceKeywords(fileContent string, keywordMapping map[string]interface{}) string

func ReplacePlaceholders

func ReplacePlaceholders(configFile []byte) []byte

func ReplaceTypeTags

func ReplaceTypeTags(data []byte) []byte

func ReplaceValue

func ReplaceValue(data interface{}, pathString string, replacement string) interface{}

func ResolveAdvancedKeywordMapping

func ResolveAdvancedKeywordMapping(resourceName string, resourceConfigs map[string]interface{}) map[string]interface{}

func SendDeleteRequest

func SendDeleteRequest(resourceId string, resourceType string) error

func SendExportRequest

func SendExportRequest(resourceId, fileType, resourceType string, excludeSecrets bool) (resp *http.Response, err error)

func SendGetListRequest

func SendGetListRequest(resourceType string, resourceLimit int) (*http.Response, error)

func SendImportRequest

func SendImportRequest(importFilePath, fileData, resourceType string) error

func SendUpdateRequest

func SendUpdateRequest(resourceId, importFilePath, fileData, resourceType string) error

func UpdateFailureSummary

func UpdateFailureSummary(resourceType string, resourceName string)

func UpdateSuccessSummary

func UpdateSuccessSummary(resourceType string, operation string)

func WriteFiles

func WriteFiles(server string, token string, refreshToken string)

Types

type ErrorResponse

type ErrorResponse struct {
	Code             string            `json:"code"`
	Message          string            `json:"message"`
	Description      string            `json:"description"`
	TraceID          string            `json:"traceId"`
	FailedOperations []FailedOperation `json:"failedOperations"`
}

type FailedOperation

type FailedOperation struct {
	Code        string `json:"code"`
	Message     string `json:"message"`
	Description string `json:"description"`
	ClaimURI    string `json:"claimURI,omitempty"`
}

type FileInfo

type FileInfo struct {
	ResourceName  string
	FileName      string
	FileExtension string
}

func GetFileInfo

func GetFileInfo(filePath string) (fileInfo FileInfo)

type KeywordConfigs

type KeywordConfigs struct {
	KeywordMappings    map[string]interface{} `json:"KEYWORD_MAPPINGS"`
	ApplicationConfigs map[string]interface{} `json:"APPLICATIONS"`
	IdpConfigs         map[string]interface{} `json:"IDENTITY_PROVIDERS"`
	ClaimConfigs       map[string]interface{} `json:"CLAIMS"`
	UserStoreConfigs   map[string]interface{} `json:"USERSTORES"`
}
var KEYWORD_CONFIGS KeywordConfigs

type MyJSON

type MyJSON struct {
	Array []ServerDetails
}

type ResourceSummary

type ResourceSummary struct {
	ResourceType                string
	SuccessfulExport            int
	SuccessfulImport            int
	SuccessfulUpdate            int
	Failed                      int
	Deleted                     int
	SecretGeneratedApplications []string
	FailedResources             []string
}

type SampleSP

type SampleSP struct {
	Server       string `json:"server"`
	ClientID     string `json:"clientID"`
	ClientSecret string `json:"clientSecret"`
	Tenant       string `json:"tenant"`
}

type ServerConfigs

type ServerConfigs struct {
	ServerUrl    string `json:"SERVER_URL"`
	ClientId     string `json:"CLIENT_ID"`
	ClientSecret string `json:"CLIENT_SECRET"`
	TenantDomain string `json:"TENANT_DOMAIN"`
	Token        string `json:"TOKEN"`
}
var SERVER_CONFIGS ServerConfigs

type ServerDetails

type ServerDetails struct {
	Server       string `json:"server"`
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type Summary

type Summary struct {
	SuccessfulOperations int
	FailedOperations     int
	TotalRequests        int
}
var (
	SummaryData       Summary
	ResourceSummaries map[string]ResourceSummary
)

type ToolConfigs

type ToolConfigs struct {
	AllowDelete        bool                   `json:"ALLOW_DELETE"`
	Exclude            []string               `json:"EXCLUDE"`
	IncludeOnly        []string               `json:"INCLUDE_ONLY"`
	ExcludeSecrets     bool                   `json:"EXCLUDE_SECRETS"`
	ApplicationConfigs map[string]interface{} `json:"APPLICATIONS"`
	IdpConfigs         map[string]interface{} `json:"IDENTITY_PROVIDERS"`
	ClaimConfigs       map[string]interface{} `json:"CLAIMS"`
	UserStoreConfigs   map[string]interface{} `json:"USERSTORES"`
}
var TOOL_CONFIGS ToolConfigs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL