|
| 1 | +package mom |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + |
| 7 | + "github.com/openshift/multi-operator-manager/pkg/library/libraryapplyconfiguration" |
| 8 | + "github.com/spf13/cobra" |
| 9 | + "k8s.io/cli-runtime/pkg/genericiooptions" |
| 10 | +) |
| 11 | + |
| 12 | +func NewApplyConfigurationCommand(streams genericiooptions.IOStreams) *cobra.Command { |
| 13 | + return libraryapplyconfiguration.NewApplyConfigurationCommand(RunApplyConfiguration, runOutputResources, streams) |
| 14 | +} |
| 15 | + |
| 16 | +func RunApplyConfiguration(ctx context.Context, input libraryapplyconfiguration.ApplyConfigurationInput) (*libraryapplyconfiguration.ApplyConfigurationRunResult, libraryapplyconfiguration.AllDesiredMutationsGetter, error) { |
| 17 | + // TODO: Implement operator reconciliation logic |
| 18 | + // |
| 19 | + // The manifestclient (input.ManagementClient) is a drop-in replacement for standard k8s clients. |
| 20 | + // Pass it to your operator and run sync logic ONCE (not in a loop). |
| 21 | + // |
| 22 | + // Implementation steps: |
| 23 | + // 1. Create operator client using input.ManagementClient (manifestclient) |
| 24 | + // 2. Create informers from the manifestclient |
| 25 | + // 3. Initialize the operator with these clients |
| 26 | + // 4. Run sync logic ONCE (not in a control loop) |
| 27 | + // 5. Return the result |
| 28 | + // |
| 29 | + // Example pattern: |
| 30 | + // operatorClient, dynamicInformers, err := genericoperatorclient.NewStaticPodOperatorClient(...) |
| 31 | + // if err != nil { return nil, nil, err } |
| 32 | + // |
| 33 | + // // Create controllers with manifestclient-based informers |
| 34 | + // // Run sync once (not Start()) |
| 35 | + // // Return result |
| 36 | + // |
| 37 | + // Reference implementation: |
| 38 | + // github.com/openshift/cluster-authentication-operator/pkg/cmd/mom/apply_configuration_command.go |
| 39 | + // |
| 40 | + // Key considerations: |
| 41 | + // - Use input.ManagementClient instead of real k8s client |
| 42 | + // - Use input.ManagementEventRecorder for events |
| 43 | + // - Run sync ONCE, not in a loop |
| 44 | + // - The manifestclient reads from input directory and writes to output directory |
| 45 | + |
| 46 | + return nil, nil, fmt.Errorf("apply-configuration not yet implemented - see TODO comments above for implementation guidance") |
| 47 | +} |
0 commit comments