mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 03:37:34 +00:00
chore: move the go code into a subfolder
This commit is contained in:
39
apps/api/cmd/initialise/verify_grant.go
Normal file
39
apps/api/cmd/initialise/verify_grant.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package initialise
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
)
|
||||
|
||||
func newGrant() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "grant",
|
||||
Short: "set ALL grant to user",
|
||||
Long: `Sets ALL grant to the database user.
|
||||
|
||||
Prerequisites:
|
||||
- postgreSQL
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
config := MustNewConfig(viper.GetViper())
|
||||
|
||||
err := initialise(cmd.Context(), config.Database, VerifyGrant(config.Database.DatabaseName(), config.Database.Username()))
|
||||
logging.OnError(err).Fatal("unable to set grant")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func VerifyGrant(databaseName, username string) func(context.Context, *database.DB) error {
|
||||
return func(ctx context.Context, db *database.DB) error {
|
||||
logging.WithFields("user", username, "database", databaseName).Info("verify grant")
|
||||
|
||||
return exec(ctx, db, fmt.Sprintf(grantStmt, databaseName, username), nil)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user