Documentation
¶
Index ¶
- Constants
- Variables
- func BlueString(text string) string
- func Clean(props map[string]string, line string) string
- func CleanConnData(data map[string]any, line string) string
- func CleanTableName(tableName string) string
- func CleanWindowsPath(path string) string
- func CloseFileLogging()
- func CyanString(text string) string
- func DarkGrayString(text string) string
- func EnvVarRefName(s string) string
- func ExpandEnvVars(text string) string
- func GetEnvFilePath(dir string) string
- func GetHomeDirConnsMap() (connsMap map[string]map[string]any, err error)
- func GetTempFolder() string
- func GreenString(text string) string
- func HomeBinDir() string
- func InitLogger()
- func IsEnvVarRef(s string) bool
- func IsInteractiveTerminal() bool
- func LoadDotEnvSling() map[string]string
- func LoadDotEnvSlingFrom(dir string) map[string]string
- func LoadHomeDir()
- func LogSQL(props map[string]string, query string, args ...any)
- func MagentaString(text string) string
- func MergeDeclaredEnv(declared map[string]any) map[string]any
- func NewExecID() string
- func ParseDotEnv(content string) map[string]string
- func Print(text string)
- func PrintFatal(E error, args ...interface{})
- func Println(text string)
- func RecentLogs() string
- func RedString(text string) string
- func RemoveAllLocalTempFile(localPath string)
- func RemoveLocalTempFile(localPath string)
- func ScrubLine(line string) string
- func SetLogger()
- func SetTelVal(key string, value any)
- func StartLogCapture()
- func StopLogCapture()
- func UnsetEnvKeys(keys []string)
- func UseDuckDbCompute() bool
- func Vars() (vars map[string]string)
- func YellowString(text string) string
- type ConnLocation
- type EnvFile
- type MissingRef
Constants ¶
const ( DdlDefDecLength = 20 DdlMinDecLength = 24 DdlMaxDecScale = 24 DdlMaxDecLength = 38 DdlMinDecScale = 6 )
Variables ¶
var ( Marker = "Sling CLI | https://slingdata.io" HomeDir = os.Getenv("SLING_HOME_DIR") HomeDirEnvFile = "" Env = &EnvFile{} PlausibleURL = "" SentryDsn = "" NoColor = g.In(os.Getenv("SLING_LOGGING"), "NO_COLOR", "JSON") LogSink func(*g.LogLine) TelMap = g.M("begin_time", time.Now().UnixMicro()) TelMux = sync.Mutex{} NoDebugKey = " /* nD */" Executable = "" IsThreadChild = cast.ToBool(os.Getenv("SLING_THREAD_CHILD")) ExecID = g.Getenv("SLING_EXEC_ID", NewExecID()) RunnerID = g.Getenv("SLING_RUNNER_ID", os.Getenv("SLING_AGENT_ID")) IsRunnerMode = RunnerID != "" GetOAuthMap = func() map[string]map[string]any { return map[string]map[string]any{} } ExecFolder = func() string { return filepath.Join(HomeDir, "executions", ExecID) } QueueFolder = func() string { return filepath.Join(ExecFolder(), "queues") } RuntimeFolder = func() string { return filepath.Join(ExecFolder(), "runtime") } RuntimeFilePath = func(name string) string { name = strings.ReplaceAll(name, "\\", "_") name = strings.ReplaceAll(name, "/", "_") name = strings.ReplaceAll(name, ":", "_") os.MkdirAll(RuntimeFolder(), 0755) return filepath.Join(RuntimeFolder(), g.F("%s.json", name)) } ReservedFields = struct { LoadedAt string SyncedAt string SyncedOp string DeletedAt string StreamURL string RowNum string RowID string ExecID string CDCSeq string }{ LoadedAt: "_sling_loaded_at", SyncedAt: "_sling_synced_at", SyncedOp: "_sling_synced_op", DeletedAt: "_sling_deleted_at", StreamURL: "_sling_stream_url", RowNum: "_sling_row_num", RowID: "_sling_row_id", ExecID: "_sling_exec_id", CDCSeq: "_sling_cdc_seq", } )
var SecretKeys = []string{
"access_key_id",
"account_key",
"aws_access_key_id",
"aws_secret_access_key",
"aws_session_token",
"azure_account_key",
"azure_sas_token",
"conn_str",
"gcp_credentials_json",
"gcs_secret_access_key",
"password",
"rest_oauth_client_secret",
"rest_token",
"s3_secret_access_key",
"s3_session_token",
"sas_svc_url",
"sas_token",
"secret_access_key",
"session_token",
"ssh_passphrase",
"ssh_private_key",
"token",
}
SecretKeys is the full set of connection property names whose values are secrets. Clean and parse.Redact redact these. Keep it in sync with `secret: true` in core/dbio/templates/_properties.yaml.
Functions ¶
func BlueString ¶ added in v1.1.8
func Clean ¶ added in v1.2.16
Clean removes creds from a log line. CREATE/INSERT/etc. still redact: Redshift COPY/UNLOAD embeds keys in those statements.
func CleanConnData ¶ added in v1.6.0
CleanConnData redacts registry secrets and every nested secrets: value. Nested API keys are secret even when the key name is not in the registry.
func CleanTableName ¶ added in v1.2.22
func CleanWindowsPath ¶ added in v1.2.19
func CloseFileLogging ¶ added in v1.5.7
func CloseFileLogging()
CloseFileLogging closes any open log files.
func CyanString ¶ added in v1.1.15
func DarkGrayString ¶ added in v1.1.15
func EnvVarRefName ¶ added in v1.6.0
EnvVarRefName returns VAR from ${VAR}. It returns "" when s is not a ref.
func ExpandEnvVars ¶ added in v1.5.17
expandEnvVars replaces $KEY or ${KEY} with its environment variable value only if the variable is present in the environment. If not present, $KEY or ${KEY} will remain in the config text.
func GetEnvFilePath ¶ added in v1.2.4
func GetHomeDirConnsMap ¶ added in v1.2.4
func GetTempFolder ¶ added in v1.2.4
func GetTempFolder() string
func GreenString ¶ added in v1.1.8
func HomeBinDir ¶ added in v1.2.4
func HomeBinDir() string
func IsEnvVarRef ¶ added in v1.6.0
IsEnvVarRef is true when s is a whole-string ${VAR} reference.
func IsInteractiveTerminal ¶ added in v1.4.10
func IsInteractiveTerminal() bool
IsInteractiveTerminal checks if the current process is running in an interactive terminal
func LoadDotEnvSling ¶ added in v1.5.10
LoadDotEnvSling reads a `.env.sling` file from the current working directory and injects its key=value pairs into os environment variables. Existing env vars are not overwritten.
func LoadDotEnvSlingFrom ¶ added in v1.5.16
LoadDotEnvSlingFrom reads a `.env.sling` file from the specified directory and injects its key=value pairs into os environment variables. Existing env vars are not overwritten.
func LoadHomeDir ¶ added in v1.5.12
func LoadHomeDir()
func MagentaString ¶ added in v1.2.2
func MergeDeclaredEnv ¶ added in v1.6.0
MergeDeclaredEnv starts from the process environment and overlays declared pipeline/replication env keys. Bare {env.X} then renders even when the YAML has no env: block.
func ParseDotEnv ¶ added in v1.5.11
ParseDotEnv parses a .env file content into key-value pairs. It supports single-line and multi-line values enclosed in matching quotes (' or ").
func PrintFatal ¶ added in v1.6.0
func PrintFatal(E error, args ...interface{})
PrintFatal prints the fatal error (same text as g.PrintFatal) and captures it in the run-log buffer via Println, so stderr.log includes it.
func RecentLogs ¶ added in v1.6.0
func RecentLogs() string
RecentLogs returns the buffered tail, oldest first.
func RemoveAllLocalTempFile ¶ added in v1.2.16
func RemoveAllLocalTempFile(localPath string)
RemoveAllLocalTempFile deletes the local folder
func RemoveLocalTempFile ¶ added in v1.2.16
func RemoveLocalTempFile(localPath string)
RemoveLocalTempFile deletes the local file
func StartLogCapture ¶ added in v1.6.0
func StartLogCapture()
StartLogCapture begins buffering log lines for the failure snapshot.
func StopLogCapture ¶ added in v1.6.0
func StopLogCapture()
StopLogCapture stops buffering and drops what was kept.
func UnsetEnvKeys ¶ added in v1.5.10
func UnsetEnvKeys(keys []string)
func UseDuckDbCompute ¶ added in v1.4.24
func UseDuckDbCompute() bool
func YellowString ¶ added in v1.4.21
Types ¶
type ConnLocation ¶ added in v1.6.0
type ConnLocation struct {
Path string `json:"path"`
Line int `json:"line"`
Connection string `json:"connection"`
Missing []MissingRef `json:"missing"`
}
ConnLocation is a deep-link into env.yaml for one connection.
type EnvFile ¶ added in v0.86.56
type EnvFile struct {
Connections map[string]map[string]any `json:"connections,omitempty" yaml:"connections,omitempty"`
Env map[string]any `json:"env,omitempty" yaml:"env,omitempty"`
Variables map[string]any `json:"variables,omitempty" yaml:"variables,omitempty"` // legacy
Path string `json:"-" yaml:"-"`
TopComment string `json:"-" yaml:"-"`
Body string `json:"-" yaml:"-"`
}
func LoadEnvFile ¶ added in v0.86.56
func LoadSlingEnvFile ¶ added in v0.86.56
func LoadSlingEnvFile() (ef EnvFile)
func LoadSlingEnvFileBody ¶ added in v1.2.15
func (*EnvFile) LookupConnection ¶ added in v1.6.0
func (ef *EnvFile) LookupConnection(name string) (ConnLocation, error)
LookupConnection re-parses ef.Path and returns line numbers for connections.<NAME> and each ${VAR} field under it.
func (*EnvFile) MarshalBody ¶ added in v1.5.14
MarshalBody returns the EnvFile as a formatted YAML string
func (*EnvFile) WriteEnvFile ¶ added in v1.2.4
type MissingRef ¶ added in v1.6.0
MissingRef is one ${VAR} field that still needs a value (or an env var).