docs: add examples for config embedded and external files (#1432)

pull/1431/head^2
Ahmed AbouZaid 3 months ago committed by GitHub
parent 9eaa6c4d8e
commit e306d63dd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      docs/usage/configfile.md
  2. 13
      pkg/config/config_test.go
  3. 44
      pkg/config/test_assets/config_test_simple.yaml
  4. 0
      pkg/config/test_assets/ns-baz.yaml

@ -77,6 +77,19 @@ env:
- envVar: bar=baz # same as `--env 'bar=baz@server:0'`
nodeFilters:
- server:0
files:
- description: 'Source: Embedded, Destination: Magic shortcut path'
source: |
apiVersion: v1
kind: Namespace
metadata:
name: foo
destination: k3s-manifests-custom/foo.yaml # Resolved to /var/lib/rancher/k3s/server/manifests/custom/foo.yaml
- description: 'Source: Relative, Destination: Absolute path, Node: Servers only'
source: ns-baz.yaml
destination: /var/lib/rancher/k3s/server/manifests/baz.yaml
nodeFilters:
- "server:*"
registries: # define how registries should be created or used
create: # creates a default registry to be used with the cluster; same as `--registry-create registry.localhost`
name: registry.localhost

@ -73,6 +73,7 @@ func TestReadSimpleConfig(t *testing.T) {
},
Files: []conf.FileWithNodeFilters{
{
Description: "Source: Embedded, Destination: Absolute path",
Source: "apiVersion: v1\n" +
"kind: Namespace\n" +
"metadata:\n" +
@ -80,23 +81,23 @@ func TestReadSimpleConfig(t *testing.T) {
Destination: "/var/lib/rancher/k3s/server/manifests/foo.yaml",
},
{
Description: "Source: Embedded, Destination: Magic shortcut path",
Source: "apiVersion: v1\n" +
"kind: Namespace\n" +
"metadata:\n" +
" name: bar\n",
Destination: "k3s-manifests/bar.yaml",
Description: "Source: Embedded content in k3d config file, Destination: Magic shortcut path, Description: Defined",
},
{
Source: "baz-ns.yaml",
Description: "Source: Relative, Destination: Magic shortcut path",
Source: "ns-baz.yaml",
Destination: "k3s-manifests-custom/baz.yaml",
Description: "Source: Relative path to k3d config file, Destination: Magic shortcut path, Description: Defined",
},
{
Source: "baz-ns.yaml",
Destination: "k3s-manifests-custom/baz-server.yaml",
Description: "Source: Relative, Destination: Magic shortcut path, Node: Servers only",
Source: "ns-baz.yaml",
Destination: "k3s-manifests/baz.yaml",
NodeFilters: []string{"server:*"},
Description: "Source: Relative path to k3d config file, Destination: Magic shortcut path, Node: Defined, Description: Defined",
},
},
Options: conf.SimpleConfigOptions{

@ -24,28 +24,28 @@ env:
nodeFilters:
- all
files:
- source: |
apiVersion: v1
kind: Namespace
metadata:
name: foo
destination: /var/lib/rancher/k3s/server/manifests/foo.yaml
# destination: "Source: Embedded content in k3d config file, Destination: Absolute path, Description: Not defined"
- source: |
apiVersion: v1
kind: Namespace
metadata:
name: bar
destination: k3s-manifests/bar.yaml # Resolved to /var/lib/rancher/k3s/server/manifests/bar.yaml
description: 'Source: Embedded content in k3d config file, Destination: Magic shortcut path, Description: Defined'
- source: baz-ns.yaml
destination: k3s-manifests-custom/baz.yaml # Resolved to /var/lib/rancher/k3s/server/manifests/custom/bar.yaml
description: 'Source: Relative path to k3d config file, Destination: Magic shortcut path, Description: Defined'
- source: baz-ns.yaml
destination: k3s-manifests-custom/baz-server.yaml # Resolved to /var/lib/rancher/k3s/server/manifests/custom/bar-server.yaml
nodeFilters:
- "server:*"
description: 'Source: Relative path to k3d config file, Destination: Magic shortcut path, Node: Defined, Description: Defined'
- description: 'Source: Embedded, Destination: Absolute path'
source: |
apiVersion: v1
kind: Namespace
metadata:
name: foo
destination: /var/lib/rancher/k3s/server/manifests/foo.yaml
- description: 'Source: Embedded, Destination: Magic shortcut path'
source: |
apiVersion: v1
kind: Namespace
metadata:
name: bar
destination: k3s-manifests/bar.yaml # Resolved to /var/lib/rancher/k3s/server/manifests/bar.yaml
- description: 'Source: Relative, Destination: Magic shortcut path'
source: ns-baz.yaml
destination: k3s-manifests-custom/baz.yaml # Resolved to /var/lib/rancher/k3s/server/manifests/custom/baz.yaml
- description: 'Source: Relative, Destination: Magic shortcut path, Node: Servers only'
source: ns-baz.yaml
destination: k3s-manifests/baz.yaml # Resolved to /var/lib/rancher/k3s/server/manifests/baz.yaml
nodeFilters:
- "server:*"
options:
k3d:

Loading…
Cancel
Save