新聞中心
kubernetes及kubeadm工作流的Phase數據結構是怎樣的,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
為洮南等地區(qū)用戶提供了全套網頁設計制作服務,及洮南網站建設行業(yè)解決方案。主營業(yè)務為網站制作、網站建設、洮南網站設計,以傳統(tǒng)方式定制建設網站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
Phase
即工作流中的階段或步驟。創(chuàng)建一個Phase
只需要實例化一個Phase struct
類型的變量即可。
Phase
定義了某個步驟及該步驟下所采取的動作。
Phase數結結構
Phase
數據結構定義位于kubernetes\cmd\kubeadm\app\cmd\phases\workflow\phase.go
。
type Phase struct { Name string // phase的名字,同一個workflow下的phase或同一個父phase下的子phase名字也必須唯一 Aliases []string // phase的別名,可以有多個 Short string // phase的簡短介紹 Long string // phase的介紹 Example string // 使用示例,類似于help信息 Hidden bool // 該phase是否需要在工作流幫助信息中隱藏 Phases []Phase // 子phase,有序排列 // RunAllSiblings allows to assign to a phase the responsibility to // run all the sibling phases // Nb. phase marked as RunAllSiblings can not have Run functions RunAllSiblings bool Run func(data RunData) error // phase的回調函數 RunIf func(data RunData) (bool, error) // 條件檢測回調函數,在Run之前調用,決定是否要繼續(xù)調用Run,如果RunIf返回(true,nil),那么Run將會被執(zhí)行,否則不執(zhí)行 // InheritFlags defines the list of flags that the cobra command generated for this phase should Inherit // from local flags defined in the parent command / or additional flags defined in the phase runner. // If the values is not set or empty, no flags will be assigned to the command // Nb. global flags are automatically inherited by nested cobra command InheritFlags []string // LocalFlags defines the list of flags that should be assigned to the cobra command generated // for this phase. // Nb. if two or phases have the same local flags, please consider using local flags in the parent command // or additional flags defined in the phase runner. LocalFlags *pflag.FlagSet // ArgsValidator defines the positional arg function to be used for validating args for this phase // If not set a phase will adopt the args of the top level command. ArgsValidator cobra.PositionalArgs }
對外方法
Phase
只提供一個方法用于添加子Phase
,這也意味著一旦創(chuàng)建它,其屬性一般就不會修改,可以動態(tài)的添加子Phase
。
func (t *Phase) AppendPhase(phase Phase) { t.Phases = append(t.Phases, phase) }
要點總結
phase可以包含子phase
通過phase
的方法func (t *Phase) AppendPhase(phase Phase)
可以把一個phase
加入到另一個phase中,從而成為其子phase。
一個phase
的子phase存放于Phase.Phases
的切片中,而且是按照添加的順序排列的,這也是子phase被執(zhí)行的順序。
一個phase
的子phase在其父phase
執(zhí)行后會立即執(zhí)行。
關于kubernetes及kubeadm工作流的Phase數據結構是怎樣的問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注創(chuàng)新互聯行業(yè)資訊頻道了解更多相關知識。
新聞名稱:kubernetes及kubeadm工作流的Phase數據結構是怎樣的
網站路徑:http://fisionsoft.com.cn/article/ghgesi.html