mirror of
https://github.com/larksuite/cli.git
synced 2026-09-14 18:42:53 +08:00
52 lines
2.3 KiB
Go
52 lines
2.3 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package platform
|
|
|
|
// FailurePolicy controls what the framework does when a plugin's install
|
|
// stage fails (Capabilities() panics, Install returns error, etc.).
|
|
type FailurePolicy int
|
|
|
|
const (
|
|
// FailOpen (default) — log a warning and skip THIS plugin; the rest
|
|
// of the CLI keeps running. Appropriate for pure-observer plugins
|
|
// where missing audit data is preferable to a broken CLI.
|
|
FailOpen FailurePolicy = iota
|
|
|
|
// FailClosed — abort the entire CLI startup. Required for any plugin
|
|
// that contributes Restrict() (a missing policy plugin = missing
|
|
// security boundary), EmbeddedSkills() (silently dropping distribution
|
|
// assets would violate build integrity), or any other safety-sensitive
|
|
// concern. The Builder sets it automatically for Restrict and
|
|
// EmbeddedSkills; the host validates hand-written plugins after staging.
|
|
FailClosed
|
|
)
|
|
|
|
// Capabilities declares the plugin's self-description. Plugin.Capabilities
|
|
// MUST be implemented even when every field would be its zero value --
|
|
// the requirement keeps FailurePolicy / Restricts visible to the author
|
|
// at the moment they write the plugin, preventing the "I just want to
|
|
// add an audit observer" mistake of accidentally shipping a policy
|
|
// plugin with the default FailOpen.
|
|
type Capabilities struct {
|
|
// RequiredCLIVersion is a semver constraint (e.g. ">=1.1.0").
|
|
// Plugins that need a specific framework feature should declare
|
|
// the minimum version they tested against; the host fails the
|
|
// install when the running CLI is older. Empty string means "no
|
|
// version requirement".
|
|
RequiredCLIVersion string
|
|
|
|
// Restricts declares whether Install will call r.Restrict(). The
|
|
// framework enforces consistency: declaring Restricts=true and
|
|
// then NOT calling r.Restrict (or vice versa) aborts the install
|
|
// with the `restricts_mismatch` reason_code. This pre-flight
|
|
// declaration also lets `config policy show` introspect "which
|
|
// plugins are policy plugins" without running them.
|
|
Restricts bool
|
|
|
|
// FailurePolicy decides what happens on install failure. See the
|
|
// constants above; the framework requires FailClosed whenever
|
|
// Restricts=true or Install contributes EmbeddedSkills.
|
|
FailurePolicy FailurePolicy
|
|
}
|