Skip to content

Commit ed43506

Browse files
author
Devdutt Shenoi
authored
Merge branch 'main' into alpine
2 parents f67a7b7 + 4adf285 commit ed43506

File tree

16 files changed

+416
-230
lines changed

16 files changed

+416
-230
lines changed

.github/workflows/build.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
on:
2+
pull_request:
3+
paths-ignore:
4+
- "docs/**"
5+
- "helm/**"
6+
- "assets/**"
7+
- "**.md"
8+
push:
9+
branches:
10+
- main
11+
12+
name: Ensure parseable builds on all release targets
13+
jobs:
14+
build-linux:
15+
name: Build for ${{matrix.target}}
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
target:
21+
- aarch64-unknown-linux-gnu # linux(arm)
22+
- x86_64-unknown-linux-gnu # linux(64 bit)
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
- uses: actions-rs/toolchain@v1
28+
with:
29+
toolchain: stable
30+
profile: minimal # minimal component installation (ie, no documentation)
31+
target: ${{ matrix.target }}
32+
override: true
33+
34+
- uses: actions-rs/cargo@v1
35+
with:
36+
use-cross: true
37+
command: build
38+
args: --target ${{matrix.target}}
39+
40+
build-windows:
41+
name: Build for windows
42+
runs-on: windows-latest
43+
44+
steps:
45+
- uses: actions/checkout@v2
46+
47+
- uses: actions-rs/toolchain@v1
48+
with:
49+
toolchain: stable
50+
profile: minimal # minimal component installation (ie, no documentation)
51+
default: true
52+
override: true
53+
54+
- name: Build on windows
55+
run: cargo build --target x86_64-pc-windows-msvc
56+
57+
build-macos:
58+
name: Build for ${{matrix.target}}
59+
runs-on: macos-latest
60+
strategy:
61+
matrix:
62+
target:
63+
- aarch64-apple-darwin # macos(arm)
64+
- x86_64-apple-darwin # macos(intel 64 bit)
65+
66+
steps:
67+
- uses: actions/checkout@v2
68+
- uses: actions-rs/toolchain@v1
69+
with:
70+
toolchain: stable
71+
profile: minimal
72+
target: ${{ matrix.target }}
73+
override: true
74+
75+
- name: Build on ${{ matrix.target }}
76+
run: cargo build --target ${{ matrix.target }}

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "parseable"
3-
version = "1.7.2"
3+
version = "1.7.3"
44
authors = ["Parseable Team <[email protected]>"]
55
edition = "2021"
66
rust-version = "1.83.0"
@@ -139,8 +139,8 @@ rstest = "0.23.0"
139139
arrow = "53.0.0"
140140

141141
[package.metadata.parseable_ui]
142-
assets-url = "https://github.com/parseablehq/console/releases/download/v0.9.16/build.zip"
143-
assets-sha1 = "cb9af17fc1af07e590e839fc0ef4db18c323fc48"
142+
assets-url = "https://github.com/parseablehq/console/releases/download/v0.9.18/build.zip"
143+
assets-sha1 = "4516db38c8e556707b29b33569f9b1e53d5165f2"
144144

145145
[features]
146146
debug = []

src/cli.rs

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub const DEFAULT_PASSWORD: &str = "admin";
5252
long_about = r#"
5353
Cloud Native, log analytics platform for modern applications.
5454
55-
Usage:
55+
Usage:
5656
parseable [command] [options..]
5757
5858
@@ -126,7 +126,7 @@ pub struct Options {
126126
// Server configuration
127127
#[arg(
128128
long,
129-
env = "P_ADDR",
129+
env = "P_ADDR",
130130
default_value = "0.0.0.0:8000",
131131
value_parser = validation::socket_addr,
132132
help = "Address and port for Parseable HTTP(s) server"
@@ -294,35 +294,8 @@ pub struct Options {
294294
)]
295295
pub ingestor_endpoint: String,
296296

297-
// OIDC Configuration
298-
#[arg(
299-
long,
300-
long = "oidc-client",
301-
env = "P_OIDC_CLIENT_ID",
302-
requires = "oidc",
303-
group = "oidc",
304-
help = "Client id for OIDC provider"
305-
)]
306-
oidc_client_id: Option<String>,
307-
308-
#[arg(
309-
long,
310-
env = "P_OIDC_CLIENT_SECRET",
311-
requires = "oidc",
312-
group = "oidc",
313-
help = "Client secret for OIDC provider"
314-
)]
315-
oidc_client_secret: Option<String>,
316-
317-
#[arg(
318-
long,
319-
env = "P_OIDC_ISSUER",
320-
value_parser = validation::url,
321-
requires = "oidc",
322-
group = "oidc",
323-
help = "OIDC provider's host address"
324-
)]
325-
oidc_issuer: Option<Url>,
297+
#[command(flatten)]
298+
oidc: Option<OidcConfig>,
326299

327300
// Kafka configuration (conditionally compiled)
328301
#[cfg(any(
@@ -391,6 +364,34 @@ pub struct Options {
391364
pub ms_clarity_tag: Option<String>,
392365
}
393366

367+
#[derive(Parser, Debug)]
368+
pub struct OidcConfig {
369+
#[arg(
370+
long = "oidc-client-id",
371+
env = "P_OIDC_CLIENT_ID",
372+
required = false,
373+
help = "Client id for OIDC provider"
374+
)]
375+
pub client_id: String,
376+
377+
#[arg(
378+
long = "oidc-client-secret",
379+
env = "P_OIDC_CLIENT_SECRET",
380+
required = false,
381+
help = "Client secret for OIDC provider"
382+
)]
383+
pub secret: String,
384+
385+
#[arg(
386+
long = "oidc-issuer",
387+
env = "P_OIDC_ISSUER",
388+
required = false,
389+
value_parser = validation::url,
390+
help = "OIDC provider's host address"
391+
)]
392+
pub issuer: Url,
393+
}
394+
394395
impl Options {
395396
pub fn local_stream_data_path(&self, stream_name: &str) -> PathBuf {
396397
self.local_staging_path.join(stream_name)
@@ -405,28 +406,24 @@ impl Options {
405406
}
406407

407408
pub fn openid(&self) -> Option<OpenidConfig> {
408-
match (
409-
&self.oidc_client_id,
410-
&self.oidc_client_secret,
411-
&self.oidc_issuer,
412-
) {
413-
(Some(id), Some(secret), Some(issuer)) => {
414-
let origin = if let Some(url) = self.domain_address.clone() {
415-
oidc::Origin::Production(url)
416-
} else {
417-
oidc::Origin::Local {
418-
socket_addr: self.address.clone(),
419-
https: self.tls_cert_path.is_some() && self.tls_key_path.is_some(),
420-
}
421-
};
422-
Some(OpenidConfig {
423-
id: id.clone(),
424-
secret: secret.clone(),
425-
issuer: issuer.clone(),
426-
origin,
427-
})
409+
let OidcConfig {
410+
secret,
411+
client_id,
412+
issuer,
413+
} = self.oidc.as_ref()?;
414+
let origin = if let Some(url) = self.domain_address.clone() {
415+
oidc::Origin::Production(url)
416+
} else {
417+
oidc::Origin::Local {
418+
socket_addr: self.address.clone(),
419+
https: self.tls_cert_path.is_some() && self.tls_key_path.is_some(),
428420
}
429-
_ => None,
430-
}
421+
};
422+
Some(OpenidConfig {
423+
id: client_id.clone(),
424+
secret: secret.clone(),
425+
issuer: issuer.clone(),
426+
origin,
427+
})
431428
}
432429
}

src/correlation/mod.rs renamed to src/correlation.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,36 +45,32 @@ pub static CORRELATIONS: Lazy<Correlation> = Lazy::new(Correlation::default);
4545
pub struct Correlation(RwLock<Vec<CorrelationConfig>>);
4646

4747
impl Correlation {
48-
pub async fn load(&self) -> Result<(), CorrelationError> {
49-
// lead correlations from storage
48+
//load correlations from storage
49+
pub async fn load(&self) -> anyhow::Result<()> {
5050
let store = CONFIG.storage().get_object_store();
51-
let all_correlations = store.get_correlations().await.unwrap_or_default();
52-
53-
let mut correlations = vec![];
54-
for corr in all_correlations {
55-
if corr.is_empty() {
56-
continue;
57-
}
58-
59-
let correlation: CorrelationConfig = match serde_json::from_slice(&corr) {
60-
Ok(c) => c,
61-
Err(e) => {
62-
error!("Unable to load correlation- {e}");
63-
continue;
64-
}
65-
};
66-
67-
correlations.push(correlation);
68-
}
51+
let all_correlations = store.get_all_correlations().await.unwrap_or_default();
52+
53+
let correlations: Vec<CorrelationConfig> = all_correlations
54+
.into_iter()
55+
.flat_map(|(_, correlations_bytes)| correlations_bytes)
56+
.filter_map(|correlation| {
57+
serde_json::from_slice(&correlation)
58+
.inspect_err(|e| {
59+
error!("Unable to load correlation: {e}");
60+
})
61+
.ok()
62+
})
63+
.collect();
6964

7065
let mut s = self.0.write().await;
71-
s.append(&mut correlations.clone());
66+
s.extend(correlations);
7267
Ok(())
7368
}
7469

7570
pub async fn list_correlations_for_user(
7671
&self,
7772
session_key: &SessionKey,
73+
user_id: &str,
7874
) -> Result<Vec<CorrelationConfig>, CorrelationError> {
7975
let correlations = self.0.read().await.iter().cloned().collect_vec();
8076

@@ -87,27 +83,29 @@ impl Correlation {
8783
.iter()
8884
.map(|t| t.table_name.clone())
8985
.collect_vec();
90-
if user_auth_for_query(&permissions, tables).is_ok() {
86+
if user_auth_for_query(&permissions, tables).is_ok() && c.user_id == user_id {
9187
user_correlations.push(c);
9288
}
9389
}
9490
Ok(user_correlations)
9591
}
9692

97-
pub async fn get_correlation_by_id(
93+
pub async fn get_correlation(
9894
&self,
9995
correlation_id: &str,
96+
user_id: &str,
10097
) -> Result<CorrelationConfig, CorrelationError> {
10198
let read = self.0.read().await;
102-
let correlation = read.iter().find(|c| c.id == correlation_id).cloned();
99+
let correlation = read
100+
.iter()
101+
.find(|c| c.id == correlation_id && c.user_id == user_id)
102+
.cloned();
103103

104-
if let Some(c) = correlation {
105-
Ok(c)
106-
} else {
107-
Err(CorrelationError::AnyhowError(anyhow::Error::msg(format!(
104+
correlation.ok_or_else(|| {
105+
CorrelationError::AnyhowError(anyhow::Error::msg(format!(
108106
"Unable to find correlation with ID- {correlation_id}"
109-
))))
110-
}
107+
)))
108+
})
111109
}
112110

113111
pub async fn update(&self, correlation: &CorrelationConfig) -> Result<(), CorrelationError> {
@@ -152,6 +150,7 @@ pub struct CorrelationConfig {
152150
pub version: CorrelationVersion,
153151
pub title: String,
154152
pub id: String,
153+
pub user_id: String,
155154
pub table_configs: Vec<TableConfig>,
156155
pub join_config: JoinConfig,
157156
pub filter: Option<FilterQuery>,
@@ -164,7 +163,6 @@ impl CorrelationConfig {}
164163
#[derive(Debug, Clone, Serialize, Deserialize)]
165164
#[serde(rename_all = "camelCase")]
166165
pub struct CorrelationRequest {
167-
pub version: CorrelationVersion,
168166
pub title: String,
169167
pub table_configs: Vec<TableConfig>,
170168
pub join_config: JoinConfig,
@@ -176,9 +174,10 @@ pub struct CorrelationRequest {
176174
impl From<CorrelationRequest> for CorrelationConfig {
177175
fn from(val: CorrelationRequest) -> Self {
178176
Self {
179-
version: val.version,
177+
version: CorrelationVersion::V1,
180178
title: val.title,
181179
id: get_hash(Utc::now().timestamp_micros().to_string().as_str()),
180+
user_id: String::default(),
182181
table_configs: val.table_configs,
183182
join_config: val.join_config,
184183
filter: val.filter,
@@ -189,11 +188,12 @@ impl From<CorrelationRequest> for CorrelationConfig {
189188
}
190189

191190
impl CorrelationRequest {
192-
pub fn generate_correlation_config(self, id: String) -> CorrelationConfig {
191+
pub fn generate_correlation_config(self, id: String, user_id: String) -> CorrelationConfig {
193192
CorrelationConfig {
194-
version: self.version,
193+
version: CorrelationVersion::V1,
195194
title: self.title,
196195
id,
196+
user_id,
197197
table_configs: self.table_configs,
198198
join_config: self.join_config,
199199
filter: self.filter,

0 commit comments

Comments
 (0)