-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change list/results query requests to post #728
Add output to deepfence_ctl Change stdout to stderr in utils/logs
- Loading branch information
Showing
26 changed files
with
717 additions
and
384 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package output | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/deepfence/ThreatMapper/deepfence_utils/log" | ||
) | ||
|
||
var format string | ||
|
||
func Out[T any](t T) { | ||
var err error | ||
switch format { | ||
case "json": | ||
err = out_json(t) | ||
default: | ||
log.Error().Msgf("Output format %s not supported", format) | ||
} | ||
if err != nil { | ||
log.Error().Msgf("Could not marshal %v into %v format: %v", t, format, err) | ||
} | ||
} | ||
|
||
func init() { | ||
format = os.Getenv("DEEPFENCE_CTL_OUT_FORMAT") | ||
if format == "" { | ||
format = "json" | ||
log.Warn().Msgf("Using default output format %s", format) | ||
} | ||
} |
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,15 @@ | ||
package output | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func out_json[T any](t T) error { | ||
b, err := json.Marshal(t) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("%s\n", string(b)) | ||
return 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
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
Oops, something went wrong.