Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Print all arguments passed to service #1746

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions cmd/google_cloud_ops_agent_diagnostics/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ func (s *service) Execute(args []string, r <-chan svc.ChangeRequest, changes cha

const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown
changes <- svc.Status{State: svc.StartPending}
if err := s.parseFlags(args); err != nil {

allArgs := append([]string{}, os.Args[1:]...)
igorpeshansky marked this conversation as resolved.
Show resolved Hide resolved
allArgs = append(allArgs, args[1:]...)
igorpeshansky marked this conversation as resolved.
Show resolved Hide resolved
if err := s.parseFlags(allArgs); err != nil {
s.log.Error(DiagnosticsEventID, fmt.Sprintf("failed to parse arguments: %v", err))
return false, ERROR_INVALID_PARAMETER
}
Expand Down Expand Up @@ -122,9 +125,5 @@ func (s *service) parseFlags(args []string) error {
s.log.Info(DiagnosticsEventID, fmt.Sprintf("args: %#v", args))
var fs flag.FlagSet
fs.StringVar(&s.userConf, "config", "", "path to the user specified agent config")
s.log.Info(DiagnosticsEventID, s.userConf)

allArgs := append([]string{}, os.Args[1:]...)
allArgs = append(allArgs, args[1:]...)
return fs.Parse(allArgs)
return fs.Parse(args)
}
10 changes: 5 additions & 5 deletions cmd/ops_agent_windows/run_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ func (s *service) Execute(args []string, r <-chan svc.ChangeRequest, changes cha
defer cancel()
const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown
changes <- svc.Status{State: svc.StartPending}
if err := s.parseFlags(args); err != nil {

allArgs := append([]string{}, os.Args[1:]...)
allArgs = append(allArgs, args[1:]...)
if err := s.parseFlags(allArgs); err != nil {
s.log.Error(EngineEventID, fmt.Sprintf("failed to parse arguments: %v", err))
// ERROR_INVALID_ARGUMENT
return false, 0x00000057
Expand Down Expand Up @@ -104,10 +107,7 @@ func (s *service) parseFlags(args []string) error {
var fs flag.FlagSet
fs.StringVar(&s.userConf, "in", "", "path to the user specified agent config")
fs.StringVar(&s.outDirectory, "out", "", "directory to write generated configuration files to")

allArgs := append([]string{}, os.Args[1:]...)
allArgs = append(allArgs, args[1:]...)
return fs.Parse(allArgs)
return fs.Parse(args)
}

func (s *service) checkForStandaloneAgents(unified *confgenerator.UnifiedConfig) error {
Expand Down
Loading