Skip to content

Commit

Permalink
cmd/atlas: add helper function to generate safe-url (#3186)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored Oct 10, 2024
1 parent 019d92a commit 16722d8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmd/atlas/internal/cmdlog/cmdlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,10 @@ type SchemaInspect struct {
var (
// InspectTemplateFuncs are global functions available in inspect report templates.
InspectTemplateFuncs = template.FuncMap{
"sql": sqlInspect,
"json": jsonEncode,
"mermaid": mermaid,
"base64url": base64url,
"sql": sqlInspect,
"json": jsonEncode,
"mermaid": mermaid,
}

// SchemaInspectTemplate holds the default template of the 'schema inspect' command.
Expand Down Expand Up @@ -917,6 +918,12 @@ func sqlInspect(report *SchemaInspect, indent ...string) (string, error) {
return fmtPlan(report.ctx, report.client, cmdmigrate.ChangesToRealm(report.client, report.Realm), indent)
}

// base64url assumes the input is a base64 encoded string and
// replaces characters to make it URL safe.
func base64url(s string) string {
return strings.NewReplacer("+", "-", "/", "_", "=", "").Replace(s)
}

// SchemaDiff contains a summary of the 'schema diff' command.
type SchemaDiff struct {
ctx context.Context
Expand Down

0 comments on commit 16722d8

Please sign in to comment.