osbuild2: support for unit-dropins option in org.osbuild.systemd
Add support for the newly added `unit-dropins` option in the `org.osbuild.systemd` osbuild stage [1]. The stage allows one to create `.service` unit files drop-in configuration files under `/usr/lib/systemd/system/`. Add unit test cases for the added functionality. [1] https://github.com/osbuild/osbuild/pull/664 Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
20e1cfeba4
commit
29ade764ce
2 changed files with 37 additions and 0 deletions
|
|
@ -410,6 +410,26 @@ func TestStage_UnmarshalJSON(t *testing.T) {
|
|||
data: []byte(`{"type":"org.osbuild.systemd","options":{"enabled_services":["foo.service"]}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "systemd-unit-dropins",
|
||||
fields: fields{
|
||||
Type: "org.osbuild.systemd",
|
||||
Options: &SystemdStageOptions{
|
||||
UnitDropins: map[string]SystemdServiceUnitDropins{
|
||||
"nm-cloud-setup.service": {
|
||||
"10-rh-enable-for-ec2.conf": {
|
||||
Service: &SystemdUnitServiceSection{
|
||||
Environment: "NM_CLOUD_SETUP_EC2=yes",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
data: []byte(`{"type":"org.osbuild.systemd","options":{"unit_dropins":{"nm-cloud-setup.service":{"10-rh-enable-for-ec2.conf":{"Service":{"Environment":"NM_CLOUD_SETUP_EC2=yes"}}}}}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "systemd-logind",
|
||||
fields: fields{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ type SystemdStageOptions struct {
|
|||
EnabledServices []string `json:"enabled_services,omitempty"`
|
||||
DisabledServices []string `json:"disabled_services,omitempty"`
|
||||
DefaultTarget string `json:"default_target,omitempty"`
|
||||
|
||||
// For now we support only .service drop-ins, but this may change in the future
|
||||
UnitDropins map[string]SystemdServiceUnitDropins `json:"unit_dropins,omitempty"`
|
||||
}
|
||||
|
||||
func (SystemdStageOptions) isStageOptions() {}
|
||||
|
|
@ -14,3 +17,17 @@ func NewSystemdStage(options *SystemdStageOptions) *Stage {
|
|||
Options: options,
|
||||
}
|
||||
}
|
||||
|
||||
// Drop-in configurations for a '.service' unit
|
||||
type SystemdServiceUnitDropins map[string]SystemdServiceUnitDropin
|
||||
|
||||
// Drop-in configuration for a '.service' unit
|
||||
type SystemdServiceUnitDropin struct {
|
||||
Service *SystemdUnitServiceSection `json:"Service,omitempty"`
|
||||
}
|
||||
|
||||
// 'Service' configuration section of a unit file
|
||||
type SystemdUnitServiceSection struct {
|
||||
// Sets environment variables for executed process
|
||||
Environment string `json:"Environment,omitempty"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue