func (lock *Lock) get() (runtime.Object, error) {
	log.Printf("kube/lock %v: get", lock)
	if obj, err := lock.client.DaemonSets(lock.namespace).Get(lock.name, metav1.GetOptions{}); err != nil {
		return nil, fmt.Errorf("Get: %v", err)
	} else {
		return obj, nil
	}
}
get lock object
package kube
import (
	"context"
	"fmt"
	"log"
	"time"
	appsv1 "k8s.io/api/apps/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/api/meta"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/fields"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/util/wait"
	"k8s.io/apimachinery/pkg/watch"
	appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1"
	"k8s.io/client-go/rest"
)
type Lock struct {
	client     appsv1client.AppsV1Interface
	namespace  string
	name       string
	annotation string
	value      string
}
func (lock *Lock) String() string {
	return fmt.Sprintf("%v/daemonsets/%v", lock.namespace, lock.name)
}
func (lock *Lock) connect(config *rest.Config) error {
	if client, err := appsv1client.NewForConfig(config); err != nil {
		return err
	} else {
		lock.client = client
	}
	return nil
}
func (lock *Lock) test(object runtime.Object) (value string, available bool, acquired bool) {
	if accessor, err := meta.Accessor(object); err != nil {
		panic(err)
	} else if value := accessor.GetAnnotations()[lock.annotation]; value == "" {
		log.Printf("kube/lock %v: test %v=%v: free", lock, lock.annotation, value)
		return value, true, false
	} else if value == lock.value {
		log.Printf("kube/lock %v: test %v=%v: acquired", lock, lock.annotation, value)
		return value, true, true
	} else {
		log.Printf("kube/lock %v: test %v=%v: locked", lock, lock.annotation, value)
		return value, false, false
	}
}
func (lock *Lock) set(object *runtime.Object) error {
	if accessor, err := meta.Accessor(*object); err != nil {
		panic(err)
	} else if value := accessor.GetAnnotations()[lock.annotation]; value != "" && value != lock.value {
		return fmt.Errorf("Busy lock: %v=%v", lock.annotation, value)
	} else {
		log.Printf("kube/lock %v: set %v=%v", lock, lock.annotation, lock.value)
		accessor.GetAnnotations()[lock.annotation] = lock.value
	}
	return nil
}
func (lock *Lock) clear(object *runtime.Object) error {
	if accessor, err := meta.Accessor(*object); err != nil {
		panic(err)
	} else if value := accessor.GetAnnotations()[lock.annotation]; value != lock.value {
		return fmt.Errorf("Broken lock: %v=%v, expected %v", lock.annotation, value, lock.value)
	} else {
		log.Printf("kube/lock %v: clear %v=%v", lock, lock.annotation, value)
		delete(accessor.GetAnnotations(), lock.annotation)
	}
	return nil
}