pipeline/stages: Add support for various stages defined in osbuild

This commit is contained in:
Ondřej Budai 2019-10-17 13:13:57 +02:00 committed by Tom Gundersen
parent ed2dd9829c
commit 86c47bc1d6
9 changed files with 146 additions and 0 deletions

View file

@ -0,0 +1,14 @@
package pipeline
type ChronyStageOptions struct {
Timeservers []string `json:"timeservers"`
}
func (ChronyStageOptions) isStageOptions() {}
func NewChronyStage(options *ChronyStageOptions) *Stage {
return &Stage{
Name: "org.osbuild.chrony",
Options: options,
}
}

View file

@ -0,0 +1,16 @@
package pipeline
type FirewallStageOptions struct {
Ports []string `json:"ports,omitempty"`
EnabledServices []string `json:"enabled_services,omitempty"`
DisabledServices []string `json:"disabled_services,omitempty"`
}
func (FirewallStageOptions) isStageOptions() {}
func NewFirewallStage(options *FirewallStageOptions) *Stage {
return &Stage{
Name: "org.osbuild.firewall",
Options: options,
}
}

View file

@ -0,0 +1,18 @@
package pipeline
type GroupsStageOptions struct {
Groups map[string]GroupsStageOptionsGroup `json:"groups"`
}
func (GroupsStageOptions) isStageOptions() {}
type GroupsStageOptionsGroup struct {
GID *string `json:"gid,omitempty"`
}
func NewGroupsStage(options *GroupsStageOptions) *Stage {
return &Stage{
Name: "org.osbuild.groups",
Options: options,
}
}

View file

@ -0,0 +1,14 @@
package pipeline
type HostnameStageOptions struct {
Hostname string `json:"hostname"`
}
func (HostnameStageOptions) isStageOptions() {}
func NewHostnameStage(options *HostnameStageOptions) *Stage {
return &Stage{
Name: "org.osbuild.hostname",
Options: options,
}
}

View file

@ -0,0 +1,14 @@
package pipeline
type KeymapStageOptions struct {
Keymap string `json:"keymap"`
}
func (KeymapStageOptions) isStageOptions() {}
func NewKeymapStage(options *KeymapStageOptions) *Stage {
return &Stage{
Name: "org.osbuild.keymap",
Options: options,
}
}

View file

@ -48,6 +48,22 @@ func (stage *Stage) UnmarshalJSON(data []byte) error {
options = new(LocaleStageOptions)
case "org.osbuild.selinux":
options = new(SELinuxStageOptions)
case "org.osbuild.hostname":
options = new(HostnameStageOptions)
case "org.osbuild.users":
options = new(UsersStageOptions)
case "org.osbuild.groups":
options = new(GroupsStageOptions)
case "org.osbuild.timezone":
options = new(TimezoneStageOptions)
case "org.osbuild.chrony":
options = new(ChronyStageOptions)
case "org.osbuild.keymap":
options = new(KeymapStageOptions)
case "org.osbuild.firewall":
options = new(FirewallStageOptions)
case "org.osbuild.systemd":
options = new(SystemdStageOptions)
default:
return errors.New("unexpected stage name")
}

View file

@ -0,0 +1,15 @@
package pipeline
type SystemdStageOptions struct {
EnabledServices []string `json:"enabled_services,omitempty"`
DisabledServices []string `json:"disabled_services,omitempty"`
}
func (SystemdStageOptions) isStageOptions() {}
func NewSystemdStage(options *SystemdStageOptions) *Stage {
return &Stage{
Name: "org.osbuild.systemd",
Options: options,
}
}

View file

@ -0,0 +1,14 @@
package pipeline
type TimezoneStageOptions struct {
Zone string `json:"zone"`
}
func (TimezoneStageOptions) isStageOptions() {}
func NewTimezoneStage(options *TimezoneStageOptions) *Stage {
return &Stage{
Name: "org.osbuild.users",
Options: options,
}
}

View file

@ -0,0 +1,25 @@
package pipeline
type UsersStageOptions struct {
Users map[string]UsersStageOptionsUser `json:"users"`
}
func (UsersStageOptions) isStageOptions() {}
type UsersStageOptionsUser struct {
UID *string `json:"uid,omitempty"`
GID *string `json:"gid,omitempty"`
Groups []string `json:"groups,omitempty"`
Description *string `json:"description,omitempty"`
Home *string `json:"home,omitempty"`
Shell *string `json:"shell,omitempty"`
Password *string `json:"password,omitempty"`
Key *string `json:"key,omitempty"`
}
func NewUsersStage(options *UsersStageOptions) *Stage {
return &Stage{
Name: "org.osbuild.users",
Options: options,
}
}