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'` - envVar: bar=baz # same as `--env 'bar=baz@server:0'`
nodeFilters: nodeFilters:
- server:0 - 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 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` create: # creates a default registry to be used with the cluster; same as `--registry-create registry.localhost`
name: registry.localhost name: registry.localhost

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

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

Loading…
Cancel
Save