Skip to content

Commit 14f090a

Browse files
feat: deprecate config file types other than yaml and toml (#3517)
Signed-off-by: Austin Abro <[email protected]>
1 parent 1569ba1 commit 14f090a

File tree

5 files changed

+15
-78
lines changed

5 files changed

+15
-78
lines changed

examples/config-file/zarf-config.ini

-48
This file was deleted.

examples/config-file/zarf-config.json

-20
This file was deleted.

site/src/content/docs/ref/config-files.mdx

+1-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Tabs, TabItem, Code } from "@astrojs/starlight/components";
99

1010
Users can use a config file to easily control flags for `zarf init`, `zarf package create`, and `zarf package deploy` commands, as well as global flags (excluding `--confirm`), enabling a more straightforward and declarative workflow.
1111

12-
Zarf supports config files written in common configuration file formats including `toml`, `json`, `yaml`, `ini` and `props`, and by default Zarf will look for a file called `zarf-config` with one of these filenames in the current working directory. To generate a blank config file you can run `zarf dev generate-config` with an optional output filename/format. For example, to create an empty config file with the `my-cool-env` in the yaml format, you can use `zarf dev generate-config my-cool-env.yaml`.
12+
Zarf supports config files written in `toml` and `yaml`. By default Zarf will look for a file called `zarf-config` with one of these filenames in the current working directory. To generate a blank config file you can run `zarf dev generate-config` with an optional output filename/format. For example, to create an empty config file with the `my-cool-env` in the yaml format, you can use `zarf dev generate-config my-cool-env.yaml`.
1313

1414
To use a custom config filename, set the `ZARF_CONFIG` environment variable to the config file's path. For example, to use the `my-cool-env.yaml` config file in the current working directory, you can set the `ZARF_CONFIG` environment variable to `my-cool-env.yaml`. The `ZARF_CONFIG` environment variable can be set either in the shell or in a `.env` file in the current working directory. Note that the `ZARF_CONFIG` environment variable takes precedence over the default config file path.
1515

@@ -30,8 +30,6 @@ Zarf searches for the Zarf Config File from either your current working director
3030

3131
import configYaml from "../../../../../examples/config-file/zarf-config.yaml?raw";
3232
import configToml from "../../../../../examples/config-file/zarf-config.toml?raw";
33-
import configIni from "../../../../../examples/config-file/zarf-config.ini?raw";
34-
import configJson from "../../../../../examples/config-file/zarf-config.json?raw";
3533

3634
<Tabs>
3735
<TabItem label="yaml">
@@ -40,12 +38,6 @@ import configJson from "../../../../../examples/config-file/zarf-config.json?raw
4038
<TabItem label="toml">
4139
<Code code={configToml} lang="toml" title="zarf-config.toml" />
4240
</TabItem>
43-
<TabItem label="ini">
44-
<Code code={configIni} lang="ini" title="zarf-config.ini" />
45-
</TabItem>
46-
<TabItem label="json">
47-
<Code code={configJson} lang="json" title="zarf-config.json" />
48-
</TabItem>
4941
</Tabs>
5042

5143
## Example Package
@@ -62,4 +54,3 @@ zarf package deploy zarf-package-config-file-<arch>.tar.zst --confirm
6254
```
6355

6456
<Code code={packageConfig} lang="yaml" title="zarf.yaml" />
65-

src/cmd/dev.go

+2
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ func (o *devGenerateConfigOptions) run(_ *cobra.Command, args []string) error {
474474
}
475475

476476
v := getViper()
477+
// TODO once other formats are fully deprecated move this to the global viper config
478+
viper.SupportedExts = []string{"toml", "yaml", "yml"}
477479
if err := v.SafeWriteConfigAs(fileName); err != nil {
478480
return fmt.Errorf("unable to write the config file %s, make sure the file doesn't already exist: %w", fileName, err)
479481
}

src/cmd/viper.go

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"errors"
1010
"fmt"
1111
"os"
12+
"path/filepath"
1213
"strings"
1314

1415
"github.com/zarf-dev/zarf/src/pkg/logger"
@@ -190,6 +191,17 @@ func PrintViperConfigUsed(ctx context.Context) error {
190191
// Zarf skips loading the config file for version and tool commands, this avoids output in those cases
191192
if cfgFile := v.ConfigFileUsed(); cfgFile != "" {
192193
l.Info("using config file", "location", cfgFile)
194+
ext := filepath.Ext(cfgFile)
195+
switch ext {
196+
case ".yml", ".yaml":
197+
return nil
198+
case ".toml":
199+
return nil
200+
default:
201+
l.Warn("configuration file types other than yaml and toml are deprecated and will be removed in a future release",
202+
"fileType", strings.TrimPrefix(ext, "."))
203+
return nil
204+
}
193205
}
194206
return nil
195207
}

0 commit comments

Comments
 (0)