Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #60 from digitalrebar/metasetter
Browse files Browse the repository at this point in the history
Meta Data Setting Stage, Task, Params and Template
  • Loading branch information
galthaus authored Feb 26, 2018
2 parents 143b58e + 00b722b commit c227700
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
8 changes: 8 additions & 0 deletions content/params/machine-meta.color.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Description: The color for machines icon
Meta:
color: blue
icon: info
title: RackN Content
Name: machine-meta/color
Schema:
type: string
8 changes: 8 additions & 0 deletions content/params/machine-meta.icon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Description: The icon for machines icon
Meta:
color: blue
icon: info
title: RackN Content
Name: machine-meta/icon
Schema:
type: string
10 changes: 10 additions & 0 deletions content/stages/machine-meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Description: Stage to assign the machine icon and color
Meta:
color: yellow
icon: info
Name: machine-meta
Reboot: false
RunnerWait: true
Tasks:
- machine-meta-setter

14 changes: 14 additions & 0 deletions content/tasks/machine-meta-setter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Description: A task to set the color and icon for a machine
Meta:
color: blue
icon: info
Name: machine-meta-setter
OptionalParams:
- "machine-meta/color"
- "machine-meta/icon"
Templates:
- Contents: ""
ID: machine-meta-setter.sh.tmpl
Name: "Set Icons"
Path: ""

29 changes: 29 additions & 0 deletions content/templates/machine-meta-setter.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Set the Machine Meta: Icon and Color

set -e

export RS_UUID="{{.Machine.UUID}}"

{{template "setup.tmpl" .}}

{{if .ParamExists "machine-meta/color" -}}
COLOR={{.Param "machine-meta/color"}}
{{else -}}
COLOR="black"
{{end -}}

{{if .ParamExists "machine-meta/icon" -}}
ICON={{.Param "machine-meta/icon"}}
{{else -}}
ICON="server"
{{end -}}

echo "Setting the Color to $COLOR and Icon to $ICON"

# do work!
drpcli machines update $RS_UUID "{\"Meta\":{\"color\":\"$COLOR\", \"icon\": \"$ICON\"}}" | jq .Meta

echo "Finished successfully"
exit 0

2 changes: 2 additions & 0 deletions content/templates/setup.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/local/bin/env bash
# Helper to setup DRP tasks for other templates
#
###
# This is a BASH script snippet intended to be run inside other BASH templates.
#
Expand Down

0 comments on commit c227700

Please sign in to comment.