( ctx context.Context, cluster client.Object, backupObject client.Object, pluginName string, parameters map[string]string, )
| 91 | } |
| 92 | |
| 93 | func (data *data) innerBackup( |
| 94 | ctx context.Context, |
| 95 | cluster client.Object, |
| 96 | backupObject client.Object, |
| 97 | pluginName string, |
| 98 | parameters map[string]string, |
| 99 | ) (*BackupResponse, error) { |
| 100 | contextLogger := log.FromContext(ctx) |
| 101 | |
| 102 | serializedCluster, err := json.Marshal(cluster) |
| 103 | if err != nil { |
| 104 | return nil, fmt.Errorf("while serializing %s %s/%s to JSON: %w", |
| 105 | cluster.GetObjectKind().GroupVersionKind().Kind, |
| 106 | cluster.GetNamespace(), cluster.GetName(), |
| 107 | err, |
| 108 | ) |
| 109 | } |
| 110 | |
| 111 | serializedBackup, err := json.Marshal(backupObject) |
| 112 | if err != nil { |
| 113 | return nil, fmt.Errorf("while serializing %s %s/%s to JSON: %w", |
| 114 | backupObject.GetObjectKind().GroupVersionKind().Kind, |
| 115 | backupObject.GetNamespace(), backupObject.GetName(), |
| 116 | err, |
| 117 | ) |
| 118 | } |
| 119 | |
| 120 | plugin, err := data.getPlugin(pluginName) |
| 121 | if err != nil { |
| 122 | return nil, err |
| 123 | } |
| 124 | |
| 125 | if !slices.Contains(plugin.PluginCapabilities(), identity.PluginCapability_Service_TYPE_BACKUP_SERVICE) { |
| 126 | return nil, ErrPluginNotSupportBackup |
| 127 | } |
| 128 | |
| 129 | if !slices.Contains(plugin.BackupCapabilities(), backup.BackupCapability_RPC_TYPE_BACKUP) { |
| 130 | return nil, ErrPluginNotSupportBackupEndpoint |
| 131 | } |
| 132 | |
| 133 | contextLogger = contextLogger.WithValues( |
| 134 | "pluginName", pluginName, |
| 135 | ) |
| 136 | |
| 137 | request := backup.BackupRequest{ |
| 138 | ClusterDefinition: serializedCluster, |
| 139 | BackupDefinition: serializedBackup, |
| 140 | Parameters: parameters, |
| 141 | } |
| 142 | |
| 143 | contextLogger.Trace( |
| 144 | "Calling Backup endpoint", |
| 145 | "clusterDefinition", request.ClusterDefinition, |
| 146 | "parameters", parameters) |
| 147 | |
| 148 | result, err := plugin.BackupClient().Backup(ctx, &request) |
| 149 | if err != nil { |
| 150 | contextLogger.Error(err, "Error while calling Backup, failing") |
no test coverage detected