Documentation
¶
Overview ¶
Package migrate는 기존 문서를 지금의 설정과 규칙에 맞춘다. ADR 0038.
고치는 것은 셋이다. 켜진 속성의 필수 필드를 단계별 초기값으로 채우고, 꺼진 속성의 필드를 지우고, 위치와 단계의 불일치를 프론트매터를 위치에 맞춰 고친다. 단계별 초기값과 단계-디렉토리 대응의 진실원은 internal/wiki 다. 값을 따로 정의하지 않고 그것을 부른다.
파일을 옮기지 않고 슬러그를 바꾸지 않는다. 이동은 promote, demote, archive, mv 의 일이다. 문서를 승급시키지도 않는다. inbox 디렉토리에 있으면서 context 라고 선언한 문서는 선언이 inbox 로 내려갈 뿐이고 파일은 제자리에 남는다. 대량 작업이 게이트를 우회하는 경로가 되면 게이트가 유일한 관문이라는 전제가 무너진다.
게이트 위반과 깨진 링크는 고치지 않는다. 어떤 문서에 이어야 하는지는 판단이므로 보고만 하고 promote 나 demote 를 안내한다.
Index ¶
Constants ¶
const ( KindStage = "stage" // artifact_stage 를 위치에 맞춘다 KindFill = "fill" // 켜진 속성의 필수 필드를 단계별 초기값로 채운다 KindRemove = "remove" // 꺼진 속성의 필드를 지운다 )
변경 종류다. JSON 에 그대로 나간다.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
Kind string `json:"kind"`
Field string `json:"field"`
Old string `json:"old,omitempty"` // 옛값. 없었으면 빈 문자열
New string `json:"new,omitempty"` // 새값. 지우면 빈 문자열
}
Change는 문서 하나에 가할 변경 하나다. 필드 이름과 옛값, 새값을 함께 낸다. 값은 displayValue 의 표시형을 따른다.
type DocResult ¶
type DocResult struct {
Path string `json:"path"`
Changes []Change `json:"changes"` // 적용했거나 적용할 변경
Blocked []Change `json:"blocked,omitempty"` // --force 없이는 못 지운 값 있는 필드
Remainders []Remainder `json:"remainders,omitempty"` // 채우지 못해 남은 필수 필드
Written bool `json:"written"`
}
DocResult는 문서 하나의 마이그레이션 결과다.
type Remainder ¶
type Remainder struct {
Field string `json:"field"`
Reason string `json:"reason"` // 채우지 못한 이유. 사용자가 읽는 문장이다
}
Remainder는 문서를 완전히 맞추지 못하고 남긴 필수 필드다. 채울 진실원이 migrate 밖에 있는 필드다. 남긴 것이 있으면 그 문서는 맞춘 것으로 세지 않는다.
type Report ¶
type Report struct {
Applied bool `json:"applied"`
Docs int `json:"docs"`
NonConforming int `json:"nonConforming"` // 규칙에 맞지 않은 문서 수. 변경, 보류, 남은 필드를 다 센다
Partial int `json:"partial"` // 채우지 못한 필드가 남은 문서 수
Changed int `json:"changed"` // 변경이 있는 문서 수
Written int `json:"written"` // 실제로 쓴 문서 수
Blocked int `json:"blocked"` // --force 없이 못 지운 변경 수
Unparsed []string `json:"unparsed,omitempty"` // 프론트매터를 읽지 못한 문서
Advisories []Advisory `json:"advisories"`
Documents []DocResult `json:"documents"`
}
Report는 migrate 실행 결과다. Documents 는 변경, 보류, 남은 필드 중 하나라도 있는 문서만 실는다. 변화가 없는 문서까지 실으면 수백 줄이 된다.