|
|
@ -25,7 +25,7 @@ const AnnoKeySlug = "grafana.app/slug" |
|
|
|
|
|
|
|
|
|
|
|
const AnnoKeyOriginName = "grafana.app/originName" |
|
|
|
const AnnoKeyOriginName = "grafana.app/originName" |
|
|
|
const AnnoKeyOriginPath = "grafana.app/originPath" |
|
|
|
const AnnoKeyOriginPath = "grafana.app/originPath" |
|
|
|
const AnnoKeyOriginKey = "grafana.app/originKey" |
|
|
|
const AnnoKeyOriginHash = "grafana.app/originHash" |
|
|
|
const AnnoKeyOriginTimestamp = "grafana.app/originTimestamp" |
|
|
|
const AnnoKeyOriginTimestamp = "grafana.app/originTimestamp" |
|
|
|
|
|
|
|
|
|
|
|
// ResourceOriginInfo is saved in annotations. This is used to identify where the resource came from
|
|
|
|
// ResourceOriginInfo is saved in annotations. This is used to identify where the resource came from
|
|
|
@ -37,8 +37,8 @@ type ResourceOriginInfo struct { |
|
|
|
// The path within the named origin above (external_id in the existing dashboard provisioing)
|
|
|
|
// The path within the named origin above (external_id in the existing dashboard provisioing)
|
|
|
|
Path string `json:"path,omitempty"` |
|
|
|
Path string `json:"path,omitempty"` |
|
|
|
|
|
|
|
|
|
|
|
// Verification/identification key (check_sum in existing dashboard provisioning)
|
|
|
|
// Verification/identification hash (check_sum in existing dashboard provisioning)
|
|
|
|
Key string `json:"key,omitempty"` |
|
|
|
Hash string `json:"hash,omitempty"` |
|
|
|
|
|
|
|
|
|
|
|
// Origin modification timestamp when the resource was saved
|
|
|
|
// Origin modification timestamp when the resource was saved
|
|
|
|
// This will be before the resource updated time
|
|
|
|
// This will be before the resource updated time
|
|
|
@ -77,7 +77,7 @@ type GrafanaMetaAccessor interface { |
|
|
|
SetOriginInfo(info *ResourceOriginInfo) |
|
|
|
SetOriginInfo(info *ResourceOriginInfo) |
|
|
|
GetOriginName() string |
|
|
|
GetOriginName() string |
|
|
|
GetOriginPath() string |
|
|
|
GetOriginPath() string |
|
|
|
GetOriginKey() string |
|
|
|
GetOriginHash() string |
|
|
|
GetOriginTimestamp() (*time.Time, error) |
|
|
|
GetOriginTimestamp() (*time.Time, error) |
|
|
|
|
|
|
|
|
|
|
|
// Find a title in the object
|
|
|
|
// Find a title in the object
|
|
|
@ -219,15 +219,15 @@ func (m *grafanaMetaAccessor) SetOriginInfo(info *ResourceOriginInfo) { |
|
|
|
|
|
|
|
|
|
|
|
delete(anno, AnnoKeyOriginName) |
|
|
|
delete(anno, AnnoKeyOriginName) |
|
|
|
delete(anno, AnnoKeyOriginPath) |
|
|
|
delete(anno, AnnoKeyOriginPath) |
|
|
|
delete(anno, AnnoKeyOriginKey) |
|
|
|
delete(anno, AnnoKeyOriginHash) |
|
|
|
delete(anno, AnnoKeyOriginTimestamp) |
|
|
|
delete(anno, AnnoKeyOriginTimestamp) |
|
|
|
if info != nil && info.Name != "" { |
|
|
|
if info != nil && info.Name != "" { |
|
|
|
anno[AnnoKeyOriginName] = info.Name |
|
|
|
anno[AnnoKeyOriginName] = info.Name |
|
|
|
if info.Path != "" { |
|
|
|
if info.Path != "" { |
|
|
|
anno[AnnoKeyOriginPath] = info.Path |
|
|
|
anno[AnnoKeyOriginPath] = info.Path |
|
|
|
} |
|
|
|
} |
|
|
|
if info.Key != "" { |
|
|
|
if info.Hash != "" { |
|
|
|
anno[AnnoKeyOriginKey] = info.Key |
|
|
|
anno[AnnoKeyOriginHash] = info.Hash |
|
|
|
} |
|
|
|
} |
|
|
|
if info.Timestamp != nil { |
|
|
|
if info.Timestamp != nil { |
|
|
|
anno[AnnoKeyOriginTimestamp] = info.Timestamp.UTC().Format(time.RFC3339) |
|
|
|
anno[AnnoKeyOriginTimestamp] = info.Timestamp.UTC().Format(time.RFC3339) |
|
|
@ -245,7 +245,7 @@ func (m *grafanaMetaAccessor) GetOriginInfo() (*ResourceOriginInfo, error) { |
|
|
|
return &ResourceOriginInfo{ |
|
|
|
return &ResourceOriginInfo{ |
|
|
|
Name: v, |
|
|
|
Name: v, |
|
|
|
Path: m.GetOriginPath(), |
|
|
|
Path: m.GetOriginPath(), |
|
|
|
Key: m.GetOriginKey(), |
|
|
|
Hash: m.GetOriginHash(), |
|
|
|
Timestamp: t, |
|
|
|
Timestamp: t, |
|
|
|
}, err |
|
|
|
}, err |
|
|
|
} |
|
|
|
} |
|
|
@ -258,8 +258,8 @@ func (m *grafanaMetaAccessor) GetOriginPath() string { |
|
|
|
return m.get(AnnoKeyOriginPath) |
|
|
|
return m.get(AnnoKeyOriginPath) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *grafanaMetaAccessor) GetOriginKey() string { |
|
|
|
func (m *grafanaMetaAccessor) GetOriginHash() string { |
|
|
|
return m.get(AnnoKeyOriginKey) |
|
|
|
return m.get(AnnoKeyOriginHash) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *grafanaMetaAccessor) GetOriginTimestamp() (*time.Time, error) { |
|
|
|
func (m *grafanaMetaAccessor) GetOriginTimestamp() (*time.Time, error) { |
|
|
|