Visitor模式也叫访问模式
1 | // vendor/k8s.io/cli-runtime/pkg/resource/interfaces.go |
1 | // vendor/k8s.io/cli-runtime/pkg/resource/visitor.go |
1 | // 从io.Reader读取数据 |
1 | // 构造r.visitor |
调用过程
1 | func (o *CreateOptions) RunCreate(f cmdutil.Factory, cmd *cobra.Command) error { |
1 | // 下面是一层一层Visit方法的调用 |
REF:
1.https://coolshell.cn/articles/21263.html
2.staging/src/k8s.io/cli-runtime/pkg/resource/builder.go
3.staging/src/k8s.io/cli-runtime/pkg/resource/visitor.go
4.staging/src/k8s.io/kubectl/pkg/cmd/create/create.go