|
14 | 14 | package code_test |
15 | 15 |
|
16 | 16 | import ( |
17 | | - "fmt" |
18 | 17 | "testing" |
19 | 18 |
|
20 | 19 | "github.com/stretchr/testify/assert" |
@@ -4482,7 +4481,6 @@ func TestSetSDK_Lambda_Function_EnvironmentVariable_MapOfSecrets_Create(t *testi |
4482 | 4481 | } |
4483 | 4482 | ` |
4484 | 4483 | actual := code.SetSDK(crd.Config(), crd, model.OpTypeCreate, "r.ko", "res", 1) |
4485 | | - fmt.Print(actual) |
4486 | 4484 |
|
4487 | 4485 | assert.Equal(expected, actual) |
4488 | 4486 | } |
@@ -4652,3 +4650,224 @@ func TestSetSDK_Lambda_Function_EnvironmentVariable_MapOfSecrets_Update(t *testi |
4652 | 4650 |
|
4653 | 4651 | assert.Equal(expected, actual) |
4654 | 4652 | } |
| 4653 | + |
| 4654 | +func TestSetSDK_MQ_Broker_Configuration_Nested_Set_To(t *testing.T) { |
| 4655 | + assert := assert.New(t) |
| 4656 | + require := require.New(t) |
| 4657 | + |
| 4658 | + firehoseModel := testutil.NewModelForServiceWithOptions(t, "firehose", &testutil.TestingModelOptions{ |
| 4659 | + GeneratorConfigFile: "generator-set-for-nested-field.yaml", |
| 4660 | + }) |
| 4661 | + |
| 4662 | + crd := testutil.GetCRDByName(t, firehoseModel, "DeliveryStream") |
| 4663 | + require.NotNil(crd) |
| 4664 | + |
| 4665 | + expected := ` |
| 4666 | + if r.ko.Spec.DeliveryStreamName != nil { |
| 4667 | + res.DeliveryStreamName = r.ko.Spec.DeliveryStreamName |
| 4668 | + } |
| 4669 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration != nil { |
| 4670 | + f7 := &svcsdktypes.HttpEndpointDestinationUpdate{} |
| 4671 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.BufferingHints != nil { |
| 4672 | + f7f0 := &svcsdktypes.HttpEndpointBufferingHints{} |
| 4673 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.BufferingHints.IntervalInSeconds != nil { |
| 4674 | + intervalInSecondsCopy0 := *r.ko.Spec.HTTPEndpointDestinationConfiguration.BufferingHints.IntervalInSeconds |
| 4675 | + if intervalInSecondsCopy0 > math.MaxInt32 || intervalInSecondsCopy0 < math.MinInt32 { |
| 4676 | + return nil, fmt.Errorf("error: field IntervalInSeconds is of type int32") |
| 4677 | + } |
| 4678 | + intervalInSecondsCopy := int32(intervalInSecondsCopy0) |
| 4679 | + f7f0.IntervalInSeconds = &intervalInSecondsCopy |
| 4680 | + } |
| 4681 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.BufferingHints.SizeInMBs != nil { |
| 4682 | + sizeInMBsCopy0 := *r.ko.Spec.HTTPEndpointDestinationConfiguration.BufferingHints.SizeInMBs |
| 4683 | + if sizeInMBsCopy0 > math.MaxInt32 || sizeInMBsCopy0 < math.MinInt32 { |
| 4684 | + return nil, fmt.Errorf("error: field SizeInMBs is of type int32") |
| 4685 | + } |
| 4686 | + sizeInMBsCopy := int32(sizeInMBsCopy0) |
| 4687 | + f7f0.SizeInMBs = &sizeInMBsCopy |
| 4688 | + } |
| 4689 | + f7.BufferingHints = f7f0 |
| 4690 | + } |
| 4691 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.CloudWatchLoggingOptions != nil { |
| 4692 | + f7f1 := &svcsdktypes.CloudWatchLoggingOptions{} |
| 4693 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.CloudWatchLoggingOptions.Enabled != nil { |
| 4694 | + f7f1.Enabled = r.ko.Spec.HTTPEndpointDestinationConfiguration.CloudWatchLoggingOptions.Enabled |
| 4695 | + } |
| 4696 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.CloudWatchLoggingOptions.LogGroupName != nil { |
| 4697 | + f7f1.LogGroupName = r.ko.Spec.HTTPEndpointDestinationConfiguration.CloudWatchLoggingOptions.LogGroupName |
| 4698 | + } |
| 4699 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.CloudWatchLoggingOptions.LogStreamName != nil { |
| 4700 | + f7f1.LogStreamName = r.ko.Spec.HTTPEndpointDestinationConfiguration.CloudWatchLoggingOptions.LogStreamName |
| 4701 | + } |
| 4702 | + f7.CloudWatchLoggingOptions = f7f1 |
| 4703 | + } |
| 4704 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.EndpointConfiguration != nil { |
| 4705 | + f7f2 := &svcsdktypes.HttpEndpointConfiguration{} |
| 4706 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.EndpointConfiguration.AccessKey != nil { |
| 4707 | + f7f2.AccessKey = r.ko.Spec.HTTPEndpointDestinationConfiguration.EndpointConfiguration.AccessKey |
| 4708 | + } |
| 4709 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.EndpointConfiguration.Name != nil { |
| 4710 | + f7f2.Name = r.ko.Spec.HTTPEndpointDestinationConfiguration.EndpointConfiguration.Name |
| 4711 | + } |
| 4712 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.EndpointConfiguration.URL != nil { |
| 4713 | + f7f2.Url = r.ko.Spec.HTTPEndpointDestinationConfiguration.EndpointConfiguration.URL |
| 4714 | + } |
| 4715 | + f7.EndpointConfiguration = f7f2 |
| 4716 | + } |
| 4717 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.ProcessingConfiguration != nil { |
| 4718 | + f7f3 := &svcsdktypes.ProcessingConfiguration{} |
| 4719 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.ProcessingConfiguration.Enabled != nil { |
| 4720 | + f7f3.Enabled = r.ko.Spec.HTTPEndpointDestinationConfiguration.ProcessingConfiguration.Enabled |
| 4721 | + } |
| 4722 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.ProcessingConfiguration.Processors != nil { |
| 4723 | + f7f3f1 := []svcsdktypes.Processor{} |
| 4724 | + for _, f7f3f1iter := range r.ko.Spec.HTTPEndpointDestinationConfiguration.ProcessingConfiguration.Processors { |
| 4725 | + f7f3f1elem := &svcsdktypes.Processor{} |
| 4726 | + if f7f3f1iter.Parameters != nil { |
| 4727 | + f7f3f1elemf0 := []svcsdktypes.ProcessorParameter{} |
| 4728 | + for _, f7f3f1elemf0iter := range f7f3f1iter.Parameters { |
| 4729 | + f7f3f1elemf0elem := &svcsdktypes.ProcessorParameter{} |
| 4730 | + if f7f3f1elemf0iter.ParameterName != nil { |
| 4731 | + f7f3f1elemf0elem.ParameterName = svcsdktypes.ProcessorParameterName(*f7f3f1elemf0iter.ParameterName) |
| 4732 | + } |
| 4733 | + if f7f3f1elemf0iter.ParameterValue != nil { |
| 4734 | + f7f3f1elemf0elem.ParameterValue = f7f3f1elemf0iter.ParameterValue |
| 4735 | + } |
| 4736 | + f7f3f1elemf0 = append(f7f3f1elemf0, *f7f3f1elemf0elem) |
| 4737 | + } |
| 4738 | + f7f3f1elem.Parameters = f7f3f1elemf0 |
| 4739 | + } |
| 4740 | + if f7f3f1iter.Type != nil { |
| 4741 | + f7f3f1elem.Type = svcsdktypes.ProcessorType(*f7f3f1iter.Type) |
| 4742 | + } |
| 4743 | + f7f3f1 = append(f7f3f1, *f7f3f1elem) |
| 4744 | + } |
| 4745 | + f7f3.Processors = f7f3f1 |
| 4746 | + } |
| 4747 | + f7.ProcessingConfiguration = f7f3 |
| 4748 | + } |
| 4749 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.RequestConfiguration != nil { |
| 4750 | + f7f4 := &svcsdktypes.HttpEndpointRequestConfiguration{} |
| 4751 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.RequestConfiguration.CommonAttributes != nil { |
| 4752 | + f7f4f0 := []svcsdktypes.HttpEndpointCommonAttribute{} |
| 4753 | + for _, f7f4f0iter := range r.ko.Spec.HTTPEndpointDestinationConfiguration.RequestConfiguration.CommonAttributes { |
| 4754 | + f7f4f0elem := &svcsdktypes.HttpEndpointCommonAttribute{} |
| 4755 | + if f7f4f0iter.AttributeName != nil { |
| 4756 | + f7f4f0elem.AttributeName = f7f4f0iter.AttributeName |
| 4757 | + } |
| 4758 | + if f7f4f0iter.AttributeValue != nil { |
| 4759 | + f7f4f0elem.AttributeValue = f7f4f0iter.AttributeValue |
| 4760 | + } |
| 4761 | + f7f4f0 = append(f7f4f0, *f7f4f0elem) |
| 4762 | + } |
| 4763 | + f7f4.CommonAttributes = f7f4f0 |
| 4764 | + } |
| 4765 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.RequestConfiguration.ContentEncoding != nil { |
| 4766 | + f7f4.ContentEncoding = svcsdktypes.ContentEncoding(*r.ko.Spec.HTTPEndpointDestinationConfiguration.RequestConfiguration.ContentEncoding) |
| 4767 | + } |
| 4768 | + f7.RequestConfiguration = f7f4 |
| 4769 | + } |
| 4770 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.RetryOptions != nil { |
| 4771 | + f7f5 := &svcsdktypes.HttpEndpointRetryOptions{} |
| 4772 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.RetryOptions.DurationInSeconds != nil { |
| 4773 | + durationInSecondsCopy0 := *r.ko.Spec.HTTPEndpointDestinationConfiguration.RetryOptions.DurationInSeconds |
| 4774 | + if durationInSecondsCopy0 > math.MaxInt32 || durationInSecondsCopy0 < math.MinInt32 { |
| 4775 | + return nil, fmt.Errorf("error: field DurationInSeconds is of type int32") |
| 4776 | + } |
| 4777 | + durationInSecondsCopy := int32(durationInSecondsCopy0) |
| 4778 | + f7f5.DurationInSeconds = &durationInSecondsCopy |
| 4779 | + } |
| 4780 | + f7.RetryOptions = f7f5 |
| 4781 | + } |
| 4782 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.RoleARN != nil { |
| 4783 | + f7.RoleARN = r.ko.Spec.HTTPEndpointDestinationConfiguration.RoleARN |
| 4784 | + } |
| 4785 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3BackupMode != nil { |
| 4786 | + f7.S3BackupMode = svcsdktypes.HttpEndpointS3BackupMode(*r.ko.Spec.HTTPEndpointDestinationConfiguration.S3BackupMode) |
| 4787 | + } |
| 4788 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration != nil { |
| 4789 | + f7f8 := &svcsdktypes.S3DestinationUpdate{} |
| 4790 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.BucketARN != nil { |
| 4791 | + f7f8.BucketARN = r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.BucketARN |
| 4792 | + } |
| 4793 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.BufferingHints != nil { |
| 4794 | + f7f8f1 := &svcsdktypes.BufferingHints{} |
| 4795 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.BufferingHints.IntervalInSeconds != nil { |
| 4796 | + intervalInSecondsCopy0 := *r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.BufferingHints.IntervalInSeconds |
| 4797 | + if intervalInSecondsCopy0 > math.MaxInt32 || intervalInSecondsCopy0 < math.MinInt32 { |
| 4798 | + return nil, fmt.Errorf("error: field IntervalInSeconds is of type int32") |
| 4799 | + } |
| 4800 | + intervalInSecondsCopy := int32(intervalInSecondsCopy0) |
| 4801 | + f7f8f1.IntervalInSeconds = &intervalInSecondsCopy |
| 4802 | + } |
| 4803 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.BufferingHints.SizeInMBs != nil { |
| 4804 | + sizeInMBsCopy0 := *r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.BufferingHints.SizeInMBs |
| 4805 | + if sizeInMBsCopy0 > math.MaxInt32 || sizeInMBsCopy0 < math.MinInt32 { |
| 4806 | + return nil, fmt.Errorf("error: field SizeInMBs is of type int32") |
| 4807 | + } |
| 4808 | + sizeInMBsCopy := int32(sizeInMBsCopy0) |
| 4809 | + f7f8f1.SizeInMBs = &sizeInMBsCopy |
| 4810 | + } |
| 4811 | + f7f8.BufferingHints = f7f8f1 |
| 4812 | + } |
| 4813 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.CloudWatchLoggingOptions != nil { |
| 4814 | + f7f8f2 := &svcsdktypes.CloudWatchLoggingOptions{} |
| 4815 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.CloudWatchLoggingOptions.Enabled != nil { |
| 4816 | + f7f8f2.Enabled = r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.CloudWatchLoggingOptions.Enabled |
| 4817 | + } |
| 4818 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.CloudWatchLoggingOptions.LogGroupName != nil { |
| 4819 | + f7f8f2.LogGroupName = r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.CloudWatchLoggingOptions.LogGroupName |
| 4820 | + } |
| 4821 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.CloudWatchLoggingOptions.LogStreamName != nil { |
| 4822 | + f7f8f2.LogStreamName = r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.CloudWatchLoggingOptions.LogStreamName |
| 4823 | + } |
| 4824 | + f7f8.CloudWatchLoggingOptions = f7f8f2 |
| 4825 | + } |
| 4826 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.CompressionFormat != nil { |
| 4827 | + f7f8.CompressionFormat = svcsdktypes.CompressionFormat(*r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.CompressionFormat) |
| 4828 | + } |
| 4829 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.EncryptionConfiguration != nil { |
| 4830 | + f7f8f4 := &svcsdktypes.EncryptionConfiguration{} |
| 4831 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.EncryptionConfiguration.KMSEncryptionConfig != nil { |
| 4832 | + f7f8f4f0 := &svcsdktypes.KMSEncryptionConfig{} |
| 4833 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.EncryptionConfiguration.KMSEncryptionConfig.AWSKMSKeyARN != nil { |
| 4834 | + f7f8f4f0.AWSKMSKeyARN = r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.EncryptionConfiguration.KMSEncryptionConfig.AWSKMSKeyARN |
| 4835 | + } |
| 4836 | + f7f8f4.KMSEncryptionConfig = f7f8f4f0 |
| 4837 | + } |
| 4838 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.EncryptionConfiguration.NoEncryptionConfig != nil { |
| 4839 | + f7f8f4.NoEncryptionConfig = svcsdktypes.NoEncryptionConfig(*r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.EncryptionConfiguration.NoEncryptionConfig) |
| 4840 | + } |
| 4841 | + f7f8.EncryptionConfiguration = f7f8f4 |
| 4842 | + } |
| 4843 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.ErrorOutputPrefix != nil { |
| 4844 | + f7f8.ErrorOutputPrefix = r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.ErrorOutputPrefix |
| 4845 | + } |
| 4846 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.Prefix != nil { |
| 4847 | + f7f8.Prefix = r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.Prefix |
| 4848 | + } |
| 4849 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.RoleARN != nil { |
| 4850 | + f7f8.RoleARN = r.ko.Spec.HTTPEndpointDestinationConfiguration.S3Configuration.RoleARN |
| 4851 | + } |
| 4852 | + f7.S3Update = f7f8 |
| 4853 | + } |
| 4854 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.SecretsManagerConfiguration != nil { |
| 4855 | + f7f9 := &svcsdktypes.SecretsManagerConfiguration{} |
| 4856 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.SecretsManagerConfiguration.Enabled != nil { |
| 4857 | + f7f9.Enabled = r.ko.Spec.HTTPEndpointDestinationConfiguration.SecretsManagerConfiguration.Enabled |
| 4858 | + } |
| 4859 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.SecretsManagerConfiguration.RoleARN != nil { |
| 4860 | + f7f9.RoleARN = r.ko.Spec.HTTPEndpointDestinationConfiguration.SecretsManagerConfiguration.RoleARN |
| 4861 | + } |
| 4862 | + if r.ko.Spec.HTTPEndpointDestinationConfiguration.SecretsManagerConfiguration.SecretARN != nil { |
| 4863 | + f7f9.SecretARN = r.ko.Spec.HTTPEndpointDestinationConfiguration.SecretsManagerConfiguration.SecretARN |
| 4864 | + } |
| 4865 | + f7.SecretsManagerConfiguration = f7f9 |
| 4866 | + } |
| 4867 | + res.HttpEndpointDestinationUpdate = f7 |
| 4868 | + } |
| 4869 | +` |
| 4870 | + actual := code.SetSDK(crd.Config(), crd, model.OpTypeUpdate, "r.ko", "res", 1) |
| 4871 | + |
| 4872 | + assert.Equal(expected, actual) |
| 4873 | +} |
0 commit comments