Skip to content

Commit 84c762d

Browse files
Merge branch 'hashicorp:main' into feature/application-conditional-filter
2 parents 7d1d56e + 0d6e12c commit 84c762d

File tree

23 files changed

+585
-435
lines changed

23 files changed

+585
-435
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 2.48.0 (April 11, 2024)
2+
3+
ENHANCEMENTS:
4+
5+
* dependencies: updating to `v0.20240411.1104331` of `github.com/hashicorp/go-azure-sdk/sdk` ([#1353](https://github.com/hashicorp/terraform-provider-azuread/issues/1353))
6+
7+
BUG FIXES:
8+
9+
* provider: fix an issue where the provider was not correctly configured when using a custom metadata host ([#1353](https://github.com/hashicorp/terraform-provider-azuread/issues/1353))
10+
111
## 2.47.0 (December 14, 2023)
212

313
BUG FIXES:

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module github.com/hashicorp/terraform-provider-azuread
22

33
require (
44
github.com/google/go-cmp v0.5.9
5-
github.com/hashicorp/go-azure-helpers v0.66.1
6-
github.com/hashicorp/go-azure-sdk/sdk v0.20240125.1122928
5+
github.com/hashicorp/go-azure-helpers v0.66.2
6+
github.com/hashicorp/go-azure-sdk/sdk v0.20240411.1104331
77
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
88
github.com/hashicorp/go-multierror v1.1.1
99
github.com/hashicorp/go-uuid v1.0.3

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
4949
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
5050
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
5151
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
52-
github.com/hashicorp/go-azure-helpers v0.66.1 h1:SokAckK9hvQ9PZO2TmZY/CGru8KWJ4A7hcRUggHMEus=
53-
github.com/hashicorp/go-azure-helpers v0.66.1/go.mod h1:kJxXrFtJKJdOEqvad8pllAe7dhP4DbN8J6sqFZe47+4=
54-
github.com/hashicorp/go-azure-sdk/sdk v0.20240125.1122928 h1:RzRXiA9rVdERF7Y4ELqcaqlbM7oyqizqKu7+CfLVzZY=
55-
github.com/hashicorp/go-azure-sdk/sdk v0.20240125.1122928/go.mod h1:6jgkzx26qtPndLSW5u7pKIw4m3iiFiLnHlp7yDQ2Crc=
52+
github.com/hashicorp/go-azure-helpers v0.66.2 h1:+Pzuo7pdKl0hBXXr5ymmhs4Q40tHAo2nAvHq4WgSjx8=
53+
github.com/hashicorp/go-azure-helpers v0.66.2/go.mod h1:kJxXrFtJKJdOEqvad8pllAe7dhP4DbN8J6sqFZe47+4=
54+
github.com/hashicorp/go-azure-sdk/sdk v0.20240411.1104331 h1:LYQI0A1rWPjrMa0J8N8MA5ZjFfHNaVpoPY1vmzrS/C8=
55+
github.com/hashicorp/go-azure-sdk/sdk v0.20240411.1104331/go.mod h1:POOjeoqNp+mvlLBuibJTziUAkBZ7FxXGeGestwemL/w=
5656
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
5757
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
5858
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=

internal/acceptance/testclient/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func Build(tenantId string) (*clients.Client, error) {
3838
}
3939

4040
if metadataHost != "" {
41-
if env, err = environments.FromEndpoint(ctx, fmt.Sprintf("https://%s", metadataHost), envName); err != nil {
41+
if env, err = environments.FromEndpoint(ctx, fmt.Sprintf("https://%s", metadataHost)); err != nil {
4242
return nil, fmt.Errorf("building test client: %+v", err)
4343
}
4444
} else if env, err = environments.FromName(envName); err != nil {

internal/acceptance/testing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func GetAuthConfig(t *testing.T) *auth.Credentials {
5656
)
5757

5858
if metadataHost != "" {
59-
if env, err = environments.FromEndpoint(ctx, fmt.Sprintf("https://%s", metadataHost), envName); err != nil {
59+
if env, err = environments.FromEndpoint(ctx, fmt.Sprintf("https://%s", metadataHost)); err != nil {
6060
t.Fatalf("building test client: %+v", err)
6161
return nil
6262
}

internal/provider/helpers.go

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package provider
2+
3+
import (
4+
"encoding/base64"
5+
"fmt"
6+
"log"
7+
"os"
8+
"strings"
9+
10+
"github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk"
11+
)
12+
13+
// logEntry avoids log entries showing up in test output
14+
func logEntry(f string, v ...interface{}) {
15+
if os.Getenv("TF_LOG") == "" {
16+
return
17+
}
18+
19+
if os.Getenv("TF_ACC") != "" {
20+
return
21+
}
22+
23+
log.Printf(f, v...)
24+
}
25+
26+
func decodeCertificate(clientCertificate string) ([]byte, error) {
27+
var pfx []byte
28+
if clientCertificate != "" {
29+
out := make([]byte, base64.StdEncoding.DecodedLen(len(clientCertificate)))
30+
n, err := base64.StdEncoding.Decode(out, []byte(clientCertificate))
31+
if err != nil {
32+
return pfx, fmt.Errorf("could not decode client certificate data: %v", err)
33+
}
34+
pfx = out[:n]
35+
}
36+
return pfx, nil
37+
}
38+
39+
func getOidcToken(d *pluginsdk.ResourceData) (*string, error) {
40+
idToken := d.Get("oidc_token").(string)
41+
42+
if path := d.Get("oidc_token_file_path").(string); path != "" {
43+
fileTokenRaw, err := os.ReadFile(path)
44+
45+
if err != nil {
46+
return nil, fmt.Errorf("reading OIDC Token from file %q: %v", path, err)
47+
}
48+
49+
fileToken := strings.TrimSpace(string(fileTokenRaw))
50+
51+
if idToken != "" && idToken != fileToken {
52+
return nil, fmt.Errorf("mismatch between supplied OIDC token and supplied OIDC token file contents - please either remove one or ensure they match")
53+
}
54+
55+
idToken = fileToken
56+
}
57+
58+
return &idToken, nil
59+
}
60+
61+
func getClientId(d *pluginsdk.ResourceData) (*string, error) {
62+
clientId := strings.TrimSpace(d.Get("client_id").(string))
63+
64+
if path := d.Get("client_id_file_path").(string); path != "" {
65+
fileClientIdRaw, err := os.ReadFile(path)
66+
67+
if err != nil {
68+
return nil, fmt.Errorf("reading Client ID from file %q: %v", path, err)
69+
}
70+
71+
fileClientId := strings.TrimSpace(string(fileClientIdRaw))
72+
73+
if clientId != "" && clientId != fileClientId {
74+
return nil, fmt.Errorf("mismatch between supplied Client ID and supplied Client ID file contents - please either remove one or ensure they match")
75+
}
76+
77+
clientId = fileClientId
78+
}
79+
80+
return &clientId, nil
81+
}
82+
83+
func getClientSecret(d *pluginsdk.ResourceData) (*string, error) {
84+
clientSecret := strings.TrimSpace(d.Get("client_secret").(string))
85+
86+
if path := d.Get("client_secret_file_path").(string); path != "" {
87+
fileSecretRaw, err := os.ReadFile(path)
88+
89+
if err != nil {
90+
return nil, fmt.Errorf("reading Client Secret from file %q: %v", path, err)
91+
}
92+
93+
fileSecret := strings.TrimSpace(string(fileSecretRaw))
94+
95+
if clientSecret != "" && clientSecret != fileSecret {
96+
return nil, fmt.Errorf("mismatch between supplied Client Secret and supplied Client Secret file contents - please either remove one or ensure they match")
97+
}
98+
99+
clientSecret = fileSecret
100+
}
101+
102+
return &clientSecret, nil
103+
}
104+
105+
func getTenantId(d *pluginsdk.ResourceData) (*string, error) {
106+
tenantId := strings.TrimSpace(d.Get("tenant_id").(string))
107+
108+
if d.Get("use_aks_workload_identity").(bool) && os.Getenv("AZURE_TENANT_ID") != "" {
109+
aksTenantId := os.Getenv("AZURE_TENANT_ID")
110+
if tenantId != "" && tenantId != aksTenantId {
111+
return nil, fmt.Errorf("mismatch between supplied Tenant ID and that provided by AKS Workload Identity - please remove, ensure they match, or disable use_aks_workload_identity")
112+
}
113+
tenantId = aksTenantId
114+
}
115+
116+
return &tenantId, nil
117+
}

0 commit comments

Comments
 (0)