@@ -11,6 +11,7 @@ import (
11
11
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
12
12
"github.com/hashicorp/terraform-plugin-framework/resource"
13
13
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
14
+ "github.com/hashicorp/terraform-plugin-framework/types"
14
15
"github.com/knowledge-work/terraform-provider-kw-github/internal/githubclient"
15
16
)
16
17
@@ -72,13 +73,13 @@ func (p *kwgithubProvider) Schema(_ context.Context, _ provider.SchemaRequest, r
72
73
73
74
func (p * kwgithubProvider ) Configure (ctx context.Context , req provider.ConfigureRequest , resp * provider.ConfigureResponse ) {
74
75
var config struct {
75
- Token string `tfsdk:"token"`
76
- Owner string `tfsdk:"owner"`
77
- GithubBaseURL string `tfsdk:"github_base_url"`
76
+ Token types. String `tfsdk:"token"`
77
+ Owner types. String `tfsdk:"owner"`
78
+ GithubBaseURL types. String `tfsdk:"github_base_url"`
78
79
AppAuth []struct {
79
- ID string `tfsdk:"id"`
80
- InstallationID string `tfsdk:"installation_id"`
81
- PemFile string `tfsdk:"pem_file"`
80
+ ID types. String `tfsdk:"id"`
81
+ InstallationID types. String `tfsdk:"installation_id"`
82
+ PemFile types. String `tfsdk:"pem_file"`
82
83
} `tfsdk:"app_auth"`
83
84
}
84
85
@@ -88,8 +89,8 @@ func (p *kwgithubProvider) Configure(ctx context.Context, req provider.Configure
88
89
}
89
90
90
91
baseURL := "https://api.github.com"
91
- if config .GithubBaseURL != "" {
92
- baseURL = config .GithubBaseURL
92
+ if ! config .GithubBaseURL . IsNull () && ! config . GithubBaseURL . IsUnknown () {
93
+ baseURL = config .GithubBaseURL . ValueString ()
93
94
} else if envBaseURL := os .Getenv ("GITHUB_BASE_URL" ); envBaseURL != "" {
94
95
baseURL = envBaseURL
95
96
}
@@ -99,15 +100,24 @@ func (p *kwgithubProvider) Configure(ctx context.Context, req provider.Configure
99
100
100
101
if len (config .AppAuth ) > 0 {
101
102
appAuth := config .AppAuth [0 ]
102
- appID := appAuth .ID
103
+ appID := ""
104
+ if ! appAuth .ID .IsNull () && ! appAuth .ID .IsUnknown () {
105
+ appID = appAuth .ID .ValueString ()
106
+ }
103
107
if appID == "" {
104
108
appID = os .Getenv ("GITHUB_APP_ID" )
105
109
}
106
- installationID := appAuth .InstallationID
110
+ installationID := ""
111
+ if ! appAuth .InstallationID .IsNull () && ! appAuth .InstallationID .IsUnknown () {
112
+ installationID = appAuth .InstallationID .ValueString ()
113
+ }
107
114
if installationID == "" {
108
115
installationID = os .Getenv ("GITHUB_APP_INSTALLATION_ID" )
109
116
}
110
- pemFile := appAuth .PemFile
117
+ pemFile := ""
118
+ if ! appAuth .PemFile .IsNull () && ! appAuth .PemFile .IsUnknown () {
119
+ pemFile = appAuth .PemFile .ValueString ()
120
+ }
111
121
if pemFile == "" {
112
122
pemFile = os .Getenv ("GITHUB_APP_PEM_FILE" )
113
123
}
@@ -130,7 +140,9 @@ func (p *kwgithubProvider) Configure(ctx context.Context, req provider.Configure
130
140
return
131
141
}
132
142
} else {
133
- token = config .Token
143
+ if ! config .Token .IsNull () && ! config .Token .IsUnknown () {
144
+ token = config .Token .ValueString ()
145
+ }
134
146
if token == "" {
135
147
token = os .Getenv ("GITHUB_TOKEN" )
136
148
}
0 commit comments