Hi all. I'm using the Go SDK to create a small uti...
# golang
f
Hi all. I'm using the Go SDK to create a small util to set up a stack using a local backend. For example:
Copy code
project := auto.Project(workspace.Project{                                                                                                                                                                
        Name:    tokens.PackageName(projectName),                                                                                                                                                         
        Runtime: workspace.NewProjectRuntimeInfo("go", nil),                                                                                                                                              
        Backend: &workspace.ProjectBackend{                                                                                                                                                               
                URL: "file://~/.pulumi-local",                                                                                                                                                               
        },                                                                                                                                                                                                })                                                                                                                                                                                                        
                                                                                                     
s, err := auto.UpsertStackInlineSource(ctx, stackName, projectName, deployFunc(configPath), project, secretsProvider, stackSettings, envvars)
My issue is that if
~/.pulumi-local
directory doesn't exist, this will fail with
stderr: error: unable to open bucket file:///home/tim/.pulumi-local: stat /home/tim/.pulumi-local: no such file or directory
. If the directory exists, the code works and the stack is updated without issue. Looking through the pulumi CLI code, the 'login' function is what would normally create the local backend directory if it doesn't exist, but I can't seem to find this functionality exposed by the SDK.