|
| 1 | +package instance |
| 2 | + |
| 3 | +import ( |
| 4 | + "strconv" |
| 5 | + |
| 6 | + "k8s.io/apimachinery/pkg/types" |
| 7 | + |
| 8 | + "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/metadata" |
| 9 | +) |
| 10 | + |
| 11 | +type backupResultMetadata struct { |
| 12 | + timeline string |
| 13 | + version string |
| 14 | + name string |
| 15 | + displayName string |
| 16 | + clusterUID string |
| 17 | + pluginName string |
| 18 | +} |
| 19 | + |
| 20 | +func (b backupResultMetadata) toMap() map[string]string { |
| 21 | + return map[string]string{ |
| 22 | + "timeline": b.timeline, |
| 23 | + "version": b.version, |
| 24 | + "name": b.name, |
| 25 | + "displayName": b.displayName, |
| 26 | + "clusterUID": b.clusterUID, |
| 27 | + "pluginName": b.pluginName, |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +func newBackupResultMetadata(clusterUID types.UID, timeline int) backupResultMetadata { |
| 32 | + return backupResultMetadata{ |
| 33 | + timeline: strconv.Itoa(timeline), |
| 34 | + clusterUID: string(clusterUID), |
| 35 | + // static values |
| 36 | + version: metadata.Data.Version, |
| 37 | + name: metadata.Data.Name, |
| 38 | + displayName: metadata.Data.DisplayName, |
| 39 | + pluginName: metadata.PluginName, |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +func newBackupResultMetadataFromMap(m map[string]string) backupResultMetadata { |
| 44 | + if m == nil { |
| 45 | + return backupResultMetadata{} |
| 46 | + } |
| 47 | + |
| 48 | + return backupResultMetadata{ |
| 49 | + timeline: m["timeline"], |
| 50 | + version: m["version"], |
| 51 | + name: m["name"], |
| 52 | + displayName: m["displayName"], |
| 53 | + clusterUID: m["clusterUID"], |
| 54 | + pluginName: m["pluginName"], |
| 55 | + } |
| 56 | +} |
0 commit comments