• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / etl / 15885763648

25 Jun 2025 07:49PM UTC coverage: 60.073% (-1.4%) from 61.443%
15885763648

Pull #152

github

web-flow
Merge 2b95001e0 into 9f0201c2d
Pull Request #152: feat: add postgres state store to allow state to be persisted to the source db

81 of 313 new or added lines in 16 files covered. (25.88%)

29 existing lines in 8 files now uncovered.

5576 of 9282 relevant lines covered (60.07%)

27.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/config/src/shared/source.rs
1
use postgres::sqlx::config::{PgConnectionConfig, PgSslMode, PgTlsConfig};
2
use serde::{Deserialize, Serialize};
3

4
use crate::SerializableSecretString;
5
use crate::shared::ValidationError;
6

7
/// Configuration for connecting to a Postgres source database.
8
///
9
/// This struct holds all necessary connection parameters and settings.
10
#[derive(Debug, Clone, Serialize, Deserialize)]
11
#[serde(rename_all = "snake_case")]
12
pub struct SourceConfig {
13
    /// Hostname or IP address of the Postgres server.
14
    pub host: String,
15
    /// Port number on which the Postgres server is listening.
16
    pub port: u16,
17
    /// Name of the Postgres database to connect to.
18
    pub name: String,
19
    /// Username for authenticating with the Postgres server.
20
    pub username: String,
21
    /// Password for the specified user. This field is sensitive and redacted in debug output.
22
    pub password: Option<SerializableSecretString>,
23
    /// TLS configuration for secure connections.
24
    pub tls: TlsConfig,
25
}
26

27
/// TLS settings for secure Postgres connections.
28
#[derive(Debug, Clone, Serialize, Deserialize)]
29
#[serde(rename_all = "snake_case")]
30
pub struct TlsConfig {
31
    /// PEM-encoded trusted root certificates. Sensitive and redacted in debug output.
32
    pub trusted_root_certs: String,
33
    /// Whether TLS is enabled for the connection.
34
    pub enabled: bool,
35
}
36

37
impl TlsConfig {
38
    /// Validates the [`TlsConfig`].
39
    ///
40
    /// If [`TlsConfig::enabled`] is true, this method checks that [`TlsConfig::trusted_root_certs`] is not empty.
41
    ///
42
    /// Returns [`ValidationError::MissingTrustedRootCerts`] if TLS is enabled but no certificates are provided.
43
    pub fn validate(&self) -> Result<(), ValidationError> {
×
44
        if self.enabled && self.trusted_root_certs.is_empty() {
×
45
            return Err(ValidationError::MissingTrustedRootCerts);
×
46
        }
×
47

×
48
        Ok(())
×
49
    }
×
50
}
51

52
impl SourceConfig {
NEW
53
    pub fn into_connection_config(self) -> PgConnectionConfig {
×
NEW
54
        let ssl_mode = if self.tls.enabled {
×
NEW
55
            PgSslMode::VerifyFull
×
56
        } else {
NEW
57
            PgSslMode::Prefer
×
58
        };
59

NEW
60
        let tls_config = PgTlsConfig {
×
NEW
61
            ssl_mode,
×
NEW
62
            trusted_root_certs: self.tls.trusted_root_certs.into_bytes(),
×
NEW
63
        };
×
NEW
64

×
NEW
65
        PgConnectionConfig {
×
NEW
66
            host: self.host,
×
NEW
67
            port: self.port,
×
NEW
68
            name: self.name,
×
NEW
69
            username: self.username,
×
NEW
70
            password: self.password.map(Into::into),
×
NEW
71
            tls_config,
×
NEW
72
        }
×
NEW
73
    }
×
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc