Open larsks opened 2 years ago
Thanks for providing the YAML and the failure!
I will add this as a regression in the unit tests and cut a release with the fix. Stay tuned!
The problem was that naml was expecting the naml delimiter to separate the two files Reforming your command to include the delimiter will help
printf "\n\n---\n\n" | cat file1.yaml - file2.yaml - file3.yaml | naml codify > out/main.go
Well now I feel stupid for not even thinking about that because I deal with multi-document YAML files all the time and never even considered that. But even ignoring that particular issue, I still see the build failures:
$ mkdir out
$ naml codify < deployment.yaml > out/main.go
$ cd out
$ naml build -o app
2021-11-22T11:19:27-05:00 [Critical ] unable to build NAML binary from source:
+-------------------------+---------------------------------
| Codify Compile Failure |
+-------------------------+
|
|
| /tmp/1481936367.go:30:2: no required module provides package github.com/hexops/valast: go.mod file not found in current directory or any parent directory; see 'go help modules'
/tmp/1481936367.go:35:2: no required module provides package github.com/kris-nova/naml: go.mod file not found in current directory or any parent directory; see 'go help modules'
/tmp/1481936367.go:31:2: no required module provides package k8s.io/api/apps/v1: go.mod file not found in current directory or any parent directory; see 'go help modules'
/tmp/1481936367.go:32:2: no required module provides package k8s.io/api/core/v1: go.mod file not found in current directory or any parent directory; see 'go help modules'
/tmp/1481936367.go:33:2: no required module provides package k8s.io/apimachinery/pkg/apis/meta/v1: go.mod file not found in current directory or any parent directory; see 'go help modules'
/tmp/1481936367.go:36:2: no required module provides package k8s.io/apimachinery/pkg/runtime: go.mod file not found in current directory or any parent directory; see 'go help modules'
/tmp/1481936367.go:37:2: no required module provides package k8s.io/client-go/kubernetes: go.mod file not found in current directory or any parent directory; see 'go help modules'
+----------------------------------------------------------
Oh I didn't see that you were using naml build
which is basically just a wrapper of the Go compiler.
For what it's worth I always work using the /out
directory in the naml repository.
The provided go.mod
that ships with naml should include all the dependencies you need to build your binary.
git clone git@github.com:kris-nova/naml.git
cd naml
git checkout tags/v1.0.1 -b v1.0.1
cat deploy.yaml | naml codify > out/main.go
cd out
naml build -o app
./app
I think your error still deserves a test and a workflow, i will repeat the same process that I did with #100 and follow up
For what it's worth I always work using the /out directory in the naml repository.
Ah, I see. The README wasn't clear that the out
directory was created inside the checked out naml
repository. I assumed from the instructions that I could just install the naml
binary and run with it.
If I create the output directory inside the naml
repository, things work as documented.
I assumed from the instructions that I could just install the naml binary and run with it.
I want to be clear. We do want to support that functionality with naml.
I think we are learning that naml is probably going to have to have a command such as naml init
or naml env
that will initialize a directory for compiling.
Keeping this issue open as a reminder for myself to address this in a later release.
Happy to know your code is working now.
I have an example app that consists of a
Service
:And a
Deployment
:If I try to follow the instructions in the
README
, the build fails because of missing dependencies:If I try to resolve the dependency problems by running
go mod init
andgo tidy
......and then attempt to build, it fails with unused imports and an undefined reference:
Is the README missing some steps? Am I missing some steps?
I am using naml 1.0.1.