本文整理汇总了Golang中github.com/apex/apex/utils.Sha256函数的典型用法代码示例。如果您正苦于以下问题:Golang Sha256函数的具体用法?Golang Sha256怎么用?Golang Sha256使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sha256函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DeployCode
// DeployCode generates a zip and creates or updates the function.
func (f *Function) DeployCode() error {
f.Log.Info("deploying")
zip, err := f.ZipBytes()
if err != nil {
return err
}
info, err := f.Info()
if e, ok := err.(awserr.Error); ok {
if e.Code() == "ResourceNotFoundException" {
return f.Create(zip)
}
}
if err != nil {
return err
}
remoteHash := *info.Configuration.CodeSha256
localHash := utils.Sha256(zip)
if localHash == remoteHash {
f.Log.Info("unchanged")
return nil
}
return f.Update(zip)
}
示例2: UpdateFunctionCode
// UpdateFunctionCode stub.
func (l *Lambda) UpdateFunctionCode(in *lambda.UpdateFunctionCodeInput) (*lambda.FunctionConfiguration, error) {
res, err := l.GetFunction(&lambda.GetFunctionInput{
FunctionName: in.FunctionName,
})
if err != nil {
return nil, err
}
size := uint64(len(in.ZipFile))
checksum := utils.Sha256(in.ZipFile)
remoteChecksum := *res.Configuration.CodeSha256
remoteSize := uint64(*res.Configuration.CodeSize)
if checksum != remoteChecksum {
l.create("function", *in.FunctionName, map[string]interface{}{
"size": fmt.Sprintf("%s -> %s", humanize.Bytes(remoteSize), humanize.Bytes(size)),
})
}
out := &lambda.FunctionConfiguration{
Version: aws.String("$LATEST"),
}
return out, nil
}
示例3: DeployCode
// DeployCode deploys function code when changed.
func (f *Function) DeployCode(zip []byte, config *lambda.GetFunctionOutput) error {
remoteHash := *config.Configuration.CodeSha256
localHash := utils.Sha256(zip)
if localHash == remoteHash {
f.Log.Info("code unchanged")
return nil
}
f.Log.WithFields(log.Fields{
"local": localHash,
"remote": remoteHash,
}).Debug("code changed")
return f.Update(zip)
}
示例4: DeployCode
// DeployCode generates a zip and creates or updates the function.
func (f *Function) DeployCode() error {
f.Log.Info("deploying")
zip, err := f.BuildBytes()
if err != nil {
return err
}
if err := f.hookDeploy(); err != nil {
return err
}
config, err := f.GetConfig()
if e, ok := err.(awserr.Error); ok {
if e.Code() == "ResourceNotFoundException" {
return f.Create(zip)
}
}
if err != nil {
return err
}
remoteHash := *config.Configuration.CodeSha256
localHash := utils.Sha256(zip)
if localHash == remoteHash {
f.Log.Info("unchanged")
return nil
}
f.Log.WithFields(log.Fields{
"local": localHash,
"remote": remoteHash,
}).Debug("changed")
return f.Update(zip)
}
示例5: Test_Sha256
func Test_Sha256(t *testing.T) {
s := utils.Sha256([]byte("Hello World"))
assert.Equal(t, "pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=", s)
}