Skip to content

Commit

Permalink
fix: use the provided name when it's not empty in JSON conversion. (#861
Browse files Browse the repository at this point in the history
)
  • Loading branch information
abeaumont authored Feb 16, 2022
1 parent 4a11f7d commit d1c4066
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/adhoc/server/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ import (
"github.com/pyroscope-io/pyroscope/pkg/structs/flamebearer"
)

func JSONToProfileV1(b []byte, _ string, _ int) (*flamebearer.FlamebearerProfile, error) {
func JSONToProfileV1(b []byte, name string, _ int) (*flamebearer.FlamebearerProfile, error) {
var profile flamebearer.FlamebearerProfile
if err := json.Unmarshal(b, &profile); err != nil {
return nil, fmt.Errorf("unable to unmarshall JSON: %w", err)
}
if err := profile.Validate(); err != nil {
return nil, fmt.Errorf("invalid profile: %w", err)
}
if name != "" {
profile.Metadata.Name = name
}
return &profile, nil
}

Expand Down

0 comments on commit d1c4066

Please sign in to comment.