diff --git a/docs/dfx-json-schema.json b/docs/dfx-json-schema.json index ec157b6e98..14a6cdf679 100644 --- a/docs/dfx-json-schema.json +++ b/docs/dfx-json-schema.json @@ -137,10 +137,29 @@ } }, "CanisterLogVisibility": { - "type": "string", - "enum": [ - "controllers", - "public" + "oneOf": [ + { + "type": "string", + "enum": [ + "controllers", + "public" + ] + }, + { + "type": "object", + "required": [ + "allowedviewers" + ], + "properties": { + "allowedviewers": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + } ] }, "CanisterMetadataSection": { @@ -947,7 +966,7 @@ }, "log_visibility": { "title": "Log Visibility", - "description": "Specifies who is allowed to read the canister's logs.\n\nCan be \"public\" or \"controllers\".", + "description": "Specifies who is allowed to read the canister's logs.\n\nCan be \"public\", \"controllers\" or \"allowedviewers\" with a list of Principals.", "anyOf": [ { "$ref": "#/definitions/CanisterLogVisibility" diff --git a/src/dfx-core/src/config/model/dfinity.rs b/src/dfx-core/src/config/model/dfinity.rs index 50d2883ea2..c6844fabdc 100644 --- a/src/dfx-core/src/config/model/dfinity.rs +++ b/src/dfx-core/src/config/model/dfinity.rs @@ -407,12 +407,13 @@ impl CanisterTypeProperties { } } -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[derive(Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "lowercase")] pub enum CanisterLogVisibility { #[default] Controllers, Public, + AllowedViewers(Vec), } impl From for LogVisibility { @@ -420,6 +421,13 @@ impl From for LogVisibility { match value { CanisterLogVisibility::Controllers => LogVisibility::Controllers, CanisterLogVisibility::Public => LogVisibility::Public, + CanisterLogVisibility::AllowedViewers(viewers) => { + let principals: Vec<_> = viewers + .iter() + .map(|v| Principal::from_text(v).unwrap()) + .collect(); + LogVisibility::AllowedViewers(principals) + } } } } @@ -475,7 +483,7 @@ pub struct InitializationValues { /// # Log Visibility /// Specifies who is allowed to read the canister's logs. /// - /// Can be "public" or "controllers". + /// Can be "public", "controllers" or "allowedviewers" with a list of Principals. #[schemars(with = "Option")] pub log_visibility: Option, } @@ -1008,6 +1016,7 @@ impl ConfigInterface { .map_err(|e| GetLogVisibilityFailed(canister_name.to_string(), e))? .initialization_values .log_visibility + .clone() .map(|visibility| visibility.into())) }