shared

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: BSD-3-Clause Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSecretVersion

func AddSecretVersion(ctx context.Context, client *secretmanager.Client, parent string, secretName string, payload string) error

func CreateDbUser

func CreateDbUser(client *mongo.Client, username string, newPassword string, readDb []string, readWriteDb []string, creator []string, userAdmin bool) error

func CreateSecret

func CreateSecret(ctx context.Context, client *secretmanager.Client, parent string, secretName string) error

func DeleteDbUser

func DeleteDbUser(client *mongo.Client, username string) error

func ExtractSecret

func ExtractSecret(name string, version string) (string, error)

func GeneratePayload

func GeneratePayload(cmd *cobra.Command) string

func GenerateRandomString

func GenerateRandomString(n int) string

func GetProjectParents

func GetProjectParents() string

func IsSecretStale

func IsSecretStale(ctx context.Context, client *secretmanager.Client, parent string, secretName string, ttlHours int) bool

func MustConnectAdminDbClient added in v1.4.1

func MustConnectAdminDbClient(cfg *SiteConfig, creatorAffinity bool) *mongo.Client

func MustConnectDbClient added in v1.4.1

func MustConnectDbClient(cfg *SiteConfig) *mongo.Client

func MustGetSecretClient

func MustGetSecretClient(ctx context.Context) *secretmanager.Client

func ParseSecretSourceString added in v1.4.0

func ParseSecretSourceString(s string) (string, error)

func ParseSecretVersionName added in v1.4.1

func ParseSecretVersionName(s string) (string, error)

func SetDbClientFlags

func SetDbClientFlags(cmd *cobra.Command)

func TranslateMongoURIPassword

func TranslateMongoURIPassword(uri string) (string, error)

func UpdateDbUser

func UpdateDbUser(client *mongo.Client, username string, newPassword string, readDb []string, readWriteDb []string, creator []string, userAdmin bool) error

func UpsertDbUser

func UpsertDbUser(client *mongo.Client, username string, newPassword string, readDb []string, readWriteDb []string, creator []string, userAdmin bool) error

Types

type MongoRole

type MongoRole struct {
	Role string `bson:"role"`
	DB   string `bson:"db"`
}

type MongoUser

type MongoUser struct {
	User  string      `bson:"user"`
	Roles []MongoRole `bson:"roles"`
}

type SiteConfig

type SiteConfig struct {
	ProjectID         string `mapstructure:"PROJECT_ID"`
	ProxyAddress      string `mapstructure:"ALL_PROXY"`
	MongoDBCmdUri     string
	MongoDBUri        string `mapstructure:"MONGODB_URI"`
	MongoDBAdminUri   string `mapstructure:"MONGODB_ADMIN_URI"`
	MongoDBCreatorUri string `mapstructure:"MONGODB_CREATOR_URI"`
}

func LoadSiteConfig

func LoadSiteConfig() (config SiteConfig, err error)

func (*SiteConfig) FindPrivilegeMongoUri added in v1.4.1

func (c *SiteConfig) FindPrivilegeMongoUri(creator bool) string

func (*SiteConfig) MergeFromCmd added in v1.3.0

func (c *SiteConfig) MergeFromCmd(cmd *cobra.Command) *SiteConfig

func (*SiteConfig) MergeFromFile added in v1.3.0

func (c *SiteConfig) MergeFromFile(name string) *SiteConfig

type UsersInfoResponse

type UsersInfoResponse struct {
	Users []MongoUser `bson:"users"`
}

func QueryDbUser

func QueryDbUser(client *mongo.Client) (*UsersInfoResponse, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL