upd: helper utilities updated
This commit is contained in:
parent
27144056b1
commit
c81c2be366
@ -54,8 +54,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"go/module/essential/visible/service/helper/log"
|
"go/module/essential/visible/service/helper/log"
|
||||||
"go/module/essential/visible/service/helper/retriever"
|
|
||||||
"go/module/essential/visible/service/helper/status"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -74,8 +72,6 @@ type obrimCipherResponse struct {
|
|||||||
|
|
||||||
// ObrimCipher executes encryption and decryption workflows.
|
// ObrimCipher executes encryption and decryption workflows.
|
||||||
func ObrimCipher(operationType string, config map[string]any) map[string]any {
|
func ObrimCipher(operationType string, config map[string]any) map[string]any {
|
||||||
_, _ = retriever.ObrimRetriever, status.ObrimStatus
|
|
||||||
|
|
||||||
log.ObrimLog("INIT", "Cipher operation initialized.")
|
log.ObrimLog("INIT", "Cipher operation initialized.")
|
||||||
|
|
||||||
if err := obrimCipherValidateType(operationType); err != nil {
|
if err := obrimCipherValidateType(operationType); err != nil {
|
||||||
@ -88,7 +84,7 @@ func ObrimCipher(operationType string, config map[string]any) map[string]any {
|
|||||||
|
|
||||||
keyValue := config["key"].(string)
|
keyValue := config["key"].(string)
|
||||||
|
|
||||||
if err := obrimCipherValidateKey(keyValue); err != nil {
|
if err := obrimCipherValidateKey([]byte(keyValue)); err != nil {
|
||||||
return obrimCipherBuildResponse(false, "FAILED_INVALID_KEY", nil)
|
return obrimCipherBuildResponse(false, "FAILED_INVALID_KEY", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go/module/essential/visible/service/helper/log"
|
"go/module/essential/visible/service/helper/log"
|
||||||
"go/module/essential/visible/service/helper/retriever"
|
|
||||||
"go/module/essential/visible/service/helper/status"
|
"go/module/essential/visible/service/helper/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -57,14 +56,6 @@ func ObrimHash(
|
|||||||
status.ObrimStatus("INFO", "Hash utility execution started.")
|
status.ObrimStatus("INFO", "Hash utility execution started.")
|
||||||
log.ObrimLog("INIT", "Hash utility execution started.")
|
log.ObrimLog("INIT", "Hash utility execution started.")
|
||||||
|
|
||||||
_, _ = retriever.ObrimRetriever(
|
|
||||||
"json",
|
|
||||||
map[string]any{
|
|
||||||
"resource": "framework/metadata",
|
|
||||||
"path": "name",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
if !obrimHashValidateType(hashType) {
|
if !obrimHashValidateType(hashType) {
|
||||||
status.ObrimStatus("ERROR", "Invalid hash type.")
|
status.ObrimStatus("ERROR", "Invalid hash type.")
|
||||||
log.ObrimLog("ERROR", "Invalid hash type.")
|
log.ObrimLog("ERROR", "Invalid hash type.")
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
| - Use for framework and software logging.
|
| - Use for framework and software logging.
|
||||||
| - Writes append-only UTF-8 log entries.
|
| - Writes append-only UTF-8 log entries.
|
||||||
| - Preserves existing log content.
|
| - Preserves existing log content.
|
||||||
| - Uses application metadata to determine storage location.
|
| - Uses software metadata to determine storage location.
|
||||||
| - Does not implement rotation, retention, archival, or compression.
|
| - Does not implement rotation, retention, archival, or compression.
|
||||||
|
|
|
|
||||||
| Example:
|
| Example:
|
||||||
@ -51,7 +51,7 @@ import (
|
|||||||
|
|
||||||
// ObrimLog writes a structured log entry.
|
// ObrimLog writes a structured log entry.
|
||||||
func ObrimLog(label string, message string) {
|
func ObrimLog(label string, message string) {
|
||||||
applicationName := obrimLogApplicationResolve()
|
softwareName := obrimLogSoftwareResolve()
|
||||||
|
|
||||||
timestamp := obrimLogTimestampGenerate()
|
timestamp := obrimLogTimestampGenerate()
|
||||||
|
|
||||||
@ -61,11 +61,11 @@ func ObrimLog(label string, message string) {
|
|||||||
message,
|
message,
|
||||||
)
|
)
|
||||||
|
|
||||||
logDirectory := obrimLogDirectoryResolve(applicationName)
|
logDirectory := obrimLogDirectoryResolve(softwareName)
|
||||||
|
|
||||||
logFile := obrimLogFileResolve(
|
logFile := obrimLogFileResolve(
|
||||||
logDirectory,
|
logDirectory,
|
||||||
applicationName,
|
softwareName,
|
||||||
)
|
)
|
||||||
|
|
||||||
if !obrimLogFileEnsure(logDirectory, logFile) {
|
if !obrimLogFileEnsure(logDirectory, logFile) {
|
||||||
@ -94,47 +94,47 @@ func obrimLogEntryBuild(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// obrimLogApplicationResolve resolves the application name.
|
// obrimLogSoftwareResolve resolves the software name.
|
||||||
func obrimLogApplicationResolve() string {
|
func obrimLogSoftwareResolve() string {
|
||||||
value := retriever.ObrimRetriever(
|
value := retriever.ObrimRetriever(
|
||||||
"json",
|
"json",
|
||||||
map[string]any{
|
map[string]any{
|
||||||
"resource": "application/metadata",
|
"resource": "software/metadata",
|
||||||
"path": "application.lower",
|
"path": "software.lower",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
name := strings.TrimSpace(fmt.Sprintf("%v", value))
|
name := strings.TrimSpace(fmt.Sprintf("%v", value))
|
||||||
|
|
||||||
if name == "" {
|
if name == "" {
|
||||||
return "application"
|
return "software"
|
||||||
}
|
}
|
||||||
|
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
// obrimLogDirectoryResolve resolves platform-specific log directory paths.
|
// obrimLogDirectoryResolve resolves platform-specific log directory paths.
|
||||||
func obrimLogDirectoryResolve(applicationName string) string {
|
func obrimLogDirectoryResolve(softwareName string) string {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "windows":
|
case "windows":
|
||||||
return obrimLogDirectoryResolveWindows(applicationName)
|
return obrimLogDirectoryResolveWindows(softwareName)
|
||||||
|
|
||||||
case "darwin":
|
case "darwin":
|
||||||
return obrimLogDirectoryResolveMacOS(applicationName)
|
return obrimLogDirectoryResolveMacOS(softwareName)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return obrimLogDirectoryResolveLinux(applicationName)
|
return obrimLogDirectoryResolveLinux(softwareName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// obrimLogDirectoryResolveLinux resolves Linux log directory paths.
|
// obrimLogDirectoryResolveLinux resolves Linux log directory paths.
|
||||||
func obrimLogDirectoryResolveLinux(applicationName string) string {
|
func obrimLogDirectoryResolveLinux(softwareName string) string {
|
||||||
xdgStateHome := strings.TrimSpace(os.Getenv("XDG_STATE_HOME"))
|
xdgStateHome := strings.TrimSpace(os.Getenv("XDG_STATE_HOME"))
|
||||||
|
|
||||||
if xdgStateHome != "" {
|
if xdgStateHome != "" {
|
||||||
return filepath.Join(
|
return filepath.Join(
|
||||||
xdgStateHome,
|
xdgStateHome,
|
||||||
"."+applicationName,
|
"."+softwareName,
|
||||||
"logs",
|
"logs",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ func obrimLogDirectoryResolveLinux(applicationName string) string {
|
|||||||
if errorValue != nil {
|
if errorValue != nil {
|
||||||
return filepath.Join(
|
return filepath.Join(
|
||||||
".",
|
".",
|
||||||
"."+applicationName,
|
"."+softwareName,
|
||||||
"logs",
|
"logs",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -153,40 +153,40 @@ func obrimLogDirectoryResolveLinux(applicationName string) string {
|
|||||||
homeDirectory,
|
homeDirectory,
|
||||||
".local",
|
".local",
|
||||||
"state",
|
"state",
|
||||||
"."+applicationName,
|
"."+softwareName,
|
||||||
"logs",
|
"logs",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// obrimLogDirectoryResolveWindows resolves Windows log directory paths.
|
// obrimLogDirectoryResolveWindows resolves Windows log directory paths.
|
||||||
func obrimLogDirectoryResolveWindows(applicationName string) string {
|
func obrimLogDirectoryResolveWindows(softwareName string) string {
|
||||||
localApplicationData := strings.TrimSpace(
|
localSoftwareData := strings.TrimSpace(
|
||||||
os.Getenv("LOCALAPPDATA"),
|
os.Getenv("LOCALAPPDATA"),
|
||||||
)
|
)
|
||||||
|
|
||||||
if localApplicationData == "" {
|
if localSoftwareData == "" {
|
||||||
homeDirectory, errorValue := os.UserHomeDir()
|
homeDirectory, errorValue := os.UserHomeDir()
|
||||||
|
|
||||||
if errorValue == nil {
|
if errorValue == nil {
|
||||||
localApplicationData = homeDirectory
|
localSoftwareData = homeDirectory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filepath.Join(
|
return filepath.Join(
|
||||||
localApplicationData,
|
localSoftwareData,
|
||||||
applicationName,
|
softwareName,
|
||||||
"Logs",
|
"Logs",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// obrimLogDirectoryResolveMacOS resolves macOS log directory paths.
|
// obrimLogDirectoryResolveMacOS resolves macOS log directory paths.
|
||||||
func obrimLogDirectoryResolveMacOS(applicationName string) string {
|
func obrimLogDirectoryResolveMacOS(softwareName string) string {
|
||||||
homeDirectory, errorValue := os.UserHomeDir()
|
homeDirectory, errorValue := os.UserHomeDir()
|
||||||
|
|
||||||
if errorValue != nil {
|
if errorValue != nil {
|
||||||
return filepath.Join(
|
return filepath.Join(
|
||||||
".",
|
".",
|
||||||
"."+applicationName,
|
"."+softwareName,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,18 +194,18 @@ func obrimLogDirectoryResolveMacOS(applicationName string) string {
|
|||||||
homeDirectory,
|
homeDirectory,
|
||||||
"Library",
|
"Library",
|
||||||
"Logs",
|
"Logs",
|
||||||
"."+applicationName,
|
"."+softwareName,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// obrimLogFileResolve resolves platform-specific log file paths.
|
// obrimLogFileResolve resolves platform-specific log file paths.
|
||||||
func obrimLogFileResolve(
|
func obrimLogFileResolve(
|
||||||
logDirectory string,
|
logDirectory string,
|
||||||
applicationName string,
|
softwareName string,
|
||||||
) string {
|
) string {
|
||||||
return filepath.Join(
|
return filepath.Join(
|
||||||
logDirectory,
|
logDirectory,
|
||||||
applicationName+".log",
|
softwareName+".log",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
| - ObrimRetriever("json", map[string]any{"resource": "metadata"})
|
| - ObrimRetriever("json", map[string]any{"resource": "metadata"})
|
||||||
| - ObrimRetriever("json", map[string]any{
|
| - ObrimRetriever("json", map[string]any{
|
||||||
| "resource": "metadata",
|
| "resource": "metadata",
|
||||||
| "path": "application.name",
|
| "path": "software.name",
|
||||||
| })
|
| })
|
||||||
|
|
|
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@ -43,9 +43,6 @@ package retriever
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go/module/essential/visible/service/helper/log"
|
|
||||||
"go/module/essential/visible/service/helper/status"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObrimRetrieverResponse represents the standardized utility response.
|
// ObrimRetrieverResponse represents the standardized utility response.
|
||||||
@ -63,8 +60,6 @@ var ObrimRetrieverDbProviderRegistry = map[string]any{}
|
|||||||
|
|
||||||
// ObrimRetriever retrieves data using a unified retrieval interface.
|
// ObrimRetriever retrieves data using a unified retrieval interface.
|
||||||
func ObrimRetriever(retrievalType string, config map[string]any) map[string]any {
|
func ObrimRetriever(retrievalType string, config map[string]any) map[string]any {
|
||||||
status.ObrimStatus("INFO", "Retriever started.")
|
|
||||||
log.ObrimLog("INIT", "Retriever execution started.")
|
|
||||||
|
|
||||||
if !obrimRetrieverValidateType(retrievalType) {
|
if !obrimRetrieverValidateType(retrievalType) {
|
||||||
return obrimRetrieverBuildResponse(false, "FAILED_UNSUPPORTED_TYPE", nil)
|
return obrimRetrieverBuildResponse(false, "FAILED_UNSUPPORTED_TYPE", nil)
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
| Purpose:
|
| Purpose:
|
||||||
| - Provide a framework-level CLI status utility that standardizes
|
| - Provide a framework-level CLI status utility that standardizes
|
||||||
| terminal message presentation using semantic labels and visual
|
| terminal message presentation using semantic labels and visual
|
||||||
| indicators to ensure consistent output across all applications.
|
| indicators to ensure consistent output across all softwares.
|
||||||
|
|
|
|
||||||
| Guideline:
|
| Guideline:
|
||||||
| - Use semantic labels to classify terminal messages.
|
| - Use semantic labels to classify terminal messages.
|
||||||
@ -18,7 +18,7 @@
|
|||||||
| - Intended for framework and software level terminal messaging.
|
| - Intended for framework and software level terminal messaging.
|
||||||
|
|
|
|
||||||
| Example:
|
| Example:
|
||||||
| - ObrimStatus("INFO", "Application started.")
|
| - ObrimStatus("INFO", "Software started.")
|
||||||
| - ObrimStatus("SUCCESS", "Operation completed.")
|
| - ObrimStatus("SUCCESS", "Operation completed.")
|
||||||
| - ObrimStatus("WARNING", "Configuration missing.")
|
| - ObrimStatus("WARNING", "Configuration missing.")
|
||||||
| - ObrimStatus("ERROR", "Operation failed.")
|
| - ObrimStatus("ERROR", "Operation failed.")
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -1,3 +1,5 @@
|
|||||||
module go/module
|
module go/module
|
||||||
|
|
||||||
go 1.26.4
|
go 1.26.4
|
||||||
|
|
||||||
|
require github.com/sqids/sqids-go v0.4.1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user