本文整理匯總了Golang中github.com/aws/aws-sdk-go/aws/awsutil.Prettify函數的典型用法代碼示例。如果您正苦於以下問題:Golang Prettify函數的具體用法?Golang Prettify怎麽用?Golang Prettify使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Prettify函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Destroy
// Destroy remove the storage backend bucket
func (s *S3) Destroy() error {
log.Printf("[DEBUG] Amazon S3 Delete bucket objects")
objects, err := s.List()
if err != nil {
return err
}
for _, key := range objects {
resp, err := s.Client.DeleteObject(&s3.DeleteObjectInput{
Bucket: &s.Bucket,
Key: aws.String(key),
})
if err != nil {
return err
}
log.Printf("[DEBUG] %s", awsutil.Prettify(resp))
}
log.Printf("[DEBUG] Delete bucket")
resp, err := s.Client.DeleteBucket(&s3.DeleteBucketInput{
Bucket: &s.Bucket,
})
if err != nil {
return err
}
log.Printf("[DEBUG] Amazon S3 %s", awsutil.Prettify(resp))
return nil
}
示例2: TestToVolumesFrom
func TestToVolumesFrom(t *testing.T) {
input := []string{
"container1",
"container2:ro",
}
actual, err := toVolumesFroms(input)
if err != nil {
t.Error(err)
}
if len(input) != len(actual) {
t.Errorf("expect length = %d, but actual length = %d", len(input), len(actual))
}
if *actual[0].SourceContainer != "container1" ||
*actual[0].ReadOnly != false {
t.Errorf("Unexpected value. Actual = %s", awsutil.Prettify(actual[0]))
}
if *actual[1].SourceContainer != "container2" ||
*actual[1].ReadOnly != true {
t.Errorf("Unexpected value. Actual = %s", awsutil.Prettify(actual[0]))
}
}
示例3: listArtifacts
func listArtifacts(svc *devicefarm.DeviceFarm, filterArn string, artifactType string) {
fmt.Println(filterArn)
listReq := &devicefarm.ListArtifactsInput{
Arn: aws.String(filterArn),
}
listReq.Type = aws.String("LOG")
resp, err := svc.ListArtifacts(listReq)
failOnErr(err, "error listing artifacts")
fmt.Println(awsutil.Prettify(resp))
listReq.Type = aws.String("SCREENSHOT")
resp, err = svc.ListArtifacts(listReq)
failOnErr(err, "error listing artifacts")
fmt.Println(awsutil.Prettify(resp))
listReq.Type = aws.String("FILE")
resp, err = svc.ListArtifacts(listReq)
failOnErr(err, "error listing artifacts")
fmt.Println(awsutil.Prettify(resp))
}
示例4: compareObjects
func compareObjects(t *testing.T, expected interface{}, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
t.Errorf("\nExpected %s:\n%s\nActual %s:\n%s\n",
reflect.ValueOf(expected).Kind(),
awsutil.Prettify(expected),
reflect.ValueOf(actual).Kind(),
awsutil.Prettify(actual))
}
}
示例5: main
func main() {
interval, _ := strconv.ParseInt(os.Getenv("LABELGUN_INTERVAL"), 10, 64)
kube_master = os.Getenv("KUBE_MASTER")
for {
// Get Kube Node name
n, _ := sh.Command("kubectl", "-s", kube_master, "describe", "pod", os.Getenv("HOSTNAME")).Command("grep", "Node").Command("awk", "{print $2}").Command("sed", "[email protected]/.*@@").Output()
node = string(n)
node = strings.TrimSpace(node)
fmt.Println(node)
// Get instance id
instance_id, _ := sh.Command("curl", "-s", "http://169.254.169.254/latest/meta-data/instance-id").Output()
fmt.Println(string(instance_id))
// Get AWS instance metadata
params := &ec2.DescribeInstancesInput{
InstanceIds: []*string{
aws.String(string(instance_id)),
},
}
resp, err := svc.DescribeInstances(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
//fmt.Println(resp.Reservations[0].Instances[0].InstanceType)
meta = resp.Reservations[0].Instances[0]
// Apply Availability Zone
availabilityZone, _ := strconv.Unquote(string(awsutil.Prettify(meta.Placement.AvailabilityZone)))
label("AvailabilityZone=" + availabilityZone)
// Apply Instance Type
instanceType, _ := strconv.Unquote(string(awsutil.Prettify(meta.InstanceType)))
label("InstanceType=" + instanceType)
// Apply EC2 Tags
tags := meta.Tags
for _, tag := range tags {
label(*tag.Key + "=" + *tag.Value)
}
// Sleep until interval
fmt.Println("Sleeping for " + os.Getenv("LABELGUN_INTERVAL") + " seconds")
time.Sleep(time.Duration(interval) * time.Second)
}
}
示例6: compareObjects
func compareObjects(t *testing.T, expected interface{}, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
ev := reflect.ValueOf(expected)
av := reflect.ValueOf(actual)
t.Errorf("\nExpected kind(%s,%T):\n%s\nActual kind(%s,%T):\n%s\n",
ev.Kind(),
ev.Interface(),
awsutil.Prettify(expected),
av.Kind(),
ev.Interface(),
awsutil.Prettify(actual))
}
}
示例7: deleteAwsRoute
func deleteAwsRoute(conn *ec2.EC2, routeTableId string, cidr string) error {
deleteOpts := &ec2.DeleteRouteInput{
RouteTableId: aws.String(routeTableId),
DestinationCidrBlock: aws.String(cidr),
}
log.Printf("[DEBUG] Route delete opts: %s", awsutil.Prettify(deleteOpts))
resp, err := conn.DeleteRoute(deleteOpts)
log.Printf("[DEBUG] Route delete result: %s", awsutil.Prettify(resp))
if err != nil {
return err
}
return nil
}
示例8: ExampleLambda_UpdateFunctionConfiguration
func ExampleLambda_UpdateFunctionConfiguration() {
svc := lambda.New(nil)
params := &lambda.UpdateFunctionConfigurationInput{
FunctionName: aws.String("FunctionName"), // Required
Description: aws.String("Description"),
Handler: aws.String("Handler"),
MemorySize: aws.Int64(1),
Role: aws.String("RoleArn"),
Timeout: aws.Int64(1),
}
resp, err := svc.UpdateFunctionConfiguration(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例9: ExampleLambda_RemovePermission
func ExampleLambda_RemovePermission() {
svc := lambda.New(nil)
params := &lambda.RemovePermissionInput{
FunctionName: aws.String("FunctionName"), // Required
StatementID: aws.String("StatementId"), // Required
}
resp, err := svc.RemovePermission(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例10: ExampleLambda_Invoke
func ExampleLambda_Invoke() {
svc := lambda.New(nil)
params := &lambda.InvokeInput{
FunctionName: aws.String("FunctionName"), // Required
ClientContext: aws.String("String"),
InvocationType: aws.String("InvocationType"),
LogType: aws.String("LogType"),
Payload: []byte("PAYLOAD"),
}
resp, err := svc.Invoke(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例11: ExampleGlacier_SetVaultNotifications
func ExampleGlacier_SetVaultNotifications() {
svc := glacier.New(nil)
params := &glacier.SetVaultNotificationsInput{
AccountId: aws.String("string"), // Required
VaultName: aws.String("string"), // Required
VaultNotificationConfig: &glacier.VaultNotificationConfig{
Events: []*string{
aws.String("string"), // Required
// More values...
},
SNSTopic: aws.String("string"),
},
}
resp, err := svc.SetVaultNotifications(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例12: ExampleGlacier_ListVaults
func ExampleGlacier_ListVaults() {
svc := glacier.New(nil)
params := &glacier.ListVaultsInput{
AccountId: aws.String("string"), // Required
Limit: aws.String("string"),
Marker: aws.String("string"),
}
resp, err := svc.ListVaults(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例13: ExampleElasticBeanstalk_TerminateEnvironment
func ExampleElasticBeanstalk_TerminateEnvironment() {
svc := elasticbeanstalk.New(nil)
params := &elasticbeanstalk.TerminateEnvironmentInput{
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
TerminateResources: aws.Bool(true),
}
resp, err := svc.TerminateEnvironment(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例14: ExampleStorageGateway_CreateStorediSCSIVolume
func ExampleStorageGateway_CreateStorediSCSIVolume() {
svc := storagegateway.New(nil)
params := &storagegateway.CreateStorediSCSIVolumeInput{
DiskId: aws.String("DiskId"), // Required
GatewayARN: aws.String("GatewayARN"), // Required
NetworkInterfaceId: aws.String("NetworkInterfaceId"), // Required
PreserveExistingData: aws.Bool(true), // Required
TargetName: aws.String("TargetName"), // Required
SnapshotId: aws.String("SnapshotId"),
}
resp, err := svc.CreateStorediSCSIVolume(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例15: ExampleStorageGateway_ActivateGateway
func ExampleStorageGateway_ActivateGateway() {
svc := storagegateway.New(nil)
params := &storagegateway.ActivateGatewayInput{
ActivationKey: aws.String("ActivationKey"), // Required
GatewayName: aws.String("GatewayName"), // Required
GatewayRegion: aws.String("RegionId"), // Required
GatewayTimezone: aws.String("GatewayTimezone"), // Required
GatewayType: aws.String("GatewayType"),
MediumChangerType: aws.String("MediumChangerType"),
TapeDriveType: aws.String("TapeDriveType"),
}
resp, err := svc.ActivateGateway(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}