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-887) Add checks for read_only values being set or modified #54

Merged
merged 1 commit into from
Apr 4, 2018
Merged

(PDK-887) Add checks for read_only values being set or modified #54

merged 1 commit into from
Apr 4, 2018

Conversation

da-ar
Copy link

@da-ar da-ar commented Mar 29, 2018

No description provided.

@DavidS
Copy link
Contributor

DavidS commented Mar 29, 2018

david@davids:~/git/puppet-resource_api$ bundle exec puppet resource --modulepath spec/fixtures/modules/ test_validation 
test_validation { "bar": 
  ensure => 'present',
# prop => 3, # Read Only
}
test_validation { "foo": 
  ensure => 'present',
# prop => 2, # Read Only
}
david@davids:~/git/puppet-resource_api$ bundle exec puppet resource --modulepath spec/fixtures/modules/ test_validation bar param=3
test_validation { 'bar':
  ensure => 'present',
}
david@davids:~/git/puppet-resource_api$ bundle exec puppet resource --modulepath spec/fixtures/modules/ test_validation bar param=3 prop=2
test_validation { 'bar':
  ensure => 'present',
}
david@davids:~/git/puppet-resource_api$ bundle exec puppet resource --modulepath spec/fixtures/modules/ test_validation bar param=3 prop=1
test_validation { 'bar':
  ensure => 'present',
}
david@davids:~/git/puppet-resource_api$ 

The last command definitely should fail (tries to modify prop from 2 to 1). I'm not 100% sure, but the second to last command (setting prop to its current value) should likely fail too: it is not even valid to try to set a read_only value.

@DavidS
Copy link
Contributor

DavidS commented Mar 29, 2018

e.g. Azure has https://github.com/puppetlabs/puppetlabs-azure/blob/b30e68b7da9c3c4cb60a303b2e3d3c675579784f/lib/puppet_x/puppetlabs/azure/property/read_only.rb#L5 which already fails on validation. that is, every time someone tries to set any value.

@DavidS DavidS merged commit 22ff140 into puppetlabs:master Apr 4, 2018
@da-ar da-ar deleted the read_only_validation branch April 6, 2018 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants