MCPcopy Create free account
hub / github.com/rilldata/rill / toMagicAuthTokenRow

Function toMagicAuthTokenRow

cli/pkg/printer/resources.go:452–477  ·  view source on GitHub ↗
(t *adminv1.MagicAuthToken)

Source from the content-addressed store, hash-verified

450}
451
452func toMagicAuthTokenRow(t *adminv1.MagicAuthToken) *magicAuthToken {
453 filters := ""
454 for mv, filter := range t.MetricsViewFilters {
455 expr := metricsview.NewExpressionFromProto(filter)
456 sqlFilter, err := metricsview.ExpressionToSQL(expr)
457 if err != nil {
458 panic(err)
459 }
460 if filters != "" {
461 filters += ", "
462 }
463 filters += fmt.Sprintf("%s(%s)", mv, sqlFilter)
464 }
465
466 row := &magicAuthToken{
467 ID: t.Id,
468 MetricsViewFilters: filters,
469 CreatedBy: t.CreatedByUserEmail,
470 CreatedOn: t.CreatedOn.AsTime().Local().Format(time.DateTime),
471 UsedOn: t.UsedOn.AsTime().Local().Format(time.DateTime),
472 }
473 if t.ExpiresOn != nil {
474 row.ExpiresOn = t.ExpiresOn.AsTime().Local().Format(time.DateTime)
475 }
476 return row
477}
478
479type magicAuthToken struct {
480 ID string `header:"id" json:"id"`

Callers 1

toMagicAuthTokensTableFunction · 0.85

Calls 3

NewExpressionFromProtoFunction · 0.92
ExpressionToSQLFunction · 0.92
FormatMethod · 0.65

Tested by

no test coverage detected