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

Get URL via Sonolark #141

Closed
johnSchnake opened this issue Apr 27, 2022 · 3 comments · Fixed by #164
Closed

Get URL via Sonolark #141

johnSchnake opened this issue Apr 27, 2022 · 3 comments · Fixed by #164
Labels
enhancement New feature or request sonolark

Comments

@johnSchnake
Copy link
Contributor

In my case I want to check a response code, but you may also want to just GET a resource too.

You can do this in python in general with the requests package but requires exception handling and importing a package. This should be easier on users so they can simply write:

resp, err = request.get(url)
@johnSchnake johnSchnake added enhancement New feature or request sonolark labels Apr 27, 2022
@johnSchnake
Copy link
Contributor Author

@johnSchnake
Copy link
Contributor Author

That package seems like it would do what we need; it also would be the first case where we are pulling in another starlark module that uses "go.starlark.net/starlark" whereas ours now uses the k14s types, so we'll need to make a wrapper at some level to translate the types.

Once we do that we'd be ready to repeat for other libs. The question would be do we want to translate to the k14s ones or vice versa? I think at first we can translate to k14s since thats less work (since we use that type currently) but if we find we keep pulling in more libraries then we can consider switching.

@johnSchnake
Copy link
Contributor Author

I'm going to try and take this on now. Right now working on this but the main problem is that the repo above uses the default starlark go but we use the ytt fork.

When importing it, I was hoping I could use the go.mod replace directive to tell it to use the ytt starlark library (and my IDE actually likes this OK) but the other go tools for build/tidy wont work. This is a known issue golang/go#26904 and may be resolved in go 1.19

Going to have to think how to work around this. We may need to manually copy the code and edit the import paths.

johnSchnake added a commit that referenced this issue Jul 5, 2022
 - Incorporates a new library for http calls
 - Library uses core sonolark instead of ytt sonolark types
so a new set of types/functions made to wrap them appropriately.

 - Consider extracting out these types into their own repo in the
future since it would be of benefit to other starlark/ytt users

Fixes #141

Signed-off-by: John Schnake <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sonolark
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant