Skip to content

Commit

Permalink
Changed yaml data size to integer
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Abarca committed Jul 17, 2024
1 parent 473f361 commit 26b8fa6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public static String[] getValues() {
.build();

Property YAML_DATA_SIZE_PROP = PropertyBuilder.builder()
.string(ANSIBLE_YAML_DATA_SIZE)
.integer(ANSIBLE_YAML_DATA_SIZE)
.required(false)
.title("Inventory Yaml Data Size")
.description("Set the MB size (Default value is 10MB)"+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.rundeck.plugins.ansible.ansible.AnsibleInventoryList;
import com.rundeck.plugins.ansible.ansible.AnsibleRunner;
import com.rundeck.plugins.ansible.ansible.InventoryList;
import com.rundeck.plugins.ansible.ansible.PropertyResolver;
import com.rundeck.plugins.ansible.util.VaultPrompt;
import org.rundeck.app.spi.Services;
import org.rundeck.storage.api.PathUtil;
Expand Down Expand Up @@ -143,6 +144,24 @@ private static String resolveProperty(
}
}

private static Integer resolveIntProperty(
final String attribute,
final Integer defaultValue,
final Properties configuration,
final Map<String, Map<String, String>> dataContext) throws ConfigurationException {
final String strValue = resolveProperty(attribute, null, configuration, dataContext);
if (null != strValue) {
try {
return Integer.parseInt(strValue);
} catch (NumberFormatException e) {
throw new ConfigurationException("Can't parse attribute :" + attribute +
", value: " + strValue +
" Expected Integer. : " + e.getMessage(), e);
}
}
return defaultValue;
}

private static Boolean skipVar(final String hostVar, final List<String> varList) {
for (final String specialVarString : varList) {
if (hostVar.startsWith(specialVarString)) return true;
Expand All @@ -168,9 +187,7 @@ public void configure(Properties configuration) throws ConfigurationException {
gatherFacts = "true".equals(resolveProperty(AnsibleDescribable.ANSIBLE_GATHER_FACTS,null,configuration,executionDataContext));
ignoreErrors = "true".equals(resolveProperty(AnsibleDescribable.ANSIBLE_IGNORE_ERRORS,null,configuration,executionDataContext));

yamlDataSize = getIntegerValue(
resolveProperty(AnsibleDescribable.ANSIBLE_YAML_DATA_SIZE,"10", configuration, executionDataContext),
AnsibleDescribable.ANSIBLE_YAML_DATA_SIZE);
yamlDataSize = resolveIntProperty(AnsibleDescribable.ANSIBLE_YAML_DATA_SIZE,10, configuration, executionDataContext);

limit = (String) resolveProperty(AnsibleDescribable.ANSIBLE_LIMIT,null,configuration,executionDataContext);
ignoreTagPrefix = (String) resolveProperty(AnsibleDescribable.ANSIBLE_IGNORE_TAGS,null,configuration,executionDataContext);
Expand Down

0 comments on commit 26b8fa6

Please sign in to comment.