MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / CreateAndGenerateObjects

Function CreateAndGenerateObjects

internal/cmd/plugin/plugin.go:131–149  ·  view source on GitHub ↗

CreateAndGenerateObjects creates provided k8s object or generate manifest collectively

(ctx context.Context, k8sObject []client.Object, option bool)

Source from the content-addressed store, hash-verified

129
130// CreateAndGenerateObjects creates provided k8s object or generate manifest collectively
131func 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.

Callers 2

executeMethod · 0.92
executeMethod · 0.92

Calls 3

PrintFunction · 0.85
CreateMethod · 0.65
GetNameMethod · 0.65

Tested by

no test coverage detected