CreateAndGenerateObjects creates provided k8s object or generate manifest collectively
(ctx context.Context, k8sObject []client.Object, option bool)
| 129 | |
| 130 | // CreateAndGenerateObjects creates provided k8s object or generate manifest collectively |
| 131 | func CreateAndGenerateObjects(ctx context.Context, k8sObject []client.Object, option bool) error { |
| 132 | for _, item := range k8sObject { |
| 133 | switch option { |
| 134 | case true: |
| 135 | if err := Print(item, OutputFormatYAML, os.Stdout); err != nil { |
| 136 | return err |
| 137 | } |
| 138 | fmt.Println("---") |
| 139 | default: |
| 140 | objectType := item.GetObjectKind().GroupVersionKind().Kind |
| 141 | if err := Client.Create(ctx, item); err != nil { |
| 142 | return err |
| 143 | } |
| 144 | fmt.Printf("%v/%v created\n", objectType, item.GetName()) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | return nil |
| 149 | } |
| 150 | |
| 151 | // GetPGControlData obtains the PgControldata from the passed pod by doing an exec. |
| 152 | // This approach should be used only in the plugin commands. |