Can a plugin's CasC config model be different to its Web UI config model?

12 views
Skip to first unread message

Chris Kilding

unread,
Feb 11, 2020, 11:36:35 AM2/11/20
to jenkin...@googlegroups.com
Hello,

I'm adding an optional list property to a plugin's configuration. This is a particularly tricky kind of property, as it results in lots of nesting in the config data model to make the Web UI's /configure page work. I would like to present a simpler data model to CasC without the nesting.

Are the config data models allowed to vary between CasC and Web UI? If so, how would we achieve this?

Chris

---------------------------------

More information...

## Class structure

class PluginConfiguration {
private Roles roles;

// misc other properties
}

class Roles {
private List<ARN> arns;
}

class ARN {
private String value;
}


## Jelly templates

PluginConfiguration/config.jelly:
<j:jelly....>
<f:optionalProperty field="roles" title="Roles" />
</j:jelly>

Roles/config.jelly:
<j:jelly....>
<f:repeatableProperty field="arns" />
</j:jelly>

ARN/config.jelly:
<j:jelly....>
<f:entry>
<f:textbox field="value" />
</f:entry>
</j:jelly>


## Current CasC model (with unwanted nesting)

unclassified:
myPlugin:
roles:
arns:
- value: arn:aws:iam::111111111111:role/foo-role
- value: arn:aws:iam::222222222222:role/bar-role


## Desired CasC model

unclassified:
myPlugin:
roles:
- arn:aws:iam::111111111111:role/foo-role
- arn:aws:iam::222222222222:role/bar-role

---------------------------------

Jesse Glick

unread,
Feb 11, 2020, 11:54:19 AM2/11/20
to Jenkins Dev
The `structs` API defines a `CustomDescribableModel` for this sort of
thing, used for example by Pipeline. However `configuration-as-code`
has its own incompatible model. I think you can implement either
`RootElementConfigurator` or `Configurable`.

Chris Kilding

unread,
Feb 12, 2020, 12:36:43 PM2/12/20
to jenkin...@googlegroups.com
Thanks Jesse, the solution was indeed to implement a custom RootElementConfigurator in the plugin. (And then to do the translation between the desired CasC config model and the traditional Web form config model in the describe() method.)

Chris

> On 11 Feb 2020, at 16:54, Jesse Glick <jgl...@cloudbees.com> wrote:
>
> The `structs` API defines a `CustomDescribableModel` for this sort of
> thing, used for example by Pipeline. However `configuration-as-code`
> has its own incompatible model. I think you can implement either
> `RootElementConfigurator` or `Configurable`.
>
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0_EmQR26s7frpwRd3dPL6x0y9uA4Ch82_P3mcwuZ%2BD2A%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages