fix(agent-task/shared): add IsSessionID

Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
Babak K. Shandiz 2025-09-05 16:58:18 +01:00
parent a769175019
commit 5f6189be09
No known key found for this signature in database
GPG key ID: 9472CAEFF56C742E

View file

@ -1,10 +1,14 @@
package shared
import (
"regexp"
"github.com/cli/cli/v2/pkg/cmd/agent-task/capi"
"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}$`)
func CapiClientFunc(f *cmdutil.Factory) func() (capi.CapiClient, error) {
return func() (capi.CapiClient, error) {
cfg, err := f.Config()
@ -21,3 +25,7 @@ func CapiClientFunc(f *cmdutil.Factory) func() (capi.CapiClient, error) {
return capi.NewCAPIClient(httpClient, authCfg), nil
}
}
func IsSessionID(s string) bool {
return uuidRE.MatchString(s)
}