in server/datasource/etcd/kv/kv_dao.go [189:211]
func (s *Dao) Exist(ctx context.Context, key, project, domain string, options ...datasource.FindOption) (bool, error) {
opts := datasource.FindOptions{Key: key}
for _, o := range options {
o(&opts)
}
kvs, err := s.listNoAuth(ctx, project, domain,
datasource.WithExactLabels(),
datasource.WithLabels(opts.Labels),
datasource.WithLabelFormat(opts.LabelFormat),
datasource.WithKey(key),
datasource.WithCaseSensitive())
if err != nil {
openlog.Error("check kv exist: " + err.Error())
return false, err
}
if IsUniqueFind(opts) && len(kvs.Data) == 0 {
return false, nil
}
if len(kvs.Data) != 1 {
return false, datasource.ErrTooMany
}
return true, nil
}