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

Userdata in getHandlerPairs()? #177

Closed
ihamburglar opened this issue Jun 11, 2022 · 1 comment
Closed

Userdata in getHandlerPairs()? #177

ihamburglar opened this issue Jun 11, 2022 · 1 comment

Comments

@ihamburglar
Copy link
Contributor

Does userdata need to be registered, in this function?

func getHandlerPairs(cmd *cobra.Command, config cfg.Config) []handlerPair {
// always register these paths
handlerPairs := []handlerPair{
{path: "/", handler: handlers.ListRoutesHandler},
{path: "/latest", handler: handlers.ListRoutesHandler},
{path: static.ServicePath, handler: handlers.ListRoutesHandler},
{path: dynamic.ServicePath, handler: handlers.ListRoutesHandler},
}

It seems like things work without it, what does this function do exactly? Is it actually needed?

@ihamburglar ihamburglar added the bug Something isn't working label Jun 11, 2022
@brycahta
Copy link
Contributor

Does userdata need to be registered, in this function?

No, per my comment on your PR: #171 (comment)

what does this function do exactly? Is it actually needed?

Yup it's needed. It associates a path with handler during startup depending on which subcommand is used to start AEMM. For example, if users use events subcommand, aemm events <args>, then IMDS paths (and handlers) involving spot should not be available-- that logic is handled in getHandlerPairs.

Addressing this specific block:

	handlerPairs := []handlerPair{
		{path: "/", handler: handlers.ListRoutesHandler},
		{path: "/latest", handler: handlers.ListRoutesHandler},
		{path: static.ServicePath, handler: handlers.ListRoutesHandler},
		{path: dynamic.ServicePath, handler: handlers.ListRoutesHandler},
	}

handlerPairs is saying each of these paths have a List Handler, which is a handler that lists available routes for a given path. userdata does NOT have a List Handler because userdata has no routes itself just the userdata value. Ex:

  • /latest needs to register a List Handler because hitting this path should list the following routes:

    • dynamic
    • meta-data
    • user-data
  • /latest/dynamic needs to register a List Handler because hitting this path should list the following routes:

    • fws/instance-monitoring
    • instance-identity/document
    • instance-identity/pkcs7
    • instance-identity/signature
  • /latest/user-data does not have a List Handler because hitting this path will return user-data value:

    • MTIzNCxqb2huLHJlYm9vdCx0cnVlCg==

@brycahta brycahta removed the bug Something isn't working label Jun 14, 2022
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

No branches or pull requests

2 participants