Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions server/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const MAX_OBJECT_STORE_REQUESTS: usize = 1000;
// const PERMISSIONS_WRITE: &str = "writeonly";
// const PERMISSIONS_DELETE: &str = "delete";
// const PERMISSIONS_READ_WRITE: &str = "readwrite";
const PERMISSIONS_ALL: &str = "all";
const ACCESS_ALL: &str = "all";

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ObjectStoreFormat {
Expand All @@ -72,7 +72,7 @@ pub struct ObjectStoreFormat {
#[serde(rename = "created-at")]
pub created_at: String,
pub owner: Owner,
pub access: Access,
pub permissions: Vec<Permisssion>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand All @@ -88,29 +88,18 @@ impl Owner {
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Access {
pub objects: Vec<AccessObject>,
}

impl Access {
pub fn new(objects: Vec<AccessObject>) -> Self {
Self { objects }
}
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct AccessObject {
pub struct Permisssion {
pub id: String,
pub group: String,
pub permissions: Vec<String>,
pub access: Vec<String>,
}

impl AccessObject {
impl Permisssion {
pub fn new(id: String) -> Self {
Self {
id: id.clone(),
group: id,
permissions: vec![PERMISSIONS_ALL.to_string()],
access: vec![ACCESS_ALL.to_string()],
}
}
}
Expand All @@ -122,7 +111,7 @@ impl Default for ObjectStoreFormat {
objectstore_format: "v1".to_string(),
created_at: Local::now().to_rfc3339(),
owner: Owner::new("".to_string(), "".to_string()),
access: Access::new(vec![]),
permissions: vec![Permisssion::new("parseable".to_string())],
}
}
}
Expand All @@ -132,9 +121,6 @@ impl ObjectStoreFormat {
self.owner.id.clone_from(&id);
self.owner.group = id;
}
fn set_access(&mut self, access: Vec<AccessObject>) {
self.access.objects = access;
}
}

pub async fn resolve_parseable_metadata() -> Result<(), ObjectStorageError> {
Expand Down
10 changes: 5 additions & 5 deletions server/src/storage/object_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/

use super::{
file_link::CacheState, AccessObject, LogStream, MoveDataError, ObjectStorageError,
ObjectStoreFormat, StorageDir, StorageMetadata, CACHED_FILES,
file_link::CacheState, LogStream, MoveDataError, ObjectStorageError, ObjectStoreFormat,
Permisssion, StorageDir, StorageMetadata, CACHED_FILES,
};
use crate::{alerts::Alerts, metadata::STREAM_INFO, option::CONFIG, query::Query, stats::Stats};

Expand All @@ -44,7 +44,7 @@ use std::{
};

// metadata file names in a Stream prefix
const STREAM_METADATA_FILE_NAME: &str = ".metadata.json";
const STREAM_METADATA_FILE_NAME: &str = ".stream.json";
pub(super) const PARSEABLE_METADATA_FILE_NAME: &str = ".parseable.json";
const SCHEMA_FILE_NAME: &str = ".schema";
const ALERT_FILE_NAME: &str = ".alert.json";
Expand Down Expand Up @@ -83,8 +83,8 @@ pub trait ObjectStorage: Sync + 'static {
async fn create_stream(&self, stream_name: &str) -> Result<(), ObjectStorageError> {
let mut format = ObjectStoreFormat::default();
format.set_id(CONFIG.parseable.username.clone());
let access_object = AccessObject::new(CONFIG.parseable.username.clone());
format.set_access(vec![access_object]);
let permission = Permisssion::new(CONFIG.parseable.username.clone());
format.permissions = vec![permission];

let format_json = to_bytes(&format);

Expand Down