examples: Add more examples and clean up some

This commit is contained in:
James Shubin
2019-02-04 05:03:37 -05:00
parent f61e1cb36d
commit bbfeb49cdf
15 changed files with 98 additions and 26 deletions

View File

@@ -0,0 +1,22 @@
import "fmt"
class foo {
print "foo1" {
msg => "inside foo",
Meta:autogroup => false,
}
}
class bar($a, $b) { # a parameterized class
print "bar-"+ $a {
msg => fmt.printf("inside bar: %s", $b),
Meta:autogroup => false,
}
}
include foo
include foo # duplicate
include bar("b1", "hello")
include bar("b2", "world")
include bar("b2", "world") # duplicate

View File

@@ -0,0 +1,8 @@
# this combination should error
pkg "cowsay" {
state => "uninstalled",
}
pkg "cowsay" {
state => "installed",
}

View File

@@ -0,0 +1,7 @@
pkg "cowsay" {
state => "newest",
}
pkg "cowsay" {
state => "installed",
}

View File

@@ -0,0 +1,8 @@
import "fmt"
import "sys"
$x = sys.getenv("TEST", "321")
print "print1" {
msg => fmt.printf("TEST is: %s", $x),
}

View File

@@ -0,0 +1,21 @@
# single resource
print "name" {}
# single resource, defined by list variable
$names = ["hey", "there",]
print $names {
Meta:autogroup => false,
}
# multiples resources, defined by list
print ["hello", "world",] {
Meta:autogroup => false,
Depend => Print[$names],
}
$morenames = ["wow", "cool", "amazing",]
print $morenames {
Meta:autogroup => false,
}
Print[$names] -> Print[$morenames]

View File

@@ -0,0 +1,3 @@
nspawn "sid-chroot" {
state => "running",
}

View File

@@ -0,0 +1,3 @@
nspawn "Fedora-Cloud-Base-27-1.6.x86_64" {
state => "running",
}

View File

@@ -1,6 +1,6 @@
import "os" import "os"
# this copies the contents from /tmp/foo and puts them in /tmp/output # this copies the contents from /tmp/input and puts them in /tmp/output
file "/tmp/output" { file "/tmp/output" {
content => os.readfile("/tmp/foo"), content => os.readfile("/tmp/input"),
} }