Skip to content
Open
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
1 change: 1 addition & 0 deletions apps/origin-src/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod oplog;
pub mod output;
pub mod policy;
pub mod queue;
pub mod service;
pub mod store;
pub mod targets;
pub mod tree;
Expand Down
26 changes: 26 additions & 0 deletions apps/origin-src/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,32 @@ impl TryFrom<PolicyFile> for Policy {
}

impl Policy {
/// The first `policy.toml` of a repository: `node`, whose public key is
/// `key`, is the authority of `policy` and `main`, and neither requires
/// anything, so a solo project lands instantly.
#[must_use]
pub fn initial(node: &PrincipalName, key: &NodePublicKey) -> String {
format!(
"# Who may land what. Changing it is a landing on `policy`.\n\
\n\
# Each node's public key.\n\
[nodes]\n\
\"{node}\" = \"{key}\"\n\
\n\
# Groups of users and nodes, for requirements:\n\
# [groups]\n\
# runners = [\"node:ci-1\"]\n\
\n\
# The node ordering each target, and the statements landing needs.\n\
[targets.policy]\n\
authority = \"node:{node}\"\n\
\n\
[targets.main]\n\
authority = \"node:{node}\"\n\
# require = [{{ kind = \"ci.test\", verdict = \"pass\", issuer = \"group:runners\" }}]\n"
)
}

/// Checks that the group `principals` names, if any, is defined.
fn check(&self, principals: Principals) -> Result<Principals, RuleError> {
match &principals {
Expand Down
Loading