Documentation
¶
Overview ¶
Package evidence は runbook の実行中の送受信を、ステップごとの証跡ファイルとして保存する。
runn の Capturer を実装し、runn が渡す HTTP / gRPC / DB / exec の送受信を、 実行中のステップ (runn の Trail) ごとに集めて JSON ファイルに書き出す。 詳細は docs/design/evidence-report.md の 4 章。
Index ¶
- Constants
- func SafeName(s string) string
- func StepKey(trs runn.Trails) (key string, index int, ok bool)
- func ValidatePaths(paths []string) error
- type Capturer
- func (c *Capturer) CaptureAgentRequest(string, *runn.AgentRequest)
- func (c *Capturer) CaptureAgentResponse(string, *runn.AgentResponse)
- func (c *Capturer) CaptureCDPAction(runn.CDPAction)
- func (c *Capturer) CaptureCDPEnd(string)
- func (c *Capturer) CaptureCDPResponse(runn.CDPAction, map[string]any)
- func (c *Capturer) CaptureCDPStart(string)
- func (c *Capturer) CaptureDBResponse(name string, res *runn.DBResponse)
- func (c *Capturer) CaptureDBStatement(name string, stmt string)
- func (c *Capturer) CaptureEnd(runn.Trails, string, string)
- func (c *Capturer) CaptureExecCommand(command, shell string, _ bool)
- func (c *Capturer) CaptureExecStderr(stderr string)
- func (c *Capturer) CaptureExecStdin(stdin string)
- func (c *Capturer) CaptureExecStdout(stdout string)
- func (c *Capturer) CaptureGRPCClientClose()
- func (c *Capturer) CaptureGRPCEnd(string, runn.GRPCType, string, string)
- func (c *Capturer) CaptureGRPCRequestHeaders(h map[string][]string)
- func (c *Capturer) CaptureGRPCRequestMessage(m map[string]any)
- func (c *Capturer) CaptureGRPCResponseHeaders(h map[string][]string)
- func (c *Capturer) CaptureGRPCResponseMessage(m map[string]any)
- func (c *Capturer) CaptureGRPCResponseStatus(s *status.Status)
- func (c *Capturer) CaptureGRPCResponseTrailers(t map[string][]string)
- func (c *Capturer) CaptureGRPCStart(name string, typ runn.GRPCType, service, method string)
- func (c *Capturer) CaptureHTTPRequest(name string, req *http.Request)
- func (c *Capturer) CaptureHTTPResponse(name string, res *http.Response)
- func (c *Capturer) CaptureResult(runn.Trails, *runn.RunResult)
- func (c *Capturer) CaptureResultByStep(runn.Trails, *runn.RunResult)
- func (c *Capturer) CaptureSSHCommand(string)
- func (c *Capturer) CaptureSSHStderr(string)
- func (c *Capturer) CaptureSSHStdout(string)
- func (c *Capturer) CaptureStart(runn.Trails, string, string)
- func (c *Capturer) CurrentStep() (key string, index int)
- func (c *Capturer) Errs() error
- func (c *Capturer) Files() []File
- func (c *Capturer) Flush(dir, base string) ([]Written, error)
- func (c *Capturer) SetCurrentTrails(trs runn.Trails)
- type File
- type Mask
- type Mode
- type Written
Constants ¶
const Masked = "***"
Masked は隠した値の置き換え先。
const MaxBody = 1 << 20
MaxBody は証跡に書く本文の上限 (これを超える分は切り捨てて truncated を付ける)。
Variables ¶
This section is empty.
Functions ¶
func StepKey ¶
StepKey は Trail から、ステップのキーとトップレベルのステップの番号 (1 始まり) を作る。
- トップレベルのステップ: "create_loan"
- include 先のステップ: "inspect_history_book_0.call" (呼び出したステップのキーと . でつなぐ)
- loop の回 (0 始まり): "member_loans[2]"
- steps が配列で書かれた runbook: 配列の添字をキーにする ("3")
ステップの Trail がなければ ok は false。
func ValidatePaths ¶
ValidatePaths は evidence.mask.paths の書き方を確かめる (runnora validate 用)。
Types ¶
type Capturer ¶
type Capturer struct {
// contains filtered or unexported fields
}
Capturer は runn の Capturer を実装し、1 つの runbook の送受信をステップごとに集める。 runbook ごとに New で作り、実行後に Flush で書き出す。
func (*Capturer) CaptureAgentRequest ¶
func (c *Capturer) CaptureAgentRequest(string, *runn.AgentRequest)
func (*Capturer) CaptureAgentResponse ¶
func (c *Capturer) CaptureAgentResponse(string, *runn.AgentResponse)
func (*Capturer) CaptureCDPAction ¶
func (*Capturer) CaptureCDPEnd ¶
func (*Capturer) CaptureCDPResponse ¶
func (*Capturer) CaptureCDPStart ¶
func (*Capturer) CaptureDBResponse ¶
func (c *Capturer) CaptureDBResponse(name string, res *runn.DBResponse)
func (*Capturer) CaptureDBStatement ¶
func (*Capturer) CaptureExecCommand ¶
func (*Capturer) CaptureExecStderr ¶
func (*Capturer) CaptureExecStdin ¶
func (*Capturer) CaptureExecStdout ¶
func (*Capturer) CaptureGRPCClientClose ¶
func (c *Capturer) CaptureGRPCClientClose()
func (*Capturer) CaptureGRPCEnd ¶
func (*Capturer) CaptureGRPCRequestHeaders ¶
func (*Capturer) CaptureGRPCRequestMessage ¶
func (*Capturer) CaptureGRPCResponseHeaders ¶
func (*Capturer) CaptureGRPCResponseMessage ¶
func (*Capturer) CaptureGRPCResponseStatus ¶
func (*Capturer) CaptureGRPCResponseTrailers ¶
func (*Capturer) CaptureGRPCStart ¶
func (*Capturer) CaptureHTTPRequest ¶
func (*Capturer) CaptureHTTPResponse ¶
func (*Capturer) CaptureResultByStep ¶
func (*Capturer) CaptureSSHCommand ¶
func (*Capturer) CaptureSSHStderr ¶
func (*Capturer) CaptureSSHStdout ¶
func (*Capturer) CurrentStep ¶
CurrentStep は実行中のステップのキーと、トップレベルのステップの番号を返す (diffEps の記録用)。
func (*Capturer) Flush ¶
Flush は集めた証跡を dir (シナリオの証跡フォルダ) に書き出す。 base は Written.Path の基準 (証跡のフォルダ evidence/)。
func (*Capturer) SetCurrentTrails ¶
SetCurrentTrails は runn が実行するステップを切り替えるたびに呼ばれる。
type File ¶
type File struct {
ScenarioID string `json:"scenarioId"`
Key string `json:"key"`
Index int `json:"index"`
Runner string `json:"runner"`
RunnerKey string `json:"runnerKey,omitempty"`
StartedAt string `json:"startedAt"`
Request any `json:"request,omitempty"`
Response any `json:"response,omitempty"`
Masked []string `json:"masked,omitempty"`
}
File は 1 ステップ分の証跡ファイルの中身。
type Mask ¶
type Mask struct {
// contains filtered or unexported fields
}
Mask は証跡に書く前に秘密情報を隠す規則。
func (*Mask) Body ¶
Body は JSON の値 v の中の、evidence.mask.paths に当たる値を *** にした写しを返す。 JSON でない値 (文字列の本文など) や、パスが当てはまらない値はそのまま返す。
func (*Mask) HTTPHeaders ¶
HTTPHeaders は http.Header を Headers で隠す。