Skip to content

Commit

Permalink
Merge pull request #34302 from hashicorp/f-sso-endpoint
Browse files Browse the repository at this point in the history
provider: Adds SSO endpoint override
  • Loading branch information
gdavison authored Nov 9, 2023
2 parents a0e3a30 + 5247ce1 commit e61f339
Show file tree
Hide file tree
Showing 18 changed files with 685 additions and 511 deletions.
3 changes: 3 additions & 0 deletions .changelog/34302.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
provider: Adds SSO API endpoint override parameter `endpoints.sso`
```
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ require (
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.4.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.1 // indirect
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.23.0 // indirect
github.com/aws/aws-sdk-go-v2/service/iam v1.22.7 // indirect
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.25.0 // indirect
github.com/aws/aws-sdk-go-v2/service/iam v1.26.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.1 // indirect
Expand Down Expand Up @@ -208,3 +208,5 @@ exclude ( // Contains INI parsing regression
github.com/aws/aws-sdk-go-v2/internal/ini v1.5.0
github.com/aws/aws-sdk-go-v2/internal/ini v1.5.1
)

replace github.com/hashicorp/aws-sdk-go-base/v2 => github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.38.0.20231106231929-ee4c6bb6c5c8
19 changes: 6 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aws/aws-sdk-go v1.47.5 h1:U2JlfPmrUoz5p+2X/XwKxmaJFo2oV+LbJqx8jyEvyAY=
github.com/aws/aws-sdk-go v1.47.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go-v2 v1.21.2/go.mod h1:ErQhvNuEMhJjweavOYhxVkn2RUx7kQXVATHrjKtxIpM=
github.com/aws/aws-sdk-go-v2 v1.22.1 h1:sjnni/AuoTXxHitsIdT0FwmqUuNUuHtufcVDErVFT9U=
github.com/aws/aws-sdk-go-v2 v1.22.1/go.mod h1:Kd0OJtkW3Q0M0lUWGszapWjEvrXDzRW+D21JNsroB+c=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.0 h1:hHgLiIrTRtddC0AKcJr5s7i/hLgcpTt+q/FKxf1Zayk=
Expand All @@ -37,10 +36,8 @@ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.2 h1:gIeH4+o1MN/caGBWjoGQTUT
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.2/go.mod h1:wLyMIo/zPOhQhPXTddpfdkSleyigtFi8iMnC+2m/SK4=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.13.2 h1:XmPqt2VLMB7dfZ/cGNXBJOFq+Q+VsnEcPW3MqyKAsvY=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.13.2/go.mod h1:Y9RO68QWibKfkJpic8lh2G36x1eUJsAznj+1jiyYmsU=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43/go.mod h1:auo+PiyLl0n1l8A0e8RIeR8tOzYPfZZH/JNlrJ8igTQ=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.1 h1:fi1ga6WysOyYb5PAf3Exd6B5GiSNpnZim4h1rhlBqx0=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.1/go.mod h1:V5CY8wNurvPUibTi9mwqUqpiFZ5LnioKWIFUDtIzdI8=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37/go.mod h1:Qe+2KtKml+FEsQF/DHmDV+xjtche/hwoF75EG4UlHW8=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.1 h1:ZpaV/j48RlPc4AmOZuPv22pJliXjXq8/reL63YzyFnw=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.1/go.mod h1:R8aXraabD2e3qv1csxM14/X9WF4wFMIY0kH4YEtYD5M=
github.com/aws/aws-sdk-go-v2/internal/ini v1.4.0 h1:21tlTXq3ev10yLMAjXZzpkZbrl49h3ElSjmxD57tD/E=
Expand Down Expand Up @@ -81,8 +78,8 @@ github.com/aws/aws-sdk-go-v2/service/directoryservice v1.21.0 h1:d/E7xrw/NQnS2EB
github.com/aws/aws-sdk-go-v2/service/directoryservice v1.21.0/go.mod h1:ZGVwNAF49JrNO/ix2XMpuW2LaYrJiNHfxVO8wc/rGK0=
github.com/aws/aws-sdk-go-v2/service/docdbelastic v1.5.0 h1:REXrD/JZJba2fdv9JlQOBHKI+1PxWdENucMXEC70R+8=
github.com/aws/aws-sdk-go-v2/service/docdbelastic v1.5.0/go.mod h1:LV95B+6qbLHK2M9RiROoVIQMlZGz6vBhNqTxCzmiBgA=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.23.0 h1:xmSAn14nM6IdHyuWO/bsrAagOQtnqzuUCLxdVmj9nhg=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.23.0/go.mod h1:1HkLh8vaL4obF95fne7ZOu7sxomS/+vkBt3/+gqqwE4=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.25.0 h1:wAG9NailFhGhg8Ngg2YeCtzGmFWc63SYqJKdvN5ZMkE=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.25.0/go.mod h1:ByrosnNlEq6xkA0d+FwB4f0HH/5KWCcgBqVxAt+Rsps=
github.com/aws/aws-sdk-go-v2/service/ec2 v1.130.0 h1:a7CPCX/m+owAiAqcK8W9/SoB7EA4QUE4BddYdFyEGco=
github.com/aws/aws-sdk-go-v2/service/ec2 v1.130.0/go.mod h1:EJlGVMO5zynmSDdvwJfFa2RzAZoHI4gVJER0h82/dYk=
github.com/aws/aws-sdk-go-v2/service/eks v1.32.0 h1:w8O52S+rH0026BqntZs55OWbV8Huq8VhXL9bSixCRYc=
Expand All @@ -97,18 +94,16 @@ github.com/aws/aws-sdk-go-v2/service/glacier v1.18.0 h1:0H5luPEAxH6yTBYfXp5OkLeB
github.com/aws/aws-sdk-go-v2/service/glacier v1.18.0/go.mod h1:Vj8AdxwJpgnnxIa+P5SLWfnBTHk9vOIG8Gb6HJFUc5U=
github.com/aws/aws-sdk-go-v2/service/healthlake v1.19.0 h1:3XoTWx3VCcaOTKv93+8K+xCGO+RMyDCc0JdtLFO5+Ug=
github.com/aws/aws-sdk-go-v2/service/healthlake v1.19.0/go.mod h1:wg+/yWskCS48i+6HcLCbsDPKxcqFqXqSGtxe9/d/60s=
github.com/aws/aws-sdk-go-v2/service/iam v1.22.7 h1:hitc48qIZgl38TU33Gxi3V0blniZBDRbdExINJDZ9f8=
github.com/aws/aws-sdk-go-v2/service/iam v1.22.7/go.mod h1:d4c7P+mola/qBIgxgtVHK/w77vn+BlCsC/tbJ3m8m4Y=
github.com/aws/aws-sdk-go-v2/service/iam v1.26.0 h1:BGEB7NY0e0YZjrQBDN+2kj0ZZg/B5xNjyk0SUjeKuj8=
github.com/aws/aws-sdk-go-v2/service/iam v1.26.0/go.mod h1:K+kpOBBIGJKPAVdyzzCRR6ssqxpVG6SioxWi2/uWctk=
github.com/aws/aws-sdk-go-v2/service/identitystore v1.20.0 h1:M5pM4J4hNwm936JYdViZHIT8BiMdIFmOH3cwbHwPYPw=
github.com/aws/aws-sdk-go-v2/service/identitystore v1.20.0/go.mod h1:tLLFZFbSv06le/+pJJbbiIltpj53UjLxq3teIrs/xoU=
github.com/aws/aws-sdk-go-v2/service/inspector2 v1.19.0 h1:UvWXMuOsWVH8bP4f7i5afJZ5hmurXNNW/SeIZfVLNFQ=
github.com/aws/aws-sdk-go-v2/service/inspector2 v1.19.0/go.mod h1:U7Dpi+k+S9PPz9rzuCHQucZiiQxa5rhuBpZ7Um804iw=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.15/go.mod h1:26SQUPcTNgV1Tapwdt4a1rOsYRsnBsJHLMPoxK2b0d8=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.0 h1:CJxo7ZBbaIzmXfV3hjcx36n9V87gJsIUPJflwqEHl3Q=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.0/go.mod h1:yjVfjuY4nD1EW9i387Kau+I6V5cBA5YnC/mWNopjZrI=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.1 h1:15FUCJzAP9Y25nioTqTrGlZmhOtthaXBWlt4pS+d3Xo=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.1/go.mod h1:5655NW53Un6l7JzkI6AA3rZvf0m532cSnLThA1fVXcA=
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.37/go.mod h1:7xBUZyP6LeLc+5Ym9PG7atqw4sR28sBtYcHETik+bPE=
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.1 h1:aY45T0Xk+xHHrQPlQrp8IhrgN7k4SL5VF2UXhsmI2rs=
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.1/go.mod h1:5E/dXkj2ljMIAvuYaFuYwitKJg6ULwsDbUr3g8izVB0=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.1 h1:2OXw3ppu1XsB6rqKEMV4tnecTjIY3PRV2U6IP6KPJQo=
Expand Down Expand Up @@ -207,7 +202,6 @@ github.com/aws/aws-sdk-go-v2/service/workspaces v1.33.0 h1:DiZZM8fjwxhfCJz/bdlIh
github.com/aws/aws-sdk-go-v2/service/workspaces v1.33.0/go.mod h1:r7kckJ+/qarXPNSOyWgGNWt0+CUyyKGJTtEhAardDR0=
github.com/aws/aws-sdk-go-v2/service/xray v1.22.0 h1:j56f6+yYrQdrszG3yvkQXRFB7RgkpUM5V9x+/JqrhDo=
github.com/aws/aws-sdk-go-v2/service/xray v1.22.0/go.mod h1:A5GNo+DzE13RBklrS6+czyOZoTOQJ6v1j3yXGvYKqAQ=
github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/aws/smithy-go v1.16.0 h1:gJZEH/Fqh+RsvlJ1Zt4tVAtV6bKkp3cC+R6FCZMNzik=
github.com/aws/smithy-go v1.16.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE=
github.com/beevik/etree v1.2.0 h1:l7WETslUG/T+xOPs47dtd6jov2Ii/8/OjCldk5fYfQw=
Expand Down Expand Up @@ -257,7 +251,6 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand All @@ -267,8 +260,8 @@ github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/aws-cloudformation-resource-schema-sdk-go v0.21.0 h1:IUypt/TbXiJBkBbE3926CgnjD8IltAitdn7Yive61DY=
github.com/hashicorp/aws-cloudformation-resource-schema-sdk-go v0.21.0/go.mod h1:cdTE6F2pCKQobug+RqRaQp7Kz9hIEqiSvpPmb6E5G1w=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.38 h1:C5DvIFGNn7Lhu8SV6PAUY5WNq3aPYYqdnC4PT1tJc1o=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.38/go.mod h1:zjTe61MBV+nvdnW4MDP1NBFEC6qyCbYEd9tI0x8FY5s=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.38.0.20231106231929-ee4c6bb6c5c8 h1:9EQc7Lio5Mhc0dkQAz3Kb/qdv+5K5CfIE6Kp3i+Q69E=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.38.0.20231106231929-ee4c6bb6c5c8/go.mod h1:y1qchK9Ii0bpVNfofQIByA3vD7W+RG5x+lDIXhj2ITY=
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.39 h1:j8/73Sv9CATp6FKJJ+r2ghw8Yvq+nZSRqHYMxVUXGcM=
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.39/go.mod h1:9wIzp4fMm/Gra2/pWa9yL0vCN6VldCMDavcPUCUEdvI=
github.com/hashicorp/awspolicyequivalence v1.6.0 h1:7aadmkalbc5ewStC6g3rljx1iNvP4QyAhg2KsHx8bU8=
Expand Down
3 changes: 2 additions & 1 deletion internal/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWS
SecretKey: c.SecretKey,
SkipCredsValidation: c.SkipCredsValidation,
SkipRequestingAccountId: c.SkipRequestingAccountId,
SsoEndpoint: c.Endpoints[names.SSO],
StsEndpoint: c.Endpoints[names.STS],
SuppressDebugLog: c.SuppressDebugLog,
Token: c.Token,
Expand Down Expand Up @@ -174,7 +175,7 @@ func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWS
if accountID == "" {
diags = append(diags, errs.NewWarningDiagnostic(
"AWS account ID not found for provider",
"See https://www.terraform.io/docs/providers/aws/index.html#skip_requesting_account_id for implications."))
"See https://registry.terraform.io/providers/hashicorp/aws/latest/docs#skip_requesting_account_id for implications."))
}

err := awsbaseConfig.VerifyAccountIDAllowed(accountID)
Expand Down
14 changes: 11 additions & 3 deletions internal/errs/fwdiag/diags.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package fwdiag
import (
"errors"
"fmt"
"strings"

"github.com/hashicorp/terraform-plugin-framework/diag"
)
Expand All @@ -24,10 +25,17 @@ func DiagnosticsError(diags diag.Diagnostics) error {
// DiagnosticString formats a Diagnostic
// If there is no `Detail`, only prints summary, otherwise prints both
func DiagnosticString(d diag.Diagnostic) string {
if d.Detail() == "" {
return d.Summary()
var buf strings.Builder

fmt.Fprint(&buf, d.Summary())
if d.Detail() != "" {
fmt.Fprintf(&buf, "\n\n%s", d.Detail())
}
if withPath, ok := d.(diag.DiagnosticWithPath); ok {
fmt.Fprintf(&buf, "\n%s", withPath.Path().String())
}
return fmt.Sprintf("%s\n\n%s", d.Summary(), d.Detail())

return buf.String()
}

func NewResourceNotFoundWarningDiagnostic(err error) diag.Diagnostic {
Expand Down
47 changes: 44 additions & 3 deletions internal/errs/sdkdiag/diags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"strings"

"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
)
Expand Down Expand Up @@ -44,10 +45,50 @@ func DiagnosticsError(diags diag.Diagnostics) error {
// DiagnosticString formats a Diagnostic
// If there is no `Detail`, only prints summary, otherwise prints both
func DiagnosticString(d diag.Diagnostic) string {
if d.Detail == "" {
return d.Summary
var buf strings.Builder

fmt.Fprint(&buf, d.Summary)
if d.Detail != "" {
fmt.Fprintf(&buf, "\n\n%s", d.Detail)
}
if len(d.AttributePath) > 0 {
fmt.Fprintf(&buf, "\n%s", pathString(d.AttributePath))
}

return buf.String()
}

func pathString(path cty.Path) string {
var buf strings.Builder
for i, step := range path {
switch x := step.(type) {
case cty.GetAttrStep:
if i != 0 {
buf.WriteString(".")
}
buf.WriteString(x.Name)
case cty.IndexStep:
val := x.Key
typ := val.Type()
var s string
switch {
case typ == cty.String:
s = val.AsString()
case typ == cty.Number:
num := val.AsBigFloat()
s = num.String()
default:
s = fmt.Sprintf("<unexpected index: %s>", typ.FriendlyName())
}
buf.WriteString(fmt.Sprintf("[%s]", s))
default:
if i != 0 {
buf.WriteString(".")
}
buf.WriteString(fmt.Sprintf("<unexpected step: %[1]T %[1]v>", x))
}
}
return fmt.Sprintf("%s\n\n%s", d.Summary, d.Detail)
return buf.String()
}

// DiagnosticsString formats a Diagnostics
Expand Down
2 changes: 1 addition & 1 deletion internal/generate/checknames/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func main() {
}

if l[names.ColHumanFriendly] == "" {
log.Fatal("in names_data.csv, HumanFriendly cannot be blank")
log.Fatalf("in names_data.csv line %d, HumanFriendly cannot be blank", i+1)
}

// TODO: Check for duplicates in HumanFriendly, ProviderPackageActual,
Expand Down
54 changes: 5 additions & 49 deletions internal/generate/customends/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,23 @@ var header string
//go:embed custom_endpoints_footer.tmpl
var footer string

type ServiceDatum struct {
ProviderPackage string
Aliases []string
}

type TemplateData struct {
Services []ServiceDatum
Services []names.Endpoint
}

func main() {
const (
filename = `../../../website/docs/guides/custom-service-endpoints.html.markdown`
namesDataFile = "../../../names/names_data.csv"
filename = `../../../website/docs/guides/custom-service-endpoints.html.markdown`
)
g := common.NewGenerator()

g.Infof("Generating %s", strings.TrimPrefix(filename, "../../../"))

data, err := common.ReadAllCSVData(namesDataFile)

if err != nil {
g.Fatalf("error reading %s: %s", namesDataFile, err)
}

td := TemplateData{}

for i, l := range data {
if i < 1 { // no header
continue
}

if l[names.ColExclude] != "" {
continue
}

if l[names.ColNotImplemented] != "" {
continue
}

if l[names.ColProviderPackageActual] == "" && l[names.ColProviderPackageCorrect] == "" {
continue
}

p := l[names.ColProviderPackageCorrect]

if l[names.ColProviderPackageActual] != "" {
p = l[names.ColProviderPackageActual]
}

sd := ServiceDatum{
ProviderPackage: p,
}

if l[names.ColAliases] != "" {
sd.Aliases = strings.Split(l[names.ColAliases], ";")
}

td.Services = append(td.Services, sd)
td := TemplateData{
Services: names.Endpoints(),
}

sort.SliceStable(td.Services, func(i, j int) bool {
sort.Slice(td.Services, func(i, j int) bool {
return td.Services[i].ProviderPackage < td.Services[j].ProviderPackage
})

Expand Down
49 changes: 5 additions & 44 deletions internal/generate/namesconsts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,23 @@ import (
"github.com/hashicorp/terraform-provider-aws/names"
)

type ServiceDatum struct {
ProviderNameUpper string
ProviderPackage string
}

type TemplateData struct {
Services []ServiceDatum
Services []names.ServiceNameUpper
}

func main() {
const (
filename = `consts_gen.go`
namesDataFile = "names_data.csv"
filename = `consts_gen.go`
)
g := common.NewGenerator()

g.Infof("Generating names/%s", filename)

data, err := common.ReadAllCSVData(namesDataFile)

if err != nil {
g.Fatalf("error reading %s: %s", namesDataFile, err)
}

td := TemplateData{}

for i, l := range data {
if i < 1 { // no header
continue
}

if l[names.ColExclude] != "" {
continue
}

if l[names.ColNotImplemented] != "" {
continue
}

if l[names.ColProviderPackageActual] == "" && l[names.ColProviderPackageCorrect] == "" {
continue
}

p := l[names.ColProviderPackageCorrect]

if l[names.ColProviderPackageActual] != "" {
p = l[names.ColProviderPackageActual]
}

td.Services = append(td.Services, ServiceDatum{
ProviderNameUpper: l[names.ColProviderNameUpper],
ProviderPackage: p,
})
td := TemplateData{
Services: names.ServiceNamesUpper(),
}

sort.SliceStable(td.Services, func(i, j int) bool {
sort.Slice(td.Services, func(i, j int) bool {
return td.Services[i].ProviderNameUpper < td.Services[j].ProviderNameUpper
})

Expand Down
Loading

0 comments on commit e61f339

Please sign in to comment.