fix lint errors
Some checks failed
Lint / golangci-lint (push) Failing after 10m6s
Declarative Tests / test (push) Successful in 1m13s

This commit is contained in:
Matthew Rich 2024-04-21 23:24:38 -07:00
parent 85cff22da4
commit 9f168cff85
3 changed files with 25 additions and 9 deletions

View File

@ -1,10 +1,10 @@
LDFLAGS?=--ldflags '-extldflags "-static"' LDFLAGS?=--ldflags '-extldflags "-static"'
export CGO_ENABLED=0 export CGO_ENABLED=0
build: decl build: jx
decl: jx:
go build -o decl $(LDFLAGS) ./cmd/cli/main.go go build -o jx $(LDFLAGS) ./cmd/cli/main.go
test: test:
go test ./... go test ./...

View File

@ -1,4 +1,4 @@
# decl # jx
# Purpose # Purpose
@ -24,19 +24,35 @@ make build
# Update Resource state # Update Resource state
`decl -resource-file decl-runner.yaml` `jx apply decl-runner.yaml`
Create the resources specified in a resource document HTTP endpoint.
`jx apply http://localhost/resources`
# Read resource state # Read resource state
Read the state of an existing resource (URI) and generate a YAML representation of it. Read the state of an existing resource (URI) and generate a YAML representation of it.
`jx import -resource file://COPYRIGHT`
![Import Resource](md-images/import-resource.gif) ![Import Resource](md-images/import-resource.gif)
Import the contents of a tar archive into a resource document.
`jx import ./test.tgz`
Read a resource document from an http endpoint.
`jx import http://localhost/resources`
# Examples # Examples
Resources: Resources:
* [file](examples/file.yaml) [schema](internal/resource/schemas/file.jsonschema) * [file](examples/file.yaml) [schema](internal/resource/schemas/file.jsonschema)
* [http](examples/http.yaml) [schema](internal/resource/schemas/http.jsonschema)
* [user](examples/user.yaml) [schema](internal/resource/schemas/user.jsonschema) * [user](examples/user.yaml) [schema](internal/resource/schemas/user.jsonschema)
* [package](examples/package.yaml) [schema](internal/resource/schemas/package.jsonschema) * [package](examples/package.yaml) [schema](internal/resource/schemas/package.jsonschema)
* [container](examples/container.yaml) [schema](internal/resource/schemas/container.jsonschema) * [container](examples/container.yaml) [schema](internal/resource/schemas/container.jsonschema)

View File

@ -15,10 +15,10 @@ import (
) )
func TestCli(t *testing.T) { func TestCli(t *testing.T) {
if _, e := os.Stat("./decl"); errors.Is(e, os.ErrNotExist) { if _, e := os.Stat("./jx"); errors.Is(e, os.ErrNotExist) {
t.Skip("cli not built") t.Skip("cli not built")
} }
yaml, cliErr := exec.Command("./decl", "import", "--resource", "file://COPYRIGHT").Output() yaml, cliErr := exec.Command("./jx", "import", "--resource", "file://COPYRIGHT").Output()
slog.Info("TestCli", "err", cliErr) slog.Info("TestCli", "err", cliErr)
assert.Nil(t, cliErr) assert.Nil(t, cliErr)
assert.NotEqual(t, "", string(yaml)) assert.NotEqual(t, "", string(yaml))
@ -26,7 +26,7 @@ func TestCli(t *testing.T) {
} }
func TestCliHTTPSource(t *testing.T) { func TestCliHTTPSource(t *testing.T) {
if _, e := os.Stat("./decl"); errors.Is(e, os.ErrNotExist) { if _, e := os.Stat("./jx"); errors.Is(e, os.ErrNotExist) {
t.Skip("cli not built") t.Skip("cli not built")
} }
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@ -46,7 +46,7 @@ resources:
})) }))
defer ts.Close() defer ts.Close()
yaml, cliErr := exec.Command("./decl", "import", "--resource", ts.URL).Output() yaml, cliErr := exec.Command("./jx", "import", "--resource", ts.URL).Output()
slog.Info("TestCliHTTPSource", "err", cliErr) slog.Info("TestCliHTTPSource", "err", cliErr)
assert.Nil(t, cliErr) assert.Nil(t, cliErr)
assert.NotEqual(t, "", string(yaml)) assert.NotEqual(t, "", string(yaml))