newCommand initialize pgadmin deployment options
( cluster *apiv1.Cluster, mode Mode, dryRun bool, pgadminImage string, )
| 99 | |
| 100 | // newCommand initialize pgadmin deployment options |
| 101 | func 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 | |
| 134 | func (cmd *command) execute(ctx context.Context) error { |
| 135 | configMap, err := cmd.generateConfigMap() |
no test coverage detected