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

Add daemon mode flag #161

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add daemon mode flag #161

wants to merge 7 commits into from

Conversation

faisal-memon
Copy link
Collaborator

@faisal-memon faisal-memon commented May 21, 2024

  • Add a daemon_mode configurable to toggle running spiffe-helper as a daemon. When daemon mode is disabled x509 and/or jwts are downloaded and spiffe-helper exits.
  • Add a daemon-mode cli flag to override config file setting and disable daemon mode.

configFile := flag.String("config", "helper.conf", "<configFile> Configuration file path")
exitWhenReady := flag.Bool("exitWhenReady", false, "Exit once the requested objects are retrieved")
disableDaemonMode := flag.Bool("disable_daemon_mode", false, "Exit once the requested objects are retrieved")
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the config daemon_mode, not disable_daemon_mode?

Copy link
Collaborator Author

@faisal-memon faisal-memon Jul 2, 2024

Choose a reason for hiding this comment

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

Changed to daemon-mode

Base automatically changed from fix-caps to main June 26, 2024 13:14
@faisal-memon faisal-memon force-pushed the daemon branch 2 times, most recently from 7bac373 to e6e9234 Compare July 1, 2024 22:49
@faisal-memon faisal-memon marked this pull request as ready for review July 2, 2024 00:21
@faisal-memon faisal-memon marked this pull request as draft July 2, 2024 01:20
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
@faisal-memon faisal-memon marked this pull request as ready for review July 2, 2024 22:31
Comment on lines +52 to +54
configFile := flag.String("config", "helper.conf", "<configFile> Configuration file path")
daemonModeFlag := flag.Bool(daemonModeFlagName, true, "Exit once the requested objects are retrieved")
flag.Parse()
Copy link
Collaborator

Choose a reason for hiding this comment

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

why to parse here? generally it is expected than flags are parsed in main so it is easy to found,
is it for testing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i can move back to main and have duplicate for tests if you think thats better.

return errors.New("at least one of the sets ('svid_file_name', 'svid_key_file_name', 'svid_bundle_file_name'), 'jwt_svids', or 'jwt_bundle_file_name' must be fully specified")
}

if x509EmptyCount != 0 && x509EmptyCount != 3 {
return errors.New("all or none of 'svid_file_name', 'svid_key_file_name', 'svid_bundle_file_name' must be specified")
if isFlagPassed(daemonModeFlagName) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you unify daemonModeFlag to a single value?
it must be calculated before getting here, so we can just set the value we get

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can move to ParseConfig(). Is that what you're thinking?

cmd/spiffe-helper/main.go Outdated Show resolved Hide resolved
cmd/spiffe-helper/main.go Outdated Show resolved Hide resolved
faisal-memon and others added 2 commits July 3, 2024 16:40
Signed-off-by: Faisal Memon <fymemon@yahoo.com>

Co-authored-by: Marcos Yacob <marcos.yacob@hpe.com>
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
Co-authored-by: Marcos Yacob <marcos.yacob@hpe.com>
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
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.

None yet

3 participants