refactor(agent-task/shared): extract uuid pattern

Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
Babak K. Shandiz 2025-09-10 19:07:03 +01:00
parent 6b872923ea
commit b079ea82e5
No known key found for this signature in database
GPG key ID: 9472CAEFF56C742E

View file

@ -2,6 +2,7 @@ package shared
import (
"errors"
"fmt"
"regexp"
"github.com/cli/cli/v2/pkg/cmd/agent-task/capi"
@ -9,8 +10,10 @@ import (
"github.com/cli/cli/v2/pkg/cmdutil"
)
var uuidRE = regexp.MustCompile(`^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`)
var agentSessionsPathRE = regexp.MustCompile(`^/agent-sessions/([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})$`)
const uuidPattern = `[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}`
var uuidRE = regexp.MustCompile(fmt.Sprintf("^%s$", uuidPattern))
var agentSessionsPathRE = regexp.MustCompile(fmt.Sprintf("^/agent-sessions/(%s)$", uuidPattern))
func CapiClientFunc(f *cmdutil.Factory) func() (capi.CapiClient, error) {
return func() (capi.CapiClient, error) {