Skip to content

Commit

Permalink
Correctly map dragonfly value to DRAGONFLYBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi committed Apr 14, 2021
1 parent e9f085b commit f6c046e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
11 changes: 10 additions & 1 deletion processor/resourcedetectionprocessor/internal/system/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,17 @@ type systemMetadata interface {

type systemMetadataImpl struct{}

// goosToOSType maps a runtime.GOOS-like value to os.type style.
func goosToOSType(goos string) string {
switch goos {
case "dragonfly":
return "DRAGONFLYBSD"
}
return strings.ToUpper(goos)
}

func (*systemMetadataImpl) OSType() (string, error) {
return strings.ToUpper(runtime.GOOS), nil
return goosToOSType(runtime.GOOS), nil
}

func (*systemMetadataImpl) FQDN() (string, error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package system

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestGOOSToOsType(t *testing.T) {
assert.Equal(t, "DARWIN", goosToOSType("darwin"))
assert.Equal(t, "LINUX", goosToOSType("linux"))
assert.Equal(t, "WINDOWS", goosToOSType("windows"))
assert.Equal(t, "DRAGONFLYBSD", goosToOSType("dragonfly"))
}

0 comments on commit f6c046e

Please sign in to comment.