mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-07-30 20:12:42 +00:00
check existence of the same label from node-agent
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -38,7 +38,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrDaemonSetNotFound = errors.New("daemonset not found")
|
||||
ErrDaemonSetNotFound = errors.New("daemonset not found")
|
||||
ErrNodeAgentLabelNotFound = errors.New("node-agent label not found")
|
||||
)
|
||||
|
||||
type LoadConcurrency struct {
|
||||
@@ -161,3 +162,21 @@ func GetConfigs(ctx context.Context, namespace string, kubeClient kubernetes.Int
|
||||
|
||||
return configs, nil
|
||||
}
|
||||
|
||||
func GetLabelValue(ctx context.Context, kubeClient kubernetes.Interface, namespace string, key string) (string, error) {
|
||||
ds, err := kubeClient.AppsV1().DaemonSets(namespace).Get(ctx, daemonSet, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "error getting node-agent daemonset")
|
||||
}
|
||||
|
||||
if ds.Spec.Template.Labels == nil {
|
||||
return "", ErrNodeAgentLabelNotFound
|
||||
}
|
||||
|
||||
val, found := ds.Spec.Template.Labels[key]
|
||||
if !found {
|
||||
return "", ErrNodeAgentLabelNotFound
|
||||
}
|
||||
|
||||
return val, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user