MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / newCommand

Function newCommand

internal/cmd/plugin/pgadmin/pgadmin.go:101–132  ·  view source on GitHub ↗

newCommand initialize pgadmin deployment options

(
	cluster *apiv1.Cluster,
	mode Mode,
	dryRun bool,
	pgadminImage string,
)

Source from the content-addressed store, hash-verified

99
100// newCommand initialize pgadmin deployment options
101func newCommand(
102 cluster *apiv1.Cluster,
103 mode Mode,
104 dryRun bool,
105 pgadminImage string,
106) (*command, error) {
107 const defaultPgadminUsername = "user@pgadmin.com"
108
109 clusterName := cluster.Name
110 result := &command{
111 ClusterName: clusterName,
112 ApplicationDatabaseSecretName: cluster.GetApplicationSecretName(),
113 ApplicationDatabaseOwnerName: cluster.GetApplicationDatabaseOwner(),
114 dryRun: dryRun,
115 DeploymentName: fmt.Sprintf("%s-pgadmin4", clusterName),
116 ConfigMapName: fmt.Sprintf("%s-pgadmin4", clusterName),
117 ServiceName: fmt.Sprintf("%s-pgadmin4", clusterName),
118 SecretName: fmt.Sprintf("%s-pgadmin4", clusterName),
119 Mode: mode,
120 PgadminImage: pgadminImage,
121 }
122
123 pgadminPassword, err := password.Generate(32, 10, 0, false, true)
124 if err != nil {
125 return nil, err
126 }
127
128 result.PgadminPassword = pgadminPassword
129 result.PgadminUsername = defaultPgadminUsername
130
131 return result, nil
132}
133
134func (cmd *command) execute(ctx context.Context) error {
135 configMap, err := cmd.generateConfigMap()

Callers 1

NewCmdFunction · 0.85

Calls 2

Tested by

no test coverage detected