1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| 1. 接口定义 type XxxManager interface { Create(args argsType) (*XxxStruct, error) Get(args argsType) (**XxxStruct, error) Update(args argsType) (*XxxStruct, error) Delete(name string, options *DeleleOptions) error } 2. 结构体定义 type XxxManagerImpl struct { Name string Namespace string kubeCli *kubernetes.Clientset } 3,构造函数 func NewXxxManagerImpl (namespace, name string, kubeCli *kubernetes.Clientset) XxxManager { return &XxxManagerImpl{ Name name, Namespace namespace, kubeCli: kubeCli, } } 4. 方法具体实现 func (xm *XxxManagerImpl) Create(args argsType) (*XxxStruct, error) { }
|