Getting started example of golang cdk8s throws error: `undefined: constructs.ConstructOptions`

116 Views Asked by At

Very simple question. I copy pasted the golang examples of cdk8s right from the documentation. Source. Detail of the error below.

I went to the pkg.go site for cdk8s and did not find this type. I'm not a newbie to go, but I'm also not an expert. So here's my question.

Is this a problem on my end, or a problem with the example?


The example with the webservice fails with the error:

❯ cdk8s synth
Synthesizing application
# example.com/cdk8s-example
./webservice.go:10:13: undefined: constructs.ConstructOptions
./webservice.go:18:24: undefined: constructs.ConstructOptions
Error: ...

Today's date is 2023-02-15 and the relevant example code looks like this:

package main

import (
  "example.com/hello/imports/k8s"
  "github.com/aws/constructs-go/constructs/v10"
  "github.com/aws/jsii-runtime-go"
)

type WebServiceProps struct {
  constructs.ConstructOptions       // <-- this doesn't exist?
  Image         *string
  Replicas      *float64
  Port          *float64
  ContainerPort *float64
}

func NewWebService(scope constructs.Construct, id *string, props *WebServiceProps) constructs.Construct {
  var cprops constructs.ConstructOptions       // <-- this doesn't exist?
  if props != nil {
    cprops = props.ConstructOptions
  }
  ...
1

There are 1 best solutions below

1
On

Sorry about this. Fix in the oven: https://github.com/cdk8s-team/cdk8s/pull/1283