Skip to content

Commit e508b9c

Browse files
committed
[ignore] Added IPv6 custom type code and updated the aci_epg_useg_ip_attribute for the verification
1 parent f2533f9 commit e508b9c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+336
-19
lines changed

gen/definitions/properties/fvIpAttr.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ test_values:
2626
resource_required:
2727
ip: 131.107.1.200
2828
name: "131"
29+
custom_type:
30+
ip: fe80::0002
31+
static_custom_type:
32+
ip: ipv6_address

gen/generator.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const pubhupDevnetBaseUrl = "https://pubhub.devnetcloud.com/media/model-doc-late
7979

8080
var staticCustomTypeMap = map[string]string{
8181
"rounded_percentage": "RoundedPercentage",
82+
"ipv6_address": "IPv6Address",
8283
}
8384

8485
// Function map used during template rendering in order to call functions from the template
@@ -1168,7 +1169,7 @@ func cleanDirectories() {
11681169
cleanDirectory(resourcesDocsPath, []string{})
11691170
cleanDirectory(datasourcesDocsPath, []string{"system.md"})
11701171
cleanDirectory(testVarsPath, []string{})
1171-
cleanDirectory("./internal/custom_types", []string{"roundedPercentage.go"})
1172+
cleanDirectory("./internal/custom_types", []string{"roundedPercentage.go", "ipv6Address.go"})
11721173

11731174
// The *ExamplesPath directories are removed and recreated to ensure all previously rendered files are removed
11741175
// The provider example file is not removed because it contains static provider configuration
@@ -1559,6 +1560,7 @@ type Property struct {
15591560
HasCustomType bool
15601561
IncludeInCustomTypeTest bool
15611562
StaticCustomType string
1563+
ValidateAsIPv4OrIPv6 bool
15621564
}
15631565

15641566
// A Definitions represents the ACI class and property definitions as defined in the definitions YAML files
@@ -2138,6 +2140,10 @@ func (m *Model) SetClassProperties(classDetails interface{}) {
21382140
HasCustomType: false,
21392141
}
21402142

2143+
if propertyValue.(map[string]interface{})["validateAsIPv4OrIPv6"] != nil {
2144+
property.ValidateAsIPv4OrIPv6 = propertyValue.(map[string]interface{})["validateAsIPv4OrIPv6"].(bool)
2145+
}
2146+
21412147
if requiredProperty(GetOverwriteAttributeName(m.PkgName, propertyName, m.Definitions), m.PkgName, m.Definitions) || property.IsNaming {
21422148
property.IsRequired = true
21432149
requiredCount += 1

gen/templates/custom_type.go.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Code generated by "gen/generator.go"; DO NOT EDIT.
2+
// In order to regenerate this file execute `go generate` from the repository root.
3+
// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md).
4+
15
package customTypes
26

37
import (

gen/templates/resource.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc
16411641
{{- if eq .Name "Annotation"}}
16421642
Default: stringdefault.StaticString(globalAnnotation),
16431643
{{- end}}
1644-
{{- if .HasCustomType}}
1644+
{{- if and .HasCustomType (not .ValidateAsIPv4OrIPv6) }}
16451645
Validators: []validator.String{
16461646
stringvalidator.Any(
16471647
{{- if .ValidValues}}

gen/templates/resource.md.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ All examples for the {{.ResourceNameAsDescription}} resource can be found in the
7777
{{- range .Properties}}
7878
{{- if or .IsNaming .IsRequired}}
7979
* `{{- overwriteProperty .PkgName .SnakeCaseName $.Definitions}}` ({{- .PropertyName}}) - (string) {{.Comment}}{{if ne .NamedPropertyClass ""}}{{$RName := getResourceName .NamedPropertyClass $.Definitions}} This attribute can be referenced from a [resource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/{{$RName}}) with `aci_{{$RName}}.example.name` or from a [datasource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/data-sources/{{$RName}}) with `data.aci_{{$RName}}.example.name`.{{end}}{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}}
80-
{{- if and .HasCustomType (hasCustomTypeDocs .PkgName .Name $.Definitions)}}{{$i := 1}}{{$length := len .ValidValues}}
80+
{{- if and .HasCustomType (hasCustomTypeDocs .PkgName .Name $.Definitions) (not .ValidateAsIPv4OrIPv6) }}{{$i := 1}}{{$length := len .ValidValues}}
8181
- Valid Values:
8282
{{- if .ValidValues}}
8383
*{{ range .ValidValues}} `"{{ . }}"`{{ if ne $length $i}}{{$i = add $i 1}}, {{- else}}.{{- end}}{{- end}}
@@ -143,7 +143,7 @@ All examples for the {{.ResourceNameAsDescription}} resource can be found in the
143143
- Default: `"{{ .DefaultValue }}"`
144144
{{- end}}
145145
{{- end}}
146-
{{- if and .HasCustomType (hasCustomTypeDocs .PkgName .Name $.Definitions)}}{{$i := 1}}{{$length := len .ValidValues}}
146+
{{- if and .HasCustomType (hasCustomTypeDocs .PkgName .Name $.Definitions) (not .ValidateAsIPv4OrIPv6) }}{{$i := 1}}{{$length := len .ValidValues}}
147147
- Valid Values:
148148
{{- if .ValidValues}}
149149
*{{ range .ValidValues}} `"{{ . }}"`{{ if ne $length $i}}{{$i = add $i 1}}, {{- else}}.{{- end}}{{- end}}

gen/testvars/fvIpAttr.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ resource_required:
2222
ip: "131.107.1.200"
2323
name: "131"
2424

25+
custom_type:
26+
ip: "fe80::0002"
27+
name: "131"
28+
2529
all:
2630
annotation: "annotation"
2731
description: "description_1"

internal/custom_types/dwdmIfPol_fcotChannelNumber.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/custom_types/fvAEPg_prio.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/custom_types/fvAp_prio.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/custom_types/fvRsConsIf_prio.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)