github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/service/runtime/kubernetes/client/options.go (about) 1 // Licensed under the Apache License, Version 2.0 (the "License"); 2 // you may not use this file except in compliance with the License. 3 // You may obtain a copy of the License at 4 // 5 // https://www.apache.org/licenses/LICENSE-2.0 6 // 7 // Unless required by applicable law or agreed to in writing, software 8 // distributed under the License is distributed on an "AS IS" BASIS, 9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 // See the License for the specific language governing permissions and 11 // limitations under the License. 12 // 13 // Original source: github.com/micro/go-micro/v3/util/kubernetes/client/options.go 14 15 package client 16 17 type CreateOptions struct { 18 Namespace string 19 } 20 21 type GetOptions struct { 22 Namespace string 23 Labels map[string]string 24 } 25 type UpdateOptions struct { 26 Namespace string 27 } 28 type DeleteOptions struct { 29 Namespace string 30 } 31 type ListOptions struct { 32 Namespace string 33 } 34 35 type LogOptions struct { 36 Namespace string 37 Params map[string]string 38 } 39 40 type WatchOptions struct { 41 Namespace string 42 Params map[string]string 43 } 44 45 type CreateOption func(*CreateOptions) 46 type GetOption func(*GetOptions) 47 type UpdateOption func(*UpdateOptions) 48 type DeleteOption func(*DeleteOptions) 49 type ListOption func(*ListOptions) 50 type LogOption func(*LogOptions) 51 type WatchOption func(*WatchOptions) 52 53 // LogParams provides additional params for logs 54 func LogParams(p map[string]string) LogOption { 55 return func(l *LogOptions) { 56 l.Params = p 57 } 58 } 59 60 // WatchParams used for watch params 61 func WatchParams(p map[string]string) WatchOption { 62 return func(w *WatchOptions) { 63 w.Params = p 64 } 65 } 66 67 // CreateNamespace sets the namespace for creating a resource 68 func CreateNamespace(ns string) CreateOption { 69 return func(o *CreateOptions) { 70 o.Namespace = Format(ns) 71 } 72 } 73 74 // GetNamespace sets the namespace for getting a resource 75 func GetNamespace(ns string) GetOption { 76 return func(o *GetOptions) { 77 o.Namespace = Format(ns) 78 } 79 } 80 81 // GetLabels sets the labels for when getting a resource 82 func GetLabels(ls map[string]string) GetOption { 83 return func(o *GetOptions) { 84 o.Labels = ls 85 } 86 } 87 88 // UpdateNamespace sets the namespace for updating a resource 89 func UpdateNamespace(ns string) UpdateOption { 90 return func(o *UpdateOptions) { 91 o.Namespace = Format(ns) 92 } 93 } 94 95 // DeleteNamespace sets the namespace for deleting a resource 96 func DeleteNamespace(ns string) DeleteOption { 97 return func(o *DeleteOptions) { 98 o.Namespace = Format(ns) 99 } 100 } 101 102 // ListNamespace sets the namespace for listing resources 103 func ListNamespace(ns string) ListOption { 104 return func(o *ListOptions) { 105 o.Namespace = Format(ns) 106 } 107 } 108 109 // LogNamespace sets the namespace for logging a resource 110 func LogNamespace(ns string) LogOption { 111 return func(o *LogOptions) { 112 o.Namespace = Format(ns) 113 } 114 } 115 116 // WatchNamespace sets the namespace for watching a resource 117 func WatchNamespace(ns string) WatchOption { 118 return func(o *WatchOptions) { 119 o.Namespace = Format(ns) 120 } 121 }