From a717a7245bac622e2b5a1e83d2cf11c0a785a162 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Fri, 30 Apr 2021 18:28:13 +0200 Subject: [PATCH] osbuild2: new stages org.osbuild.chmod: runs chmod on one or more files org.osbuild.nginx.conf: write nginx config file Signed-off-by: Achilleas Koutsou --- internal/osbuild2/chmod_stage.go | 20 +++++++++++++++++ internal/osbuild2/nginxconf_stage.go | 32 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 internal/osbuild2/chmod_stage.go create mode 100644 internal/osbuild2/nginxconf_stage.go diff --git a/internal/osbuild2/chmod_stage.go b/internal/osbuild2/chmod_stage.go new file mode 100644 index 000000000..089a07700 --- /dev/null +++ b/internal/osbuild2/chmod_stage.go @@ -0,0 +1,20 @@ +package osbuild2 + +type ChmodStageOptions struct { + Items map[string]ChmodStagePathOptions `json:"items"` +} + +type ChmodStagePathOptions struct { + Mode string `json:"mode"` + Recursive bool `json:"recursive,omitempty"` +} + +func (ChmodStageOptions) isStageOptions() {} + +// NewChmodStage creates a new org.osbuild.chmod stage +func NewChmodStage(options *ChmodStageOptions) *Stage { + return &Stage{ + Type: "org.osbuild.chmod", + Options: options, + } +} diff --git a/internal/osbuild2/nginxconf_stage.go b/internal/osbuild2/nginxconf_stage.go new file mode 100644 index 000000000..2dc6ad0f9 --- /dev/null +++ b/internal/osbuild2/nginxconf_stage.go @@ -0,0 +1,32 @@ +package osbuild2 + +type NginxConfigStageOptions struct { + // Config file location + Path string `json:"path,omitempty"` + + Config *NginxConfig `json:"config,omitempty"` +} + +func (NginxConfigStageOptions) isStageOptions() {} + +type NginxConfig struct { + // The address and/or port on which the server will accept requests + Listen string `json:"listen,omitempty"` + + // The root directory for requests + Root string `json:"root,omitempty"` + + // File that will store the process ID of the main process + PID string `json:"pid,omitempty"` + + // Whether nginx should become a daemon + Daemon *bool `json:"daemon,omitempty"` +} + +// NewNingxConfigStage creates a new org.osbuild.nginxconfig stage +func NewNginxConfigStage(options *NginxConfigStageOptions) *Stage { + return &Stage{ + Type: "org.osbuild.nginx.conf", + Options: options, + } +}