當前位置: 首頁>>代碼示例>>Golang>>正文


Golang awsutil.Prettify函數代碼示例

本文整理匯總了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
}
開發者ID:nlamirault,項目名稱:enigma,代碼行數:27,代碼來源:s3.go

示例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]))
	}
}
開發者ID:TanUkkii007,項目名稱:ecs-formation,代碼行數:27,代碼來源:converter_test.go

示例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))
}
開發者ID:ainoya,項目名稱:devicefarm-cli,代碼行數:25,代碼來源:devicefarm-cli.go

示例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))
	}
}
開發者ID:CyCoreSystems,項目名稱:coreos-kubernetes,代碼行數:9,代碼來源:converter_test.go

示例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)
	}

}
開發者ID:Vungle,項目名稱:labelgun,代碼行數:52,代碼來源:labelgun.go

示例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))
	}
}
開發者ID:ColourboxDevelopment,項目名稱:aws-sdk-go,代碼行數:13,代碼來源:marshaler_test.go

示例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
}
開發者ID:MDL,項目名稱:terraform,代碼行數:14,代碼來源:resource_aws_route.go

示例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))
}
開發者ID:Talos208,項目名稱:aws-sdk-go,代碼行數:31,代碼來源:examples_test.go

示例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))
}
開發者ID:Talos208,項目名稱:aws-sdk-go,代碼行數:27,代碼來源:examples_test.go

示例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))
}
開發者ID:Talos208,項目名稱:aws-sdk-go,代碼行數:30,代碼來源:examples_test.go

示例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))
}
開發者ID:strife25,項目名稱:aws-sdk-go,代碼行數:34,代碼來源:examples_test.go

示例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))
}
開發者ID:strife25,項目名稱:aws-sdk-go,代碼行數:28,代碼來源:examples_test.go

示例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))
}
開發者ID:strife25,項目名稱:aws-sdk-go,代碼行數:28,代碼來源:examples_test.go

示例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))
}
開發者ID:strife25,項目名稱:aws-sdk-go,代碼行數:31,代碼來源:examples_test.go

示例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))
}
開發者ID:strife25,項目名稱:aws-sdk-go,代碼行數:32,代碼來源:examples_test.go


注:本文中的github.com/aws/aws-sdk-go/aws/awsutil.Prettify函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。