mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-07-30 12:02:44 +00:00
issue 8754: add third party annotation support
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -44,8 +44,9 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrDaemonSetNotFound = errors.New("daemonset not found")
|
||||
ErrNodeAgentLabelNotFound = errors.New("node-agent label not found")
|
||||
ErrDaemonSetNotFound = errors.New("daemonset not found")
|
||||
ErrNodeAgentLabelNotFound = errors.New("node-agent label not found")
|
||||
ErrNodeAgentAnnotationNotFound = errors.New("node-agent annotation not found")
|
||||
)
|
||||
|
||||
type LoadConcurrency struct {
|
||||
@@ -225,3 +226,26 @@ func GetLabelValue(ctx context.Context, kubeClient kubernetes.Interface, namespa
|
||||
|
||||
return val, nil
|
||||
}
|
||||
|
||||
func GetAnnotationValue(ctx context.Context, kubeClient kubernetes.Interface, namespace string, key string, osType string) (string, error) {
|
||||
dsName := daemonSet
|
||||
if osType == kube.NodeOSWindows {
|
||||
dsName = daemonsetWindows
|
||||
}
|
||||
|
||||
ds, err := kubeClient.AppsV1().DaemonSets(namespace).Get(ctx, dsName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "error getting %s daemonset", dsName)
|
||||
}
|
||||
|
||||
if ds.Spec.Template.Annotations == nil {
|
||||
return "", ErrNodeAgentAnnotationNotFound
|
||||
}
|
||||
|
||||
val, found := ds.Spec.Template.Annotations[key]
|
||||
if !found {
|
||||
return "", ErrNodeAgentAnnotationNotFound
|
||||
}
|
||||
|
||||
return val, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user