https://pulumi.com logo
Title
m

magnificent-restaurant-51456

01/12/2021, 11:25 AM
I tried to write an automation api with revel framework but when I declare the variable S for new stackinlinestack, I get S as invalid type. Am i missing anything?
package controllers
import (
    
"context"
    
"<http://github.com/pulumi/pulumi-azure/sdk/go/azure/core|github.com/pulumi/pulumi-azure/sdk/go/azure/core>"
    
"<http://github.com/pulumi/pulumi/sdk/go/pulumi|github.com/pulumi/pulumi/sdk/go/pulumi>"
    
"<http://github.com/pulumi/pulumi/sdk/v2/go/x/auto|github.com/pulumi/pulumi/sdk/v2/go/x/auto>"
    
"<http://github.com/revel/revel|github.com/revel/revel>"
)
type ResourceNames struct {
    `RgName      string `json:"rgname"``     `StorageName string `json:"storage_name"``
}
type CreateReq struct {
    `StackName   string `json:"stackname"``     `ProjectName string `json:"project_name"``     
Resources   []ResourceNames
}
func (c App) CreateResourceGroup() revel.Result {
    
ctx := context.Background()
    
c.Params.BindJSON(&<http://c.cr|c.cr>)
    
program := createRgProgram(c.rn.RgName)
    
s, err := auto.NewStackInlineSource(ctx, <http://c.cr|c.cr>.StackName, <http://c.cr|c.cr>.ProjectName, program)
    
if err != nil {
        
if auto.IsSelectStack404Error(err) {
            
return c.RenderText("stack already exists")
        
}
        
return c.RenderText(err.Error())
    
}
    
s.SetConfig(ctx, "azure.clientId", auto.ConfigValue{Value: ""})
    
return c.Render()
}
func createRgProgram(Name string) pulumi.RunFunc {
    
return func(ctx *pulumi.Context) error {
        
// our program defines a s3 website.
        
// here we create the bucket
        
resourceGroup, err := core.NewResourceGroup(ctx, "testpulumi", &core.ResourceGroupArgs{
            
Location: pulumi.String("westindia"),
            
Name:     pulumi.String(Name),
            
Tags: pulumi.StringMap{
                
"Created_By": pulumi.String(""),
                
"Purpose":    pulumi.String("test pulumi"),
                
"Start_Date": pulumi.String("16-Nov-2020"),
                
"End_Date":   pulumi.String("16-Jan-2020"),
            
},
        
})
        
if err != nil {
            
return err
        
}
        
// export the website URL
        
ctx.Export("resourceGroupName", resourceGroup.Name)
        
return nil
    
}
}