feat: updated pr based on review

This commit is contained in:
=
2024-11-25 20:28:43 +05:30
parent ed7fc0e5cd
commit be39e63832
4 changed files with 7 additions and 22 deletions

View File

@@ -28,8 +28,9 @@ func PrintAllDynamicRootCredentials(dynamicRootCredentials []infisicalModels.Dyn
func PrintAllDynamicSecretLeases(dynamicSecretLeases []infisicalModels.DynamicSecretLease) {
rows := [][]string{}
const timeformat = "02-Jan-2006 03:04:05 PM"
for _, el := range dynamicSecretLeases {
rows = append(rows, []string{el.Id, el.ExpireAt.Local().Format("02-Jan-2006 03:04:05 PM"), el.CreatedAt.Local().Format("02-Jan-2006 03:04:05 PM")})
rows = append(rows, []string{el.Id, el.ExpireAt.Local().Format(timeformat), el.CreatedAt.Local().Format(timeformat)})
}
headers := []string{"ID", "Expire At", "Created At"}

View File

@@ -95,25 +95,6 @@ func getLongestValues(rows [][3]string) (longestSecretName, longestSecretType in
}
func GenericTable(headers []string, rows [][]string) {
// if we're not in a terminal or cygwin terminal, don't truncate the secret value
shouldTruncate := isatty.IsTerminal(os.Stdout.Fd())
// This will return an error if we're not in a terminal or
// if the terminal is a cygwin terminal like Git Bash.
width, _, err := term.GetSize(int(os.Stdout.Fd()))
if err != nil {
if shouldTruncate {
log.Error().Msgf("error getting terminal size: %s", err)
} else {
log.Debug().Err(err)
}
}
availableWidth := width - borderWidths
if availableWidth < 0 {
availableWidth = 0
}
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.SetStyle(table.StyleLight)