-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(WIP) core/update (#169) + Core Binaries update + Enhanced Logging and Reporting + Log Standard Definition + Webhook Log & Event Type Parity + Bulk Mode
- Loading branch information
Showing
31 changed files
with
1,314 additions
and
11,557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//go:build linux && amd64 && container | ||
// +build linux,amd64,container | ||
|
||
package cmd | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
) | ||
|
||
//go:embed goss/goss-linux-amd64 | ||
var embeddedFiles embed.FS | ||
|
||
func prepareEmbeddedExecutables() (string, string, error) { | ||
tempDir, err := os.MkdirTemp("", "temp_exec") | ||
if err != nil { | ||
return "", "", fmt.Errorf("failed to create temp dir: %w", err) | ||
} | ||
|
||
rgPath, err := findSystemRg() | ||
if err != nil { | ||
return "", "", err | ||
} | ||
|
||
gossPath, err := extractExecutable(tempDir, "goss/goss-linux-amd64") | ||
if err != nil { | ||
return "", "", err | ||
} | ||
|
||
return rgPath, gossPath, nil | ||
} | ||
|
||
func findSystemRg() (string, error) { | ||
rgPath, err := exec.LookPath("rg") | ||
if err != nil { | ||
return "", fmt.Errorf("failed to find 'rg' in system PATH: %w", err) | ||
} | ||
return rgPath, nil | ||
} | ||
|
||
func extractExecutable(tempDir, executableName string) (string, error) { | ||
executableFolder := filepath.Dir(executableName) | ||
err := os.MkdirAll(filepath.Join(tempDir, executableFolder), 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create folder structure: %w", err) | ||
} | ||
|
||
executablePath := filepath.Join(tempDir, executableName) | ||
|
||
data, err := embeddedFiles.ReadFile(executableName) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to read embedded file: %w", err) | ||
} | ||
|
||
err = os.WriteFile(executablePath, data, 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to write executable to temp path: %w", err) | ||
} | ||
|
||
return executablePath, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//go:build linux && arm64 && container | ||
// +build linux,arm64,container | ||
|
||
package cmd | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
) | ||
|
||
//go:embed goss/goss-linux-arm64 | ||
var embeddedFiles embed.FS | ||
|
||
func prepareEmbeddedExecutables() (string, string, error) { | ||
tempDir, err := os.MkdirTemp("", "temp_exec") | ||
if err != nil { | ||
return "", "", fmt.Errorf("failed to create temp dir: %w", err) | ||
} | ||
|
||
rgPath, err := findSystemRg() | ||
if err != nil { | ||
return "", "", err | ||
} | ||
|
||
gossPath, err := extractExecutable(tempDir, "goss/goss-linux-arm64") | ||
if err != nil { | ||
return "", "", err | ||
} | ||
|
||
return rgPath, gossPath, nil | ||
} | ||
|
||
func findSystemRg() (string, error) { | ||
rgPath, err := exec.LookPath("rg") | ||
if err != nil { | ||
return "", fmt.Errorf("failed to find 'rg' in system PATH: %w", err) | ||
} | ||
return rgPath, nil | ||
} | ||
|
||
func extractExecutable(tempDir, executableName string) (string, error) { | ||
executableFolder := filepath.Dir(executableName) | ||
err := os.MkdirAll(filepath.Join(tempDir, executableFolder), 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create folder structure: %w", err) | ||
} | ||
|
||
executablePath := filepath.Join(tempDir, executableName) | ||
|
||
data, err := embeddedFiles.ReadFile(executableName) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to read embedded file: %w", err) | ||
} | ||
|
||
err = os.WriteFile(executablePath, data, 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to write executable to temp path: %w", err) | ||
} | ||
|
||
return executablePath, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.