Hey everyone, I am working on data typing a class ...
# puppet
k
Hey everyone, I am working on data typing a class for managing .NET packages. First off this is my first time posting so please let me know if there is any context I am missing that would help. Currently I am trying to type my data to accept a SemVer but it does not seem to be able to convert the string from Hiera or even just using a default value on the param in the class. Here is my current (attempt) data struct:
Hash[Enum['core', 'sdk'], Array[SemVer], 0, 1] $pkg_details = { 'core' => ['10.0.1', '8.0.4'] }
Errors:
Copy code
Error: Evaluation Error: Error while evaluating a Function Call, Class[Test]:
  parameter 'pkg_details' entry 'core' index 0 expects a SemVer value, got String
  parameter 'pkg_details' entry 'core' index 1 expects a SemVer value, got String
The goal is to have Hiera store the data as such:
Copy code
profile::path_to::pkg_details:
  core:
    - '10.0.1'
    - '8.0.4'
I wanted to avoid having two params on the class since I would still need to add logic to not allow both installs on the node. So the purpose is to allow the key in
$pkg_details
act as a selector since I do not want both on the same server anyways. Then an array of versions that are wanted to be installed. We previously had two different classes for SDK and CORE bundle but wanted to test out a single class since the automation was already pretty similar. I am not too concerned if the data type becomes unwieldy since I can just alias it if needed. Also, I can get this to work if I convert the strings to SemVer in the class itself with:
Copy code
$semvers = $pkg_details[$dotnet_type].map | String $version_str | {
    SemVer.new($version_str)
  }
We have wanted to try to get better at versioning and part of that was testing with this data struct so if anyone has any ideas that would be awesome. Thanks!
👋 1