Skip to content

Comments

Implement Service Checks For Windows#1017

Open
cthiel42 wants to merge 12 commits intogoss-org:masterfrom
cthiel42:windows_updates
Open

Implement Service Checks For Windows#1017
cthiel42 wants to merge 12 commits intogoss-org:masterfrom
cthiel42:windows_updates

Conversation

@cthiel42
Copy link

Checklist
  • make test-all (UNIX) passes. CI will also test this
  • unit and/or integration tests are included (if applicable)
  • documentation is changed or added (if applicable)

Description of change

I noticed some of the functionality for Windows wasn't implemented when I was using Goss with Windows a few months ago and I'd like to implement some of it, starting with services.

I tried to keep the initial changes here simple to see what you were looking for. For instance, services and processes are set up a little different than the others, so there would need to be some small refactoring if you wanted the windows service file to only be compiled into the windows build. I have an idea about how it could be accomplished somewhat cleanly, but wanted to get your take on whether it was worth it or not first. Same goes for integration tests. There was one test already in there, let me know if you wanted more and what you want them to cover.

@cthiel42 cthiel42 requested a review from aelsabbahy as a code owner January 28, 2025 01:30
Copy link
Collaborator

@petemounce petemounce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cthiel42 thanks very much for your contribution, and apologies for latency on review. This looks broadly good to me. I think ideally it'd be conditionally compiled so it's only present within the Windows binary to follow the pattern the other OS-specific support established.

re: my suggestions - please consider them my own in-memory suggestions for changes as opposed to relying on them to be syntactically / semantically correct. I made them inline during the review, not via an editor.

@aelsabbahy any comments?

@cthiel42
Copy link
Author

@petemounce Thanks for the review. I'll take a look over the next few days and push some changes for your comments.

@cthiel42
Copy link
Author

@petemounce I pushed up some changes. I switched the powershell calls to be through a helper function. I removed the comparison operator from the powershell commands and put them in the code (thanks for that suggestion, it looks a lot cleaner to me). Lastly, the windows service file is now not included in linux builds.

On that last item, I accomplished that by stubbing out the call to NewServiceWindows. That's a functioning way for the linux builds to run with that call in there. Another way would be to take system.go and split it into system_linux.go and system_windows.go. Let me know your thoughts on that.

Copy link
Collaborator

@petemounce petemounce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cthiel42 thanks very much for your increment, and apologies again for latency. Couple more suggestions.

I see I now have an Approve workflows to run button, so I've blithely pressed that and can see GHA has done its thing. Not sure if that button is needed each time; will see. Still no Travis, though; I lack access to address that.

I'd be cool with this merging once CI is run and green. @ripienaar / @aelsabbahy, any thoughts?

func NewCommandForWindowsPowershell(name string, arg ...string) *Command {
//fmt.Println(arg)
command := new(Command)
command.name = "powershell"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not this PR, but I gather that powershell-core's binary is pwsh.

Is there a way this choice might be later threaded through without a breaking change? I guess it would be a property on the service like powershell-binary, defaulting to powershell...?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you thinking of using pwsh if its available, and falling back to powershell if its not available?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I was thinking of this being left hard-coded to powershell and then (later in a follow-up) providing the ability to a test-author to override that with (something like) powershell_binary: pwsh in the test YAML definition. If that test-attribute is omitted, the default no-value choice would be powershell as in this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked too much into this, but I think as long as we can get the config to be accessible within this method, we could do that.

@petemounce
Copy link
Collaborator

@cthiel42 would you mind addressing https://github.com/goss-org/goss/actions/runs/21811022610/job/63155554726?pr=1017#step:4:34, which ought to just be a go fmt to make it progress?

@cthiel42
Copy link
Author

@cthiel42 would you mind addressing https://github.com/goss-org/goss/actions/runs/21811022610/job/63155554726?pr=1017#step:4:34, which ought to just be a go fmt to make it progress?

@petemounce This should hopefully be resolved now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants