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


Golang awsutil.CopyOf函數代碼示例

本文整理匯總了Golang中github.com/aws/aws-sdk-go/aws/awsutil.CopyOf函數的典型用法代碼示例。如果您正苦於以下問題:Golang CopyOf函數的具體用法?Golang CopyOf怎麽用?Golang CopyOf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CopyOf函數的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: copyDBSnapshotPresign

func copyDBSnapshotPresign(r *request.Request) {
	originParams := r.Params.(*CopyDBSnapshotInput)

	if originParams.PreSignedUrl != nil || originParams.DestinationRegion != nil {
		return
	}

	originParams.DestinationRegion = r.Config.Region
	newParams := awsutil.CopyOf(r.Params).(*CopyDBSnapshotInput)
	originParams.PreSignedUrl = presignURL(r, originParams.SourceRegion, newParams)
}
開發者ID:hashicorp,項目名稱:terraform,代碼行數:11,代碼來源:customizations.go

示例2: populateLocationConstraint

func populateLocationConstraint(r *aws.Request) {
	if r.ParamsFilled() && r.Config.Region != "us-east-1" {
		in := r.Params.(*CreateBucketInput)
		if in.CreateBucketConfiguration == nil {
			r.Params = awsutil.CopyOf(r.Params)
			in = r.Params.(*CreateBucketInput)
			in.CreateBucketConfiguration = &CreateBucketConfiguration{
				LocationConstraint: &r.Config.Region,
			}
		}
	}
}
開發者ID:worldspawn,項目名稱:vault,代碼行數:12,代碼來源:bucket_location.go

示例3: populateLocationConstraint

func populateLocationConstraint(r *request.Request) {
	if r.ParamsFilled() && aws.StringValue(r.Service.Config.Region) != "us-east-1" {
		in := r.Params.(*CreateBucketInput)
		if in.CreateBucketConfiguration == nil {
			r.Params = awsutil.CopyOf(r.Params)
			in = r.Params.(*CreateBucketInput)
			in.CreateBucketConfiguration = &CreateBucketConfiguration{
				LocationConstraint: r.Service.Config.Region,
			}
		}
	}
}
開發者ID:Celluliodio,項目名稱:flannel,代碼行數:12,代碼來源:bucket_location.go

示例4: NextPage

// NextPage returns a new Request that can be executed to return the next
// page of result data. Call .Send() on this request to execute it.
func (r *Request) NextPage() *Request {
	tokens := r.nextPageTokens()
	if tokens == nil {
		return nil
	}

	data := reflect.New(reflect.TypeOf(r.Data).Elem()).Interface()
	nr := NewRequest(r.Service, r.Operation, awsutil.CopyOf(r.Params), data)
	for i, intok := range nr.Operation.InputTokens {
		awsutil.SetValueAtAnyPath(nr.Params, intok, tokens[i])
	}
	return nr
}
開發者ID:lds-cf,項目名稱:go_service_broker,代碼行數:15,代碼來源:request.go

示例5: NextPage

// NextPage returns a new Request that can be executed to return the next
// page of result data. Call .Send() on this request to execute it.
func (r *Request) NextPage() *Request {
	tokens := r.nextPageTokens()
	if len(tokens) == 0 {
		return nil
	}

	data := reflect.New(reflect.TypeOf(r.Data).Elem()).Interface()
	nr := New(r.Config, r.ClientInfo, r.Handlers, r.Retryer, r.Operation, awsutil.CopyOf(r.Params), data)
	for i, intok := range nr.Operation.InputTokens {
		awsutil.SetValueAtPath(nr.Params, intok, tokens[i])
	}
	return nr
}
開發者ID:40a,項目名稱:bootkube,代碼行數:15,代碼來源:request_pagination.go

示例6: fillPresignedURL

func fillPresignedURL(r *request.Request) {
	if !r.ParamsFilled() {
		return
	}

	origParams := r.Params.(*CopySnapshotInput)

	// Stop if PresignedURL/DestinationRegion is set
	if origParams.PresignedUrl != nil || origParams.DestinationRegion != nil {
		return
	}

	origParams.DestinationRegion = r.Config.Region
	newParams := awsutil.CopyOf(r.Params).(*CopySnapshotInput)

	// Create a new request based on the existing request. We will use this to
	// presign the CopySnapshot request against the source region.
	cfg := r.Config.Copy(aws.NewConfig().
		WithEndpoint("").
		WithRegion(aws.StringValue(origParams.SourceRegion)))

	clientInfo := r.ClientInfo
	resolved, err := r.Config.EndpointResolver.EndpointFor(
		clientInfo.ServiceName, aws.StringValue(cfg.Region),
		func(opt *endpoints.Options) {
			opt.DisableSSL = aws.BoolValue(cfg.DisableSSL)
			opt.UseDualStack = aws.BoolValue(cfg.UseDualStack)
		},
	)
	if err != nil {
		r.Error = err
		return
	}

	clientInfo.Endpoint = resolved.URL
	clientInfo.SigningRegion = resolved.SigningRegion

	// Presign a CopySnapshot request with modified params
	req := request.New(*cfg, clientInfo, r.Handlers, r.Retryer, r.Operation, newParams, r.Data)
	url, err := req.Presign(5 * time.Minute) // 5 minutes should be enough.
	if err != nil {                          // bubble error back up to original request
		r.Error = err
		return
	}

	// We have our URL, set it on params
	origParams.PresignedUrl = &url
}
開發者ID:hooklift,項目名稱:terraform,代碼行數:48,代碼來源:customizations.go

示例7: TestCopyIgnoreNilMembers

func TestCopyIgnoreNilMembers(t *testing.T) {
	type Foo struct {
		A *string
	}

	f := &Foo{}
	assert.Nil(t, f.A)

	var f2 Foo
	awsutil.Copy(&f2, f)
	assert.Nil(t, f2.A)

	fcopy := awsutil.CopyOf(f)
	f3 := fcopy.(*Foo)
	assert.Nil(t, f3.A)
}
開發者ID:chenzhen411,項目名稱:kubernetes,代碼行數:16,代碼來源:copy_test.go

示例8: fillPresignedURL

func fillPresignedURL(r *aws.Request) {
	if !r.ParamsFilled() {
		return
	}

	params := r.Params.(*CopySnapshotInput)

	// Stop if PresignedURL/DestinationRegion is set
	if params.PresignedURL != nil || params.DestinationRegion != nil {
		return
	}

	// First generate a copy of parameters
	r.Params = awsutil.CopyOf(r.Params)
	params = r.Params.(*CopySnapshotInput)

	// Set destination region. Avoids infinite handler loop.
	// Also needed to sign sub-request.
	params.DestinationRegion = r.Service.Config.Region

	// Create a new client pointing at source region.
	// We will use this to presign the CopySnapshot request against
	// the source region
	config := r.Service.Config.Copy().
		WithEndpoint("").
		WithRegion(*params.SourceRegion)

	client := New(config)

	// Presign a CopySnapshot request with modified params
	req, _ := client.CopySnapshotRequest(params)
	url, err := req.Presign(300 * time.Second) // 5 minutes should be enough.

	if err != nil { // bubble error back up to original request
		r.Error = err
	}

	// We have our URL, set it on params
	params.PresignedURL = &url
}
開發者ID:Talos208,項目名稱:aws-sdk-go,代碼行數:40,代碼來源:customizations.go

示例9: ExampleCopyOf

func ExampleCopyOf() {
	type Foo struct {
		A int
		B []*string
	}

	// Create the initial value
	str1 := "hello"
	str2 := "bye bye"
	f1 := &Foo{A: 1, B: []*string{&str1, &str2}}

	// Do the copy
	v := awsutil.CopyOf(f1)
	var f2 *Foo = v.(*Foo)

	// Print the result
	fmt.Println(awsutil.Prettify(f2))

	// Output:
	// {
	//   A: 1,
	//   B: ["hello","bye bye"]
	// }
}
開發者ID:acquia,項目名稱:fifo2kinesis,代碼行數:24,代碼來源:copy_test.go

示例10: copyParams

func copyParams(r *request.Request) {
	r.Params = awsutil.CopyOf(r.Params)
}
開發者ID:charles-at-linknext,項目名稱:aws-sdk-go,代碼行數:3,代碼來源:customizations.go

示例11: copyParams

func copyParams(r *service.Request) {
	r.Params = awsutil.CopyOf(r.Params)
}
開發者ID:jkakar,項目名稱:aws-sdk-go,代碼行數:3,代碼來源:customizations.go


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