@@ -72,6 +72,7 @@ public class AnsibleResourceModelSource implements ResourceModelSource, ProxyRun
72
72
73
73
private String inventory ;
74
74
private boolean gatherFacts ;
75
+ private Integer yamlDataSize ;
75
76
private boolean ignoreErrors = false ;
76
77
private String limit ;
77
78
private String ignoreTagPrefix ;
@@ -167,6 +168,10 @@ public void configure(Properties configuration) throws ConfigurationException {
167
168
gatherFacts = "true" .equals (resolveProperty (AnsibleDescribable .ANSIBLE_GATHER_FACTS ,null ,configuration ,executionDataContext ));
168
169
ignoreErrors = "true" .equals (resolveProperty (AnsibleDescribable .ANSIBLE_IGNORE_ERRORS ,null ,configuration ,executionDataContext ));
169
170
171
+ yamlDataSize = getIntegerValue (
172
+ resolveProperty (AnsibleDescribable .ANSIBLE_YAML_DATA_SIZE ,"10" , configuration , executionDataContext ),
173
+ AnsibleDescribable .ANSIBLE_YAML_DATA_SIZE );
174
+
170
175
limit = (String ) resolveProperty (AnsibleDescribable .ANSIBLE_LIMIT ,null ,configuration ,executionDataContext );
171
176
ignoreTagPrefix = (String ) resolveProperty (AnsibleDescribable .ANSIBLE_IGNORE_TAGS ,null ,configuration ,executionDataContext );
172
177
@@ -670,9 +675,11 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx
670
675
*/
671
676
public void ansibleInventoryList (NodeSetImpl nodes , AnsibleRunner .AnsibleRunnerBuilder runnerBuilder ) throws ResourceModelSourceException {
672
677
678
+ int codePointLimit = yamlDataSize * 1024 * 1024 ;
679
+
673
680
LoaderOptions snakeOptions = new LoaderOptions ();
674
681
// max inventory file size allowed to 10mb
675
- snakeOptions .setCodePointLimit (10_485_760 );
682
+ snakeOptions .setCodePointLimit (codePointLimit );
676
683
Yaml yaml = new Yaml (new SafeConstructor (snakeOptions ));
677
684
678
685
String listResp = getNodesFromInventory (runnerBuilder );
@@ -812,4 +819,23 @@ public List<String> listSecretsPathResourceModel(Map<String, Object> configurati
812
819
813
820
}
814
821
822
+ /**
823
+ *
824
+ * @param value parameter from gui
825
+ * @param paramName parameter name
826
+ * @return an integer value
827
+ * @throws ConfigurationException
828
+ */
829
+ private Integer getIntegerValue (String value , String paramName ) throws ConfigurationException {
830
+ if (value == null ) {
831
+ throw new ConfigurationException ("Value cannot be null for parameter: " + paramName );
832
+ }
833
+
834
+ try {
835
+ return Integer .parseInt (value );
836
+ } catch (NumberFormatException e ) {
837
+ throw new ConfigurationException ("Error parsing " + paramName + " as integer: " + e .getMessage (), e );
838
+ }
839
+ }
840
+
815
841
}
0 commit comments