Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[codegen/go] Add GenerateProgramWithOpts function #8997

Merged
merged 6 commits into from Feb 16, 2022

Conversation

lblackstone
Copy link
Member

@lblackstone lblackstone commented Feb 15, 2022

Description

Add an additional function to enable configurable codegen options.

Here's an example of the generated Go code with this change:

package main

import (
        "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/rds"
        "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
        pulumi.Run(func(ctx *pulumi.Context) error {
                dbCluster, err := rds.NewCluster(ctx, "db-Cluster", &rds.ClusterArgs{
                        MasterPassword: pulumi.ToSecret("foobar").(pulumi.StringOutput),
                })
                if err != nil {
                        return err
                }
                return nil
        })
}

Note that this code currently won't compile due to an unused variable. We could generate a block of code like this if we wanted to guarantee that it compiles:

    // The following assignments are used to ignore unused variable compiler errors for generated variables.
    _ = dbCluster

Fixes # (issue)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • Yes, there are changes in this PR that warrants bumping the Pulumi Service API version

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 584dd67

@github-actions
Copy link

Diff for pulumi-random with merge commit 584dd67

Add an additional function to enable configurable codegen options.
@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 584dd67

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 584dd67

@github-actions
Copy link

Diff for pulumi-random with merge commit 7a3f038

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 7a3f038

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 7a3f038

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 7a3f038

@github-actions
Copy link

Diff for pulumi-azure with merge commit 584dd67

@github-actions
Copy link

Diff for pulumi-aws with merge commit 584dd67

@github-actions
Copy link

Diff for pulumi-azure with merge commit 7a3f038

@github-actions
Copy link

Diff for pulumi-aws with merge commit 7a3f038

pkg/codegen/go/gen_program.go Outdated Show resolved Hide resolved
pkg/codegen/go/gen_program.go Outdated Show resolved Hide resolved
pkg/codegen/go/gen_program.go Outdated Show resolved Hide resolved
@github-actions
Copy link

Diff for pulumi-azure-native with merge commit 584dd67

@github-actions
Copy link

Diff for pulumi-azure-native with merge commit 7a3f038

@github-actions
Copy link

Diff for pulumi-random with merge commit 69e9540

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 69e9540

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 69e9540

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 69e9540

@github-actions
Copy link

Diff for pulumi-azure with merge commit 69e9540

@github-actions
Copy link

Diff for pulumi-aws with merge commit 69e9540

@github-actions
Copy link

Diff for pulumi-random with merge commit a5162a2

@github-actions
Copy link

Diff for pulumi-azuread with merge commit a5162a2

@github-actions
Copy link

Diff for pulumi-azuread with merge commit cd98745

@github-actions
Copy link

Diff for pulumi-random with merge commit cd98745

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit a5162a2

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit cd98745

@github-actions
Copy link

Diff for pulumi-gcp with merge commit cd98745

@github-actions
Copy link

Diff for pulumi-gcp with merge commit a5162a2

@github-actions
Copy link

Diff for pulumi-azure with merge commit a5162a2

@github-actions
Copy link

Diff for pulumi-azure with merge commit cd98745

@github-actions
Copy link

Diff for pulumi-aws with merge commit a5162a2

@github-actions
Copy link

Diff for pulumi-aws with merge commit cd98745

@github-actions
Copy link

Diff for pulumi-azure-native with merge commit 69e9540

@github-actions
Copy link

Diff for pulumi-azure-native with merge commit a5162a2

@github-actions
Copy link

Diff for pulumi-azure-native with merge commit cd98745

Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (aside from some nits)

pkg/codegen/go/gen_program.go Outdated Show resolved Hide resolved
pkg/codegen/go/gen_program.go Outdated Show resolved Hide resolved
pkg/codegen/go/gen_program.go Outdated Show resolved Hide resolved
@github-actions
Copy link

Diff for pulumi-random with merge commit 91e0427

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 91e0427

@github-actions
Copy link

Diff for pulumi-azuread with merge commit da4e8a9

@github-actions
Copy link

Diff for pulumi-random with merge commit da4e8a9

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 91e0427

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit da4e8a9

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 91e0427

@github-actions
Copy link

Diff for pulumi-gcp with merge commit da4e8a9

@github-actions
Copy link

Diff for pulumi-azure with merge commit da4e8a9

@github-actions
Copy link

Diff for pulumi-azure with merge commit 91e0427

@github-actions
Copy link

Diff for pulumi-aws with merge commit da4e8a9

@github-actions
Copy link

Diff for pulumi-aws with merge commit 91e0427

@github-actions
Copy link

Diff for pulumi-azure-native with merge commit 91e0427

@github-actions
Copy link

Diff for pulumi-azure-native with merge commit da4e8a9

@lblackstone lblackstone merged commit 36e649e into master Feb 16, 2022
@pulumi-bot pulumi-bot deleted the lblackstone/go-gen-opts branch February 16, 2022 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants