Documentation ¶
Index ¶
- Constants
- Variables
- func DiagFromError(err error, summary string) diag.Diagnostic
- func DiagsCheckError(diags diag.Diagnostics, err error, summary string) diag.Diagnostics
- func DiagsFromError(err error, summary string) diag.Diagnostics
- func GenerateError(detail string, docs string) error
- func GetStr(m map[string]interface{}, key string) (string, bool)
- func JsonBytesEqual(b1 []byte, b2 []byte) bool
- func Optional(valueType schema.ValueType, description string) *schema.Schema
- func ParseImpl(impl string) string
- func ParseRemoteImpl(impl string) string
- func PrefixDiagPaths(diags diag.Diagnostics, prefix cty.Path)
- func Required(valueType schema.ValueType, description string) *schema.Schema
- func RequiredCaseInsensitiveString(description string) *schema.Schema
- func SettingsMap(description string) *schema.Schema
- func StringList(required bool, description string) *schema.Schema
- func SuppressCaseSensitiveNamesDiffs(k, old, new string, _ *schema.ResourceData) bool
- func SuppressEquivalentFileContentDiffs(k string, old string, new string, _ *schema.ResourceData) bool
- func SuppressEquivalentJsonDiffs(k string, old string, new string, _ *schema.ResourceData) bool
- func SuppressFlowDiffs(k string, old string, new string, d *schema.ResourceData) bool
- func SuppressNullSettingsDiffs(k string, old string, new string, d *schema.ResourceData) bool
- func TranslateDiagPaths(diags diag.Diagnostics, keyMap map[string]string)
- type AuthToken
- type Config
- type Error
- type ErrorResponse
Constants ¶
const ( JWTEnvVar = "SYM_JWT" SkipValidationEnvVar = "SYM_TF_SKIP_VALIDATION" )
const ( DocsHome = "https://docs.symops.com/" DocsSupport = "https://docs.symops.com/docs/support" DocsSymflowInstall = "https://docs.symops.com/docs/install-sym-flow" DocsSymflowLogin = "https://docs.symops.com/docs/login-sym-flow" DocsImport = "https://docs.symops.com/docs/reapplying-terraform" )
Static URLs for specific Sym documentation pages.
Variables ¶
var ( ErrConfigFileDoesNotExist = GenerateError("No local Sym config was found. Have you installed the `symflow` CLI and run `symflow login` or set $SYM_JWT?", DocsSymflowInstall) ErrConfigFileNoJWT = GenerateError("Your Sym access token is missing or invalid. Have you run `symflow login` or set $SYM_JWT?", DocsSymflowLogin) ErrSymflowNotInstalled = GenerateError("`symflow` is not installed, please install it and run `symflow login`.", DocsSymflowInstall) ErrSymflowNoOrgConfigured = GenerateError("You do not have an org configured via `symflow`, please run `symflow login` or set $SYM_JWT with your Sym access token", DocsSymflowLogin) )
var ErrAPIBadRequest = func(messages []Error) error { errorMessage := fmt.Sprintf("The Sym API returned a bad request error: %v", messages) return GenerateError(errorMessage, DocsSupport) }
var ErrAPIConnect = func(endpoint string, requestId string) error { errorMessage := fmt.Sprintf("An unexpected error occurred while connecting to the Sym API. Please reach out to Sym Support.\nURL: %s\nRequest ID: %s", endpoint, requestId) return GenerateError(errorMessage, DocsSupport) }
var ErrAPINotFound = func(endpoint string, requestId string) error { errorMessage := fmt.Sprintf("The Sym API URL you tried to use could not be found. Please reach out to Sym Support.\nURL: %s\nStatus Code: 404\nRequest ID: %s", endpoint, requestId) return GenerateError(errorMessage, DocsSupport) }
var ErrAPIUnexpected = func(endpoint string, requestId string, statusCode int) error { errorMessage := fmt.Sprintf("An unexpected error occurred while connecting to the Sym API. Please reach out to Sym Support.\nURL: %s\nStatus Code: %v\nRequest ID: %s", endpoint, statusCode, requestId) return GenerateError(errorMessage, DocsSupport) }
var ErrInvalidImportTypeSlug = func(resource, identifier string) error { errorMessage := fmt.Sprintf("The provided %s identifier %s could not be parsed. Identifiers must be in the form of `TYPE:SLUG`.", resource, identifier) return GenerateError(errorMessage, DocsImport) }
var ErrInvalidImportUUID = func(resource string) error { errorMessage := fmt.Sprintf("Looks like you tried to import a %s by UUID, but it only supports importing by `SLUG`.", resource) return GenerateError(errorMessage, DocsImport) }
var ErrSymflowWrongOrg = func(symflowOrg string, providerOrg string) error { errorMessage := fmt.Sprintf( "You are logged in to `symflow` using the %s org, but the Sym provider is configured with the %s org. Please ensure that you are logged in to the correct org via `symflow`.", symflowOrg, providerOrg, ) return GenerateError(errorMessage, DocsSymflowLogin) }
Functions ¶
func DiagFromError ¶
func DiagFromError(err error, summary string) diag.Diagnostic
func DiagsCheckError ¶
func DiagsCheckError(diags diag.Diagnostics, err error, summary string) diag.Diagnostics
func DiagsFromError ¶
func DiagsFromError(err error, summary string) diag.Diagnostics
func GenerateError ¶
GenerateError generates Sym errors in a standard format.
func GetStr ¶
GetStr retrieves a string safely from a given map `m` at the given `key`, if it exists. If the value does not exist or is not a string, returns `("", false)`.
func JsonBytesEqual ¶
func ParseImpl ¶
ParseImpl takes in an impl in base64, text, or filename format, and consistently returns the impl in text format, if possible.
func ParseRemoteImpl ¶
ParseRemoteImpl takes in an impl in base64 or text format, and consistently returns the impl in text format, if possible.
func PrefixDiagPaths ¶
func PrefixDiagPaths(diags diag.Diagnostics, prefix cty.Path)
func SettingsMap ¶
func SuppressCaseSensitiveNamesDiffs ¶
func SuppressCaseSensitiveNamesDiffs(k, old, new string, _ *schema.ResourceData) bool
func SuppressEquivalentFileContentDiffs ¶
func SuppressEquivalentFileContentDiffs(k string, old string, new string, _ *schema.ResourceData) bool
SuppressEquivalentFileContentDiffs is a DiffSuppressFunc that can be passed into a schema when the provider receives file content from the API but needs to compare against the file content locally, but the terraform specifies the file name vs. content.
e.g. the API response vs. the terraform, we get something like implementation = "ZnJvbSBzeW0uYW5ub3RhdGlvbnMgaW1wb3J0" implementation = "impl.py"
If the file fails to be read, we will return false to specify that we should not suppress the difference. If the incoming base64 encoding file fails to decode, we will return false.
NOTE: if true is returned, the diff is suppressed and the field whose diff is being suppressed will have a value matching the OLD input. This means that if the diff is suppressed, we need to account for already having a base64 encoded string as the field's value vs. a file path.
func SuppressEquivalentJsonDiffs ¶
SuppressEquivalentJsonDiffs is a DiffSuppressFunc that can be passed into a schema to ensure meaningless differences in JSON are ignored when reading/writing.
e.g. without this function, TF will see the following two blobs as different, and prompt an update. With this function set, the blobs are seen as equivalent:
{"template": "sym:approval", "name": "access"} {"name": "access", "template": "sym:approval"}
func SuppressFlowDiffs ¶
func SuppressNullSettingsDiffs ¶
SuppressNullSettingsDiffs is a DiffSuppressFunc that can be passed into a schema to account for differences in settings maps received from the API and stored in the Terraform state.
e.g. if a Terraform object's settings are empty:
settings {}
the API may still send the full dictionary of possible settings will null values
{"account_id": null, ...}
where effectively those values are the same, but Terraform's diff will not know that.
SuppressNullSettingsDiffs will be called on each item in the settings map individually as well as on the settings map as a whole.
func TranslateDiagPaths ¶
func TranslateDiagPaths(diags diag.Diagnostics, keyMap map[string]string)
Types ¶
type Config ¶
type Config struct { AuthToken *AuthToken `yaml:"auth_token"` ClientID string `yaml:"client_id"` Email string `yaml:"email"` Org string `yaml:"org"` LastUpdateCheck string `yaml:"last_update_check"` // contains filtered or unexported fields }
Config is the deserialized form of the sym config.yml file. Note: Keep this in sync with the file structure in symflow CLI.
func GetConfig ¶
GetConfig reads the Sym config file at the given path and relevant environment variables and returns a Config
func GetDefaultConfig ¶
GetDefaultConfig reads the Sym config at the default config path