Skip to content

Commit

Permalink
fix(profiler): relax service name regexp to allow service names start…
Browse files Browse the repository at this point in the history
…ing with numbers to be used (#5994)
  • Loading branch information
nolanmar511 committed May 4, 2022
1 parent cebbd5e commit a1d8ac9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion profiler/profiler.go
Expand Up @@ -80,7 +80,7 @@ var (
sleep = gax.Sleep
dialGRPC = gtransport.DialPool
onGCE = gcemd.OnGCE
serviceRegexp = regexp.MustCompile(`^[a-z]([-a-z0-9_.]{0,253}[a-z0-9])?$`)
serviceRegexp = regexp.MustCompile(`^[a-z0-9]([-a-z0-9_.]{0,253}[a-z0-9])?$`)

// For testing only.
// When the profiling loop has exited without error and this channel is
Expand Down
18 changes: 14 additions & 4 deletions profiler/profiler_test.go
Expand Up @@ -504,9 +504,19 @@ func TestInitializeConfig(t *testing.T) {
envProjectID bool
}{
{
"accepts service name",
Config{Service: testService},
Config{Service: testService, ProjectID: testGCEProjectID, Zone: testZone, Instance: testInstance},
"accepts service name starting with letter",
Config{Service: "test-service-1"},
Config{Service: "test-service-1", ProjectID: testGCEProjectID, Zone: testZone, Instance: testInstance},
"",
false,
false,
true,
false,
},
{
"accepts service name starting number",
Config{Service: "12service"},
Config{Service: "12service", ProjectID: testGCEProjectID, Zone: testZone, Instance: testInstance},
"",
false,
false,
Expand Down Expand Up @@ -537,7 +547,7 @@ func TestInitializeConfig(t *testing.T) {
"requires valid service name",
Config{Service: "Service"},
Config{Service: "Service"},
"service name \"Service\" does not match regular expression ^[a-z]([-a-z0-9_.]{0,253}[a-z0-9])?$",
"service name \"Service\" does not match regular expression ^[a-z0-9]([-a-z0-9_.]{0,253}[a-z0-9])?$",
false,
false,
true,
Expand Down

0 comments on commit a1d8ac9

Please sign in to comment.