Skip to content

(wip) use json, not pson, steal Bens work to make pup4 #1087

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

Closed
wants to merge 2 commits into from

Conversation

justinstoller
Copy link
Member

Needs tests and to double check the documentation / its generation.

Wanted to know if there were any concerns with the approach though.

FWIW, I first tried to overwrite the existing method but we have tests that invalid inputs cause the default given to be output instead of failing with a type error (which the newer functions would do if properly typed).

Alternatively, I could loosen the typing to allow more backwards compat but there'll still be some incompatibility between JSON <-> PSON. The content of the 4x functions was stolen from Ben's PR #1079 and slightly cleaned up.

@justinstoller justinstoller requested a review from a team as a code owner February 11, 2020 18:51
@justinstoller
Copy link
Member Author

fwiw, these are failing on lint checks not tests

Wanted to know if there were any concerns with the approach though.

I've heard at least someone express a preference for making this replace the existing method rather than deprecating the old and replacing it with a "stdlib::" namespaced one. I'm unclear if we should then remove the stricter type checking? Do others have thoughts on the approach?

@DavidS
Copy link
Contributor

DavidS commented Feb 21, 2020

Hi @justinstoller,

Depending on how much the behaviour changes, it might be a barrier to switching over. I'm not familiar enough with the pson/json differences to be able to make a judgement call on that. I would guess that most users of those functions are actually looking for JSON, not pson semantics, so it might be really not a big deal in this case.

With the changes in #1079 we're moving all non-deprecated functions to stdlib:: prefix. I haven't worked through all the issues there yet, but see the commit message on DavidS@25a2af2 for a up-to-date snapshot of where the project is at.

cc @binford2k

URI_WITH_NAME_PATTERN = %r{(http\://|https\://)(.*)@(.*)}

dispatch :default_impl do
param 'String', :path_or_uri
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use Stdlib::HTTP(s)Url here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It needs to be a URL or filepath that Ruby will accept. Maybe we could do something like:

dispatch :load_from_uri do
  param 'Variant[Stdlib::HttpsUrl, Stdlib::HttpUrl]', :url
  ...

dispatch :load_from_file do
  param 'Stdlib::Absolutepath', :path
  ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried something in d584063 I don't know if it's correct, still need to test it. But is it more what you were thinking?

@david22swan david22swan deleted the branch puppetlabs:master April 15, 2021 11:12
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.

4 participants