Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/usage/configfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,31 @@ func TestReadSimpleConfig(t *testing.T) {
},
Files: []conf.FileWithNodeFilters{
{
Description: "Source: Embedded, Destination: Absolute path",
Source: "apiVersion: v1\n" +
"kind: Namespace\n" +
"metadata:\n" +
" name: foo\n",
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{
Expand Down
44 changes: 22 additions & 22 deletions pkg/config/test_assets/config_test_simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
File renamed without changes.