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

(PDK-1107) Add pdk config get CLI command #715

Merged
merged 1 commit into from
Aug 21, 2019

Conversation

glennsarti
Copy link
Contributor

@glennsarti glennsarti commented Jul 29, 2019


Previously there was no way to display what the current configuration the PDK
was using. This commit adds a pdk config command, with a single get
sub-command.

This commit also adds the ability to filter the settings either by a specific
name or setting treename.

This commit also adds tests for the new resolve method in the Namespace object.

@coveralls
Copy link

coveralls commented Jul 29, 2019

Coverage Status

Coverage decreased (-0.3%) to 91.802% when pulling 5cb9b92 on glennsarti:add-config-feature-flags into 70d19e0 on puppetlabs:master.

@glennsarti
Copy link
Contributor Author

Looked at adding json formatter but it's waaay outside the scope of this PR and should not stop merging of this PR. Punting for now

@glennsarti glennsarti force-pushed the add-config-feature-flags branch 2 times, most recently from b59226b to c8ee105 Compare July 30, 2019 05:47
@glennsarti
Copy link
Contributor Author

glennsarti commented Jul 30, 2019

Not sure about this though:

https://github.com/puppetlabs/pdk/pull/715/files#diff-583f8159ac861abd5736f8e9c611c396R35

If the user specifies a non-existant setting, should it exit with non-zero?


Update : Yes it should be non-zero


Update : Now exits with 1

@glennsarti glennsarti changed the title {WIP}(PDK-1107) Add pdk config get CLI command (PDK-1107) Add pdk config get CLI command Jul 30, 2019
@glennsarti glennsarti requested review from rodjek and scotje July 30, 2019 05:48
@glennsarti glennsarti force-pushed the add-config-feature-flags branch 3 times, most recently from 4bc2cd6 to f613c8c Compare July 31, 2019 08:01
@glennsarti glennsarti added this to the August 2019 milestone Jul 31, 2019
Copy link
Contributor

@scotje scotje left a comment

Choose a reason for hiding this comment

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

This is looking good so far!

I do notice a couple differences in the base output format from the RFC in this implementation*, but I'm not sure if the plan is to refine that in future PRs. I'm definitely +1 to implementing things incrementally.

* For example, requesting the value of a leaf node:

RFC:

If <key> is a leaf node of the configuration graph, this command will return the raw value

$ pdk config get user.analytics.user-id
4489233c-e1ff-4761-9ee0-5c85b713da67

Implementation:

$ pdk config get user.analytics.user-id
user.analytics.user-id=4489233c-e1ff-4761-9ee0-5c85b713da67

I'm also fine with revising what is described in the RFC if we want to do that deliberately.

lib/pdk/config/namespace.rb Outdated Show resolved Hide resolved
lib/pdk/cli/config.rb Outdated Show resolved Hide resolved
spec/acceptance/config_get_spec.rb Outdated Show resolved Hide resolved
@glennsarti
Copy link
Contributor Author

If is a leaf node of the configuration graph, this command will return the raw value

As there is no formal spec on what settings should appear where (i.e. what's a leaf vs, what's a tree) it get's tricky. So instead I guess. If user specified x.y.z and only one setting with the name x.y.z is returned then, it assumes it's a leaf.

@glennsarti
Copy link
Contributor Author

@scotje I've ticketted changes to the RFC to match this PR at https://github.com/puppetlabs/pdk-planning/issues/40

Once that is issue is approved and merged, this PR can be merged.

@scotje
Copy link
Contributor

scotje commented Aug 3, 2019

As there is no formal spec on what settings should appear where (i.e. what's a leaf vs, what's a tree) it get's tricky. So instead I guess. If user specified x.y.z and only one setting with the name x.y.z is returned then, it assumes it's a leaf.

Yeah, we had talked about having a config schema we could validate against to make this easier to determine as well. This section of the RFC was a initial draft of allowed keys and values at the various layers: https://github.com/puppetlabs/pdk-planning/blob/master/RFCs/0002-add-pdk-config.md#proposed-configuration-keys but that will certainly be expanded/revised as we go along. I do think we should do some sort of checking against a schema to make sure people don't typo a setting key and then wonder why it's not working.

@glennsarti
Copy link
Contributor Author

I did see that. Probably best to introduce a schema validator now actually

@glennsarti
Copy link
Contributor Author

Back to WIP for you!

@glennsarti glennsarti changed the title (PDK-1107) Add pdk config get CLI command {WIP}(PDK-1107) Add pdk config get CLI command Aug 5, 2019
@glennsarti
Copy link
Contributor Author

Blocked on #726 merge

@scotje scotje removed the needs RFC label Aug 13, 2019
@scotje
Copy link
Contributor

scotje commented Aug 13, 2019

RFC update has been merged

@glennsarti
Copy link
Contributor Author

glennsarti commented Aug 20, 2019

@scotje Regarding If <key> is a leaf node of the configuration graph, this command will return the raw value:

While I don't have a schema to work with, the tests show the current logic exhibits the behaviour the RFC sets out.

Logic:
https://github.com/puppetlabs/pdk/pull/715/files#diff-9ceca00b50a64c03ef57fc68b89dd70cR15-R19

Tests:
https://github.com/puppetlabs/pdk/pull/715/files#diff-583f8159ac861abd5736f8e9c611c396R15-R32

@glennsarti glennsarti removed the WIP label Aug 20, 2019
@glennsarti glennsarti changed the title {WIP}(PDK-1107) Add pdk config get CLI command (PDK-1107) Add pdk config get CLI command Aug 20, 2019
lib/pdk/cli/config/get.rb Outdated Show resolved Hide resolved
Previously there was no way to display what the current configuration the PDK
was using.  This commit adds a `pdk config` command, with a single `get`
sub-command.

This commit also adds the ability to filter the settings either by a specific
name or setting treename.

This commit also adds tests for the new resolve method in the Namespace object.
@glennsarti
Copy link
Contributor Author

CI Is green and approvals done. Merging.

@glennsarti glennsarti merged commit 7721e64 into puppetlabs:master Aug 21, 2019
@rodjek rodjek added the feature label Aug 29, 2019
@glennsarti glennsarti deleted the add-config-feature-flags branch August 30, 2019 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants