{"modulePath":"github.com/newstack-cloud/bluelink/apps/deploy-engine","version":"v0.9.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\n## Constants\n\n```go\nconst (\n\t// UnexpectedErrorMessage is a generic error message for unexpected errors\n\t// that occur in the deploy engine.\n\tUnexpectedErrorMessage = \"an unexpected error occurred\"\n)\n```\n\n## Variables\n\n```go\nvar (\n\t// ErrUnsupportedBlueprintFormat is the error message for an unsupported blueprint format.\n\tErrUnsupportedBlueprintFormat = errors.New(\"unsupported blueprint format\")\n)\n```\n\n## Functions\n\n```go\nfunc BlueprintFormatFromExtension(filePath string) (schema.SpecFormat, error)\n```\nBlueprintFormatFromExtension determines the blueprint input format based on the file extension. An error is returned if the extension is not supported.\n\n```go\nfunc ClearStaleUnixSocket(unixSocketPath string) error\n```\nClearStaleUnixSocket removes a socket file left behind by a previous run, so that net.Listen does not fail with \"address already in use\".\n\nA path that is not a socket is left alone and reported, rather than removed. A socket another process is still listening on is also left alone, so a second engine cannot hijack the path of a running one.\n\n```go\nfunc DiagnosticsFromBlueprintValidationError(\n\terr error,\n\tlogger core.Logger,\n\tfallbackToGeneralDiagnostic bool,\n) []*core.Diagnostic\n```\nDiagnosticsFromBlueprintValidationError extracts diagnostics from a blueprint validation error.\n\n```go\nfunc ExpandEnv(input string) string\n```\nExpandEnv expands the environment variables in the given string. This supports windows and unix style environment variable expansion.\n\n```go\nfunc HasAtLeastOneError(diagnostics []*core.Diagnostic) bool\n```\nHasAtLeastOneError checks if there is at least one error in the provided diagnostics slice.\n\n```go\nfunc NewUUIDv7Generator() core.IDGenerator\n```\nNewUUIDv7Generator creates a new blueprint framework ID generator that uses UUIDv7. This is useful for generating IDs that can be sorted based on time of creation.\n\n```go\nfunc PrepareUnixSocketDir(unixSocketPath string) error\n```\nPrepareUnixSocketDir creates the directory that will hold a unix socket, restricted to the owning user, and tightens an existing directory to the same.\n\nThe directory is the control over who can reach the socket, on both platforms. On unix its mode restricts traversal and the socket inherits nothing, so the socket is restricted separately. On Windows the socket file inherits the directory's ACL, and bind and connect are checked against it, so a restrictive directory is what restricts the socket too.\n\nGo's os.Chmod cannot express an ACL, on Windows it only toggles the read-only attribute so the directory, not a mode on the socket, is the portable way to set this.\n\n```go\nfunc RestrictUnixSocket(unixSocketPath string) error\n```\nRestrictUnixSocket restricts a unix socket to the owning user on unix, where net.Listen would otherwise create it with umask-dependent permissions.\n\n","path":"github.com/newstack-cloud/bluelink/apps/deploy-engine/utils","name":"utils","synopsis":"","isRedistributable":true}
