2

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
  }
  ...
meh
  • 2,591
  • 4
  • 20
  • 33
  • That type does not exist in that package, so there must be an error in the documentation. – JimB Feb 15 '23 at 20:07
  • 1
    For whatever reason it seems to be present in `v3` but not in `v10`. So you may be able to make the example work with `import "github.com/aws/constructs-go/constructs/v3"`. – mkopriva Feb 16 '23 at 07:43
  • Ok, I tried this again and still same error. Googled it and was happy to see somebody had asked this question. I went to upvote this question and got the error: can't upvote your own question. Nice. I guess nobody uses this? I tried v3 but got other errors. And I'm not in the mood to troubleshoot those. – meh Apr 13 '23 at 11:54

1 Answers1

0

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

Eli Polonsky
  • 511
  • 1
  • 3
  • 11
  • Whilst this may theoretically answer the question, [it would be preferable](//meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. Please [edit] the answer with all relevant information. Make sure to use your own words, [answers comprised entirely of a quote (sourced or not) will often be deleted since they do not contain any original content](/help/referencing). – Adriaan Apr 18 '23 at 11:26