diff --git a/.chloggen/try_windows_sshcheckreceiver.yaml b/.chloggen/try_windows_sshcheckreceiver.yaml new file mode 100755 index 000000000000..f110b110b182 --- /dev/null +++ b/.chloggen/try_windows_sshcheckreceiver.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: sshcheckreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add support for running this receiver on Windows + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [30650] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user, api] diff --git a/receiver/sshcheckreceiver/README.md b/receiver/sshcheckreceiver/README.md index b994bdc5519c..8924e63e6114 100644 --- a/receiver/sshcheckreceiver/README.md +++ b/receiver/sshcheckreceiver/README.md @@ -4,7 +4,6 @@ | Status | | | ------------- |-----------| | Stability | [alpha]: metrics | -| Unsupported Platforms | windows | | Distributions | [contrib] | | Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Fsshcheck%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fsshcheck) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Fsshcheck%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fsshcheck) | | [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@nslaughter](https://www.github.com/nslaughter), [@codeboten](https://www.github.com/codeboten) | diff --git a/receiver/sshcheckreceiver/config.go b/receiver/sshcheckreceiver/config.go index d1a14714aa4f..cdc5e51e80e3 100644 --- a/receiver/sshcheckreceiver/config.go +++ b/receiver/sshcheckreceiver/config.go @@ -22,8 +22,7 @@ var ( errMissingUsername = errors.New(`"username" not specified in config`) errMissingPasswordAndKeyFile = errors.New(`either "password" or "key_file" is required`) - errConfigNotSSHCheck = errors.New("config was not a SSH check receiver config") - errWindowsUnsupported = errors.New(metadata.Type.String() + " is unsupported on Windows.") + errConfigNotSSHCheck = errors.New("config was not a SSH check receiver config") ) type Config struct { diff --git a/receiver/sshcheckreceiver/factory.go b/receiver/sshcheckreceiver/factory.go index e1b6dfd07eaf..18624285b2e2 100644 --- a/receiver/sshcheckreceiver/factory.go +++ b/receiver/sshcheckreceiver/factory.go @@ -38,10 +38,6 @@ func createDefaultConfig() component.Config { } func createMetricsReceiver(_ context.Context, params receiver.CreateSettings, rConf component.Config, consumer consumer.Metrics) (receiver.Metrics, error) { - // return error if sshcheckreceiver on Windows - if !supportedOS() { - return nil, errWindowsUnsupported - } cfg, ok := rConf.(*Config) if !ok { diff --git a/receiver/sshcheckreceiver/factory_test.go b/receiver/sshcheckreceiver/factory_test.go index 2dc748fc9529..13351affe4b8 100644 --- a/receiver/sshcheckreceiver/factory_test.go +++ b/receiver/sshcheckreceiver/factory_test.go @@ -19,9 +19,6 @@ import ( ) func TestNewFactory(t *testing.T) { - if !supportedOS() { - t.Skip("Skip tests if not running on one of: [linux, darwin, freebsd, openbsd]") - } t.Parallel() testCases := []struct { desc string @@ -85,17 +82,3 @@ func TestNewFactory(t *testing.T) { t.Run(tc.desc, tc.testFunc) } } - -func TestWindowsReceiverUnsupported(t *testing.T) { - if supportedOS() { - t.Skip("Skip test if not running windows.") - } - factory := NewFactory() - _, err := factory.CreateMetricsReceiver( - context.Background(), - receivertest.NewNopCreateSettings(), - nil, - consumertest.NewNop(), - ) - require.ErrorIs(t, err, errWindowsUnsupported) -} diff --git a/receiver/sshcheckreceiver/generated_component_test.go b/receiver/sshcheckreceiver/generated_component_test.go index feb95e51a4f8..ef342b68c184 100644 --- a/receiver/sshcheckreceiver/generated_component_test.go +++ b/receiver/sshcheckreceiver/generated_component_test.go @@ -1,5 +1,4 @@ // Code generated by mdatagen. DO NOT EDIT. -//go:build !windows package sshcheckreceiver diff --git a/receiver/sshcheckreceiver/metadata.yaml b/receiver/sshcheckreceiver/metadata.yaml index 7b7277d51126..3b956cec445f 100644 --- a/receiver/sshcheckreceiver/metadata.yaml +++ b/receiver/sshcheckreceiver/metadata.yaml @@ -8,7 +8,6 @@ status: distributions: [contrib] codeowners: active: [nslaughter, codeboten] - unsupported_platforms: [windows] resource_attributes: ssh.endpoint: diff --git a/receiver/sshcheckreceiver/scraper.go b/receiver/sshcheckreceiver/scraper.go index b4951c197006..e15c2c019053 100644 --- a/receiver/sshcheckreceiver/scraper.go +++ b/receiver/sshcheckreceiver/scraper.go @@ -6,7 +6,6 @@ package sshcheckreceiver // import "github.com/open-telemetry/opentelemetry-coll import ( "context" "errors" - "runtime" "time" "go.opentelemetry.io/collector/component" @@ -30,9 +29,6 @@ type sshcheckScraper struct { // start starts the scraper by creating a new SSH Client on the scraper func (s *sshcheckScraper) start(_ context.Context, host component.Host) error { var err error - if !supportedOS() { - return errWindowsUnsupported - } s.Client, err = s.Config.ToClient(host, s.settings) return err } @@ -136,7 +132,3 @@ func newScraper(conf *Config, settings receiver.CreateSettings) *sshcheckScraper mb: metadata.NewMetricsBuilder(conf.MetricsBuilderConfig, settings), } } - -func supportedOS() bool { - return !(runtime.GOOS == "windows") -} diff --git a/receiver/sshcheckreceiver/scraper_test.go b/receiver/sshcheckreceiver/scraper_test.go index a9e736abea69..491d1e3f3492 100644 --- a/receiver/sshcheckreceiver/scraper_test.go +++ b/receiver/sshcheckreceiver/scraper_test.go @@ -137,10 +137,6 @@ func handleChannels(chans <-chan ssh.NewChannel) { } func TestScraper(t *testing.T) { - if !supportedOS() { - t.Skip("Skip tests if not running on one of: [linux, darwin, freebsd, openbsd]") - } - s, err := newSSHServer("tcp", "127.0.0.1:0") require.NoError(t, err) endpoint := s.runSSHServer(t) @@ -212,9 +208,6 @@ func TestScraper(t *testing.T) { } func TestScraperPropagatesResourceAttributes(t *testing.T) { - if !supportedOS() { - t.Skip("Skip tests if not running on one of: [linux, darwin, freebsd, openbsd]") - } s, err := newSSHServer("tcp", "127.0.0.1:0") require.NoError(t, err) endpoint := s.runSSHServer(t) @@ -251,9 +244,6 @@ func TestScraperPropagatesResourceAttributes(t *testing.T) { } func TestScraperDoesNotErrForSSHErr(t *testing.T) { - if !supportedOS() { - t.Skip("Skip tests if not running on one of: [linux, darwin, freebsd, openbsd]") - } s, err := newSSHServer("tcp", "127.0.0.1:0") require.NoError(t, err) endpoint := s.runSSHServer(t) @@ -278,9 +268,6 @@ func TestScraperDoesNotErrForSSHErr(t *testing.T) { } func TestTimeout(t *testing.T) { - if !supportedOS() { - t.Skip("Skip tests if not running on one of: [linux, darwin, freebsd, openbsd]") - } testCases := []struct { name string deadline time.Time @@ -318,10 +305,6 @@ func TestCancellation(t *testing.T) { settings := receivertest.NewNopCreateSettings() scrpr := newScraper(cfg, settings) - if !supportedOS() { - require.Error(t, scrpr.start(context.Background(), componenttest.NewNopHost()), "should err starting scraper") - return - } require.NoError(t, scrpr.start(context.Background(), componenttest.NewNopHost()), "failed starting scraper") ctx, cancel := context.WithCancel(context.Background())