Skip to content

Failed to build result of "naml codify" #99

@larsks

Description

@larsks

I have an example app that consists of a Service:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: example
  name: example
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app: example
  type: LoadBalancer

And a Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: example
  name: example
spec:
  replicas: 1
  selector:
    matchLabels:
      app: example
  template:
    metadata:
      labels:
        app: example
    spec:
      containers:
      - containerPorts:
        - containerPort: 8080
          name: http
          protocol: TCP
        image: alpinelinux/darkhttpd
        name: darkhttpd

If I try to follow the instructions in the README, the build fails because of missing dependencies:

$ mkdir out
$ cat deployment.yaml service.yaml | naml codify > out/main.go
$ cd out
$ naml build -o app
2021-11-21T08:15:27-05:00 [Critical  ]  unable to build NAML binary from source:

+-------------------------+---------------------------------
| Codify Compile Failure  |
+-------------------------+
|
|
| /tmp/3696928851.go:34: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/3696928851.go:30: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/3696928851.go:31: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/3696928851.go:35: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/3696928851.go:32:2: no required module provides package k8s.io/apimachinery/pkg/util/intstr: go.mod file not found in current directory or any parent directory; see 'go help modules'
/tmp/3696928851.go:36: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'

If I try to resolve the dependency problems by running go mod init and go tidy...

$ go mod init example
go: creating new go.mod: module example
go: to add module requirements and sums:
        go mod tidy
$ go mod tidy
go: finding module for package github.com/kris-nova/naml
go: finding module for package k8s.io/api/core/v1
go: finding module for package k8s.io/apimachinery/pkg/apis/meta/v1
go: finding module for package k8s.io/apimachinery/pkg/util/intstr
go: finding module for package k8s.io/client-go/kubernetes
go: finding module for package k8s.io/apimachinery/pkg/runtime
go: found github.com/kris-nova/naml in github.com/kris-nova/naml v1.0.1
go: found k8s.io/api/core/v1 in k8s.io/api v0.22.4
go: found k8s.io/apimachinery/pkg/apis/meta/v1 in k8s.io/apimachinery v0.22.4
go: found k8s.io/apimachinery/pkg/runtime in k8s.io/apimachinery v0.22.4
go: found k8s.io/apimachinery/pkg/util/intstr in k8s.io/apimachinery v0.22.4
go: found k8s.io/client-go/kubernetes in k8s.io/client-go v0.22.4

...and then attempt to build, it fails with unused imports and an undefined reference:

$ naml build -o app
2021-11-21T08:16:51-05:00 [Critical  ]  unable to build NAML binary from source:

+-------------------------+---------------------------------
| Codify Compile Failure  |
+-------------------------+
|
|
| # command-line-arguments
/tmp/2642747543.go:30:2: imported and not used: "k8s.io/api/core/v1" as corev1
/tmp/2642747543.go:32:2: imported and not used: "k8s.io/apimachinery/pkg/util/intstr"
/tmp/2642747543.go:70:21: undefined: Service
+----------------------------------------------------------

Is the README missing some steps? Am I missing some steps?

I am using naml 1.0.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions