Skip to content

Commit

Permalink
merge: #3106
Browse files Browse the repository at this point in the history
3106: fix(si-pkg): Ensure we carry the secrets to leaf functions r=stack72 a=stack72



Co-authored-by: stack72 <[email protected]>
  • Loading branch information
si-bors-ng[bot] and stack72 authored Jan 2, 2024
2 parents 5027100 + db3f9c9 commit 9c3b1e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 15 additions & 2 deletions lib/si-pkg/src/node/leaf_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::{
};

use object_tree::{
read_key_value_line, write_key_value_line, GraphError, NodeChild, NodeKind, NodeWithChildren,
ReadBytes, WriteBytes,
read_key_value_line, read_key_value_line_opt, write_key_value_line, GraphError, NodeChild,
NodeKind, NodeWithChildren, ReadBytes, WriteBytes,
};

use crate::{LeafFunctionSpec, LeafInputLocation, LeafKind};
Expand All @@ -15,6 +15,7 @@ use super::{read_common_fields, write_common_fields, PkgNode};
const FUNC_UNIQUE_ID_STR: &str = "func_unique_id";
const LEAF_KIND_STR: &str = "leaf_kind";
const INPUT_DOMAIN_STR: &str = "input_domain";
const INPUT_SECRET_STR: &str = "input_secret";
const INPUT_DELETED_AT_STR: &str = "input_deleted_at";
const INPUT_CODE_STR: &str = "input_code";
const INPUT_RESOURCE_STR: &str = "input_resource";
Expand All @@ -25,6 +26,7 @@ pub struct LeafFunctionNode {
pub leaf_kind: LeafKind,
pub input_code: bool,
pub input_deleted_at: bool,
pub input_secret: bool,
pub input_domain: bool,
pub input_resource: bool,
pub unique_id: Option<String>,
Expand All @@ -39,6 +41,7 @@ impl WriteBytes for LeafFunctionNode {
write_key_value_line(writer, INPUT_DOMAIN_STR, self.input_domain)?;
write_key_value_line(writer, INPUT_DELETED_AT_STR, self.input_deleted_at)?;
write_key_value_line(writer, INPUT_RESOURCE_STR, self.input_resource)?;
write_key_value_line(writer, INPUT_SECRET_STR, self.input_secret)?;

write_common_fields(writer, self.unique_id.as_deref(), self.deleted)?;

Expand All @@ -65,11 +68,20 @@ impl ReadBytes for LeafFunctionNode {

let (unique_id, deleted) = read_common_fields(reader)?;

let input_secret;
let maybe_secret = read_key_value_line_opt(reader, INPUT_SECRET_STR)?;
if let Some(secret) = maybe_secret {
input_secret = bool::from_str(secret.as_str()).map_err(GraphError::parse)?;
} else {
input_secret = false
}

Ok(Some(Self {
func_unique_id,
leaf_kind,
input_code,
input_domain,
input_secret,
input_deleted_at,
input_resource,
unique_id,
Expand All @@ -93,6 +105,7 @@ impl NodeChild for LeafFunctionSpec {
input_resource: self.inputs.contains(&LeafInputLocation::Resource),
unique_id: self.unique_id.to_owned(),
deleted: self.deleted,
input_secret: self.inputs.contains(&LeafInputLocation::Secrets),
}),
vec![],
)
Expand Down
5 changes: 4 additions & 1 deletion lib/si-pkg/src/pkg/leaf_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'a> SiPkgLeafFunction<'a> {
return Err(SiPkgError::UnexpectedPkgNodeType(
PkgNode::LEAF_FUNCTION_KIND_STR,
unexpected.node_kind_str(),
))
));
}
};

Expand All @@ -50,6 +50,9 @@ impl<'a> SiPkgLeafFunction<'a> {
if node.input_deleted_at {
inputs.push(LeafInputLocation::DeletedAt);
}
if node.input_secret {
inputs.push(LeafInputLocation::Secrets);
}

Ok(Self {
func_unique_id: node.func_unique_id,
Expand Down

0 comments on commit 9c3b1e8

Please sign in to comment.