英文:
PutApprovalResult issue with result struct
问题
我有这段 Lambda Go 代码,用于在特定阶段批准代码部署的手动操作步骤。
如果预览阶段成功,Lambda 将自动批准该操作。如果不成功,则需要有人手动检查和批准。作为起点,我编写了这段代码来始终自动批准,在添加更复杂的逻辑之前。
我在处理如何输入 PutApprovalResult 文档 和 ApprovalResult 文档 这样简单的事情上遇到了困难。
我已经到处寻找示例,但没有找到。有人可以帮我一下吗?
我的代码:
func auto_approve(pipeName, stageName, actionName, token string){
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("eu-central-1"))
if err != nil {
log.Fatal(err)
}
client := codepipeline.NewFromConfig(cfg)
//approve := { Status: "Approved", Summary: "Approved by lambda" }
client.PutApprovalResult(context.TODO(), &codepipeline.PutApprovalResultInput{
ActionName: &actionName,
StageName: &stageName,
PipelineName: &pipeName,
Token: &token,
Result: &codepipeline.ApprovalResult{ Status: "Approved", Summary: "Approved by lambda"}, // 这里是问题所在
})
return
}
英文:
I have this lambda go code, which approves a code deploy manual action step at a certain stage.
If the preview stage was successful then lambda will auto-approve the action. If not, then someone will have to check and do it manually. As a starting point, I wrote this code to always auto-approve, before adding more complex logic.
I'm having a hard time with something so simple as entering PutApprovalResult documentation
and ApprovalResult documentation.
Been looking everywhere for examples but nothing. Can someone give me a hand here, please?
My code:
func auto_approve(pipeName, stageName, actionName, token string){
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("eu-central-1"))
if err != nil {
log.Fatal(err)
}
client := codepipeline.NewFromConfig(cfg)
//approve := { Status: "Approved", Summary: "Approved by lambda" }
client.PutApprovalResult(context.TODO(), &codepipeline.PutApprovalResultInput{
ActionName: &actionName,
StageName: &stageName,
PipelineName: &pipeName,
Token: &token,
Result: { Status: "Approved", Summary: "Approved by lambda"}, \\Here is the problem
})
return
}
答案1
得分: 1
好的,以下是翻译好的内容:
好的,在经过大量的试错和阅读实际的主要源代码而不是文档之后,我终于弄清楚我需要添加类型。同时...
结果:&types.ApprovalResult{ Status: "Approved", Summary: &summsg },
此外,摘要部分需要指向一个字符串... 如果有人可以评论并解释为什么,这样我就能学到一些东西,那就太好了。
英文:
OK after a LOT of trial and error and reading the actual main source code and not the document I was able to figure out I need to add types. As well…
Result: &types.ApprovalResult{ Status: "Approved", Summary: &summsg },
Furthermore, the Summary part needs to point out to a string… If someone can comment and explain why, so I learn something, will be nice.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论