Skip to content

Commit

Permalink
Merge pull request #78 from losisin/fix/rename-config
Browse files Browse the repository at this point in the history
fix: rename config file
  • Loading branch information
losisin authored Jun 25, 2024
2 parents 3682786 + ce383b4 commit e56893d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/losisin/helm-values-schema-json
rev: v1.5.0
rev: v1.5.1
hooks:
- id: helm-schema
args:
Expand Down
2 changes: 1 addition & 1 deletion schema.yaml → .schema.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Required
input:
- schema.yaml
- '.schema.yaml'

draft: 2020 # @schema enum: [4, 6, 7, 2019, 2020]; default: 2020
indent: 4 # @schema default: 4
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ First [install pre-commit](https://pre-commit.com/#install) and then create or u
```yaml
repos:
- repo: https://github.com/losisin/helm-values-schema-json
rev: v1.5.0
rev: v1.5.1
hooks:
- id: helm-schema
args: ["-input", "values.yaml"]
Expand Down Expand Up @@ -110,12 +110,12 @@ Usage: helm schema [options...] <arguments>

### Configuration file

This plugin will look for it's configuration file called `schema.yaml` in the current working directory. All options available from CLI can be set in this file. Example:
This plugin will look for it's configuration file called `.schema.yaml` in the current working directory. All options available from CLI can be set in this file. Example:

```yaml
# Required
input:
- schema.yaml
- values.yaml
draft: 2020
indent: 4
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func main() {
// Load configuration from a YAML file
fileConfig, err := pkg.LoadConfig("schema.yaml")
fileConfig, err := pkg.LoadConfig(".schema.yaml")
if err != nil {
fmt.Println("Error loading config file:", err)
}
Expand Down
14 changes: 7 additions & 7 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ func TestMain(t *testing.T) {
name: "ErrorLoadingConfigFile",
args: []string{"schema", "-input", "testdata/basic.yaml"},
setup: func() {
if _, err := os.Stat("schema.yaml"); err == nil {
if err := os.Rename("schema.yaml", "schema.yaml.bak"); err != nil {
if _, err := os.Stat(".schema.yaml"); err == nil {
if err := os.Rename(".schema.yaml", ".schema.yaml.bak"); err != nil {
log.Fatalf("Error renaming file: %v", err)
}
}

file, _ := os.Create("schema.yaml")
file, _ := os.Create(".schema.yaml")
defer file.Close()
if _, err := file.WriteString("draft: invalid\n"); err != nil {
log.Fatalf("Error writing to file: %v", err)
}
},
cleanup: func() {
if _, err := os.Stat("schema.yaml.bak"); err == nil {
os.Remove("schema.yaml")
if err := os.Rename("schema.yaml.bak", "schema.yaml"); err != nil {
if _, err := os.Stat(".schema.yaml.bak"); err == nil {
os.Remove(".schema.yaml")
if err := os.Rename(".schema.yaml.bak", ".schema.yaml"); err != nil {
log.Fatalf("Error renaming file: %v", err)
}
} else {
os.Remove("schema.yaml")
os.Remove(".schema.yaml")
}
},
expectedOut: "",
Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "schema"
version: "1.5.0"
version: "1.5.1"
usage: "generate values.schema.json from values yaml"
description: "Helm plugin for generating values.schema.json from multiple values files."
ignoreFlags: false
Expand Down

0 comments on commit e56893d

Please sign in to comment.