Skip to content

awscdk-kubectl-go: Does not compile with latest cdk - "duplicate method Env" #37405

@chlunde

Description

@chlunde

Describe the bug

Hi, it seems kubectl-go needs to be updated to support the latest CDK, could you check?

Related: #36060

==> go.mod <==
module poc

go 1.26.1

require (
        github.com/aws/aws-cdk-go/awscdk/v2 v2.245.0
        github.com/aws/constructs-go/constructs/v10 v10.5.1
        github.com/aws/jsii-runtime-go v1.127.0
        github.com/cdklabs/awscdk-kubectl-go/kubectlv35/v2 v2.2.0
)

==> main.go <==
package main

import (
        "github.com/aws/aws-cdk-go/awscdk/v2"
        "github.com/aws/constructs-go/constructs/v10"
        "github.com/aws/jsii-runtime-go"
        kubectlv35 "github.com/cdklabs/awscdk-kubectl-go/kubectlv35/v2"
)

func main() {
        app := awscdk.NewApp(nil)
        stack := awscdk.NewStack(app, jsii.String("poc"), nil)
        _ = kubectlv35.NewKubectlV35Layer(stack, jsii.String("kubectl"))
        _ = constructs.NewConstruct(stack, jsii.String("c"))
        app.Synth(nil)
}

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

v2.223.0

Expected Behavior

Builds fine

Current Behavior

Doesn't build

/tmp/kubectlv35-poc$ go mod tidy && go build .
# github.com/cdklabs/awscdk-kubectl-go/kubectlv35/v2
/home/.../go/pkg/mod/github.com/cdklabs/awscdk-kubectl-go/kubectlv35/v2@v2.2.0/KubectlV35Layer.go:16:2: duplicate method Env
        /home/.../go/pkg/mod/github.com/cdklabs/awscdk-kubectl-go/kubectlv35/v2@v2.2.0/KubectlV35Layer.go:29:2: other declaration of method Env
/home/.../go/pkg/mod/github.com/cdklabs/awscdk-kubectl-go/kubectlv35/v2@v2.2.0/KubectlV35Layer.go:29:16: undefined: awscdk.ResourceEnvironment
/home/.../go/pkg/mod/github.com/cdklabs/awscdk-kubectl-go/kubectlv35/v2@v2.2.0/KubectlV35Layer.go:106:51: undefined: awscdk.ResourceEnvironment
/home/.../go/pkg/mod/github.com/cdklabs/awscdk-kubectl-go/kubectlv35/v2@v2.2.0/KubectlV35Layer.go:107:22: undefined: awscdk.ResourceEnvironment

Reproduction Steps

Se POC above.

Possible Solution

I haven't checked the code in question, but type aliases and/or getting KubectlV3xLayer.go to use interfaces.ResourceEnvironment instead of awscdk.ResourceEnvironment, and renaming/removing the duplicate Env() might be relevant.

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

v2.245.0

AWS CDK CLI version

N/A

Node.js Version

N/A

OS

Linux

Language

Go

Language Version

1.26.1

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    aws-cdk-libRelated to the aws-cdk-lib packagebugThis issue is a bug.p0potential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions