Add postgresql database

This commit is contained in:
Adrian Heine 2020-10-17 23:32:53 +02:00
parent d7180e327a
commit b53267f406
3 changed files with 53 additions and 4 deletions

View file

@ -5,8 +5,8 @@ use crate::artifacts::{
use crate::resources::{
AcmeAccountKey, AcmeChallengesDir, AcmeChallengesNginxSnippet, AcmeRootCert, AcmeUser, Cert,
CertChain, Cron, Csr, DefaultServer, Dir, File, GitCheckout, Key, KeyAndCertBundle,
LoadedDirectory, MariaDbDatabase, MariaDbUser, NpmInstall, Owner, PhpFpmPool, Resource,
ServeCustom, ServePhp, ServeRedir, ServeService, ServeStatic, StoredDirectory,
LoadedDirectory, MariaDbDatabase, MariaDbUser, NpmInstall, Owner, PhpFpmPool, PostgresqlDatabase,
Resource, ServeCustom, ServePhp, ServeRedir, ServeService, ServeStatic, StoredDirectory,
SystemdSocketService, User, UserForDomain, WordpressPlugin, WordpressTranslation,
};
use crate::to_artifact::ToArtifact;
@ -422,6 +422,25 @@ impl<D: AsRef<str>, P: Policy> ResourceLocator<MariaDbUser<D>> for DefaultLocato
}
}
impl<D: AsRef<str>, P: Policy> ResourceLocator<PostgresqlDatabase<D>> for DefaultLocator<P> {
type Prerequisites = ();
fn locate(
resource: &PostgresqlDatabase<D>,
) -> (
<PostgresqlDatabase<D> as Resource>::Artifact,
Self::Prerequisites,
) {
let ((user_name, _), ()) = Self::locate(&UserForDomain(&resource.0));
(
(
DatabaseNameArtifact(user_name.0.clone()),
PathArtifact::from(P::path_for_data(format!("{}.sql", user_name.0))),
),
(),
)
}
}
impl<P, POLICY> ResourceLocator<WordpressPlugin<P>> for DefaultLocator<POLICY> {
type Prerequisites = ();
fn locate(