Search in sources :

Example 1 with GlobalConfigurationCategoryConfigurator

use of io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator in project configuration-as-code-plugin by jenkinsci.

the class RootElementConfigurator method all.

static List<RootElementConfigurator> all() {
    final Jenkins jenkins = Jenkins.get();
    List<RootElementConfigurator> configurators = new ArrayList<>(jenkins.getExtensionList(RootElementConfigurator.class));
    for (GlobalConfigurationCategory category : GlobalConfigurationCategory.all()) {
        configurators.add(new GlobalConfigurationCategoryConfigurator(category));
    }
    for (ManagementLink link : ManagementLink.all()) {
        final String name = link.getUrlName();
        final Descriptor descriptor = Jenkins.get().getDescriptor(name);
        if (descriptor != null)
            configurators.add(new DescriptorConfigurator(descriptor));
    }
    configurators.sort(Configurator.extensionOrdinalSort());
    return configurators;
}
Also used : Jenkins(jenkins.model.Jenkins) GlobalConfigurationCategoryConfigurator(io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator) ArrayList(java.util.ArrayList) ManagementLink(hudson.model.ManagementLink) DescriptorConfigurator(io.jenkins.plugins.casc.impl.configurators.DescriptorConfigurator) Descriptor(hudson.model.Descriptor) GlobalConfigurationCategory(jenkins.model.GlobalConfigurationCategory)

Example 2 with GlobalConfigurationCategoryConfigurator

use of io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator in project configuration-as-code-plugin by jenkinsci.

the class Util method getSecurityRoot.

/**
 * Gets the "security" root mapping.
 * <p>
 * Example usage:
 * <pre>{@code
 * ConfiguratorRegistry registry = ConfiguratorRegistry.get();
 * ConfigurationContext context = new ConfigurationContext(registry);
 * CNode configNode = getSecurityRoot(context).get("GlobalJobDslSecurityConfiguration");}</pre>
 *
 * @param context the configuration context
 * @return the "security" root mapping
 * @throws Exception something's not right...
 */
public static Mapping getSecurityRoot(ConfigurationContext context) throws Exception {
    GlobalConfigurationCategory.Security security = ExtensionList.lookup(GlobalConfigurationCategory.Security.class).get(0);
    GlobalConfigurationCategoryConfigurator securityConfigurator = new GlobalConfigurationCategoryConfigurator(security);
    return Objects.requireNonNull(securityConfigurator.describe(securityConfigurator.getTargetComponent(context), context)).asMapping();
}
Also used : GlobalConfigurationCategoryConfigurator(io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator) GlobalConfigurationCategory(jenkins.model.GlobalConfigurationCategory)

Example 3 with GlobalConfigurationCategoryConfigurator

use of io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator in project configuration-as-code-plugin by jenkinsci.

the class Util method getToolRoot.

/**
 * Gets the "tool" root mapping.
 * <p>
 * Example usage:
 * <pre>{@code
 * ConfiguratorRegistry registry = ConfiguratorRegistry.get();
 * ConfigurationContext context = new ConfigurationContext(registry);
 * CNode configNode = getToolRoot(context).get("git");}</pre>
 *
 * @param context the configuration context
 * @return the "tool" root mapping
 * @throws Exception something's not right...
 */
public static Mapping getToolRoot(ConfigurationContext context) throws Exception {
    ToolConfigurationCategory category = ExtensionList.lookup(ToolConfigurationCategory.class).get(0);
    GlobalConfigurationCategoryConfigurator configurator = new GlobalConfigurationCategoryConfigurator(category);
    return Objects.requireNonNull(configurator.describe(configurator.getTargetComponent(context), context)).asMapping();
}
Also used : GlobalConfigurationCategoryConfigurator(io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator) ToolConfigurationCategory(jenkins.tools.ToolConfigurationCategory)

Example 4 with GlobalConfigurationCategoryConfigurator

use of io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator in project configuration-as-code-plugin by jenkinsci.

the class Util method getUnclassifiedRoot.

/**
 * Gets the "unclassified" root mapping.
 * <p>
 * Example usage:
 * <pre>{@code
 * ConfiguratorRegistry registry = ConfiguratorRegistry.get();
 * ConfigurationContext context = new ConfigurationContext(registry);
 * CNode configNode = getUnclassifiedRoot(context).get("my-plugin-attribute");}</pre>
 *
 * @param context the configuration context
 * @return the "unclassified" root mapping
 * @throws Exception something's not right...
 */
public static Mapping getUnclassifiedRoot(ConfigurationContext context) throws Exception {
    GlobalConfigurationCategory.Unclassified unclassified = ExtensionList.lookup(GlobalConfigurationCategory.Unclassified.class).get(0);
    GlobalConfigurationCategoryConfigurator unclassifiedConfigurator = new GlobalConfigurationCategoryConfigurator(unclassified);
    return Objects.requireNonNull(unclassifiedConfigurator.describe(unclassifiedConfigurator.getTargetComponent(context), context)).asMapping();
}
Also used : GlobalConfigurationCategoryConfigurator(io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator) GlobalConfigurationCategory(jenkins.model.GlobalConfigurationCategory)

Aggregations

GlobalConfigurationCategoryConfigurator (io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator)4 GlobalConfigurationCategory (jenkins.model.GlobalConfigurationCategory)3 Descriptor (hudson.model.Descriptor)1 ManagementLink (hudson.model.ManagementLink)1 DescriptorConfigurator (io.jenkins.plugins.casc.impl.configurators.DescriptorConfigurator)1 ArrayList (java.util.ArrayList)1 Jenkins (jenkins.model.Jenkins)1 ToolConfigurationCategory (jenkins.tools.ToolConfigurationCategory)1