|
@@ -23,11 +23,11 @@ import (
|
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
"errors"
|
|
"errors"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
|
|
+ "regexp"
|
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/1password/onepassword-sdk-go"
|
|
"github.com/1password/onepassword-sdk-go"
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
corev1 "k8s.io/api/core/v1"
|
|
|
- "k8s.io/kube-openapi/pkg/validation/strfmt"
|
|
|
|
|
|
|
|
|
|
esv1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
|
|
esv1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
|
|
|
"github.com/external-secrets/external-secrets/runtime/constants"
|
|
"github.com/external-secrets/external-secrets/runtime/constants"
|
|
@@ -47,6 +47,16 @@ const (
|
|
|
// ErrKeyNotFound is returned when a key is not found in the 1Password Vaults.
|
|
// ErrKeyNotFound is returned when a key is not found in the 1Password Vaults.
|
|
|
var ErrKeyNotFound = errors.New("key not found")
|
|
var ErrKeyNotFound = errors.New("key not found")
|
|
|
|
|
|
|
|
|
|
+// nativeItemIDPattern matches a 1Password item ID per the Connect
|
|
|
|
|
+// server OpenAPI spec (^[\da-z]{26}$). Despite being called "UUIDs"
|
|
|
|
|
+// in 1Password's SDK and docs, they are not RFC 4122 UUIDs.
|
|
|
|
|
+// https://github.com/1Password/connect/blob/7485a59/docs/openapi/spec.yaml#L73-L75
|
|
|
|
|
+var nativeItemIDPattern = regexp.MustCompile(`^[\da-z]{26}$`)
|
|
|
|
|
+
|
|
|
|
|
+func isNativeItemID(s string) bool {
|
|
|
|
|
+ return nativeItemIDPattern.MatchString(s)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// PushSecretMetadataSpec defines the metadata configuration for pushing secrets to 1Password.
|
|
// PushSecretMetadataSpec defines the metadata configuration for pushing secrets to 1Password.
|
|
|
type PushSecretMetadataSpec struct {
|
|
type PushSecretMetadataSpec struct {
|
|
|
Tags []string `json:"tags,omitempty"`
|
|
Tags []string `json:"tags,omitempty"`
|
|
@@ -430,7 +440,7 @@ func (p *SecretsClient) findItem(ctx context.Context, name string) (onepassword.
|
|
|
var item onepassword.Item
|
|
var item onepassword.Item
|
|
|
var err error
|
|
var err error
|
|
|
|
|
|
|
|
- if strfmt.IsUUID(name) {
|
|
|
|
|
|
|
+ if isNativeItemID(name) {
|
|
|
item, err = p.client.Items().Get(ctx, p.vaultID, name)
|
|
item, err = p.client.Items().Get(ctx, p.vaultID, name)
|
|
|
metrics.ObserveAPICall(constants.ProviderOnePasswordSDK, constants.CallOnePasswordSDKItemsGet, err)
|
|
metrics.ObserveAPICall(constants.ProviderOnePasswordSDK, constants.CallOnePasswordSDKItemsGet, err)
|
|
|
if err != nil {
|
|
if err != nil {
|