in teamcity/connection.go [105:173]
func (r *connectionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var plan connectionResourceModel
diags := req.Plan.Get(ctx, &plan)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
feature := models.ProjectFeatureJson{
Type: "OAuthProvider",
Properties: models.Properties{
Property: []models.Property{
{
Name: "providerType",
Value: "GitHubApp",
},
{
Name: "connectionSubtype",
Value: "gitHubApp",
},
{
Name: "displayName",
Value: plan.GithubApp.DisplayName.ValueString(),
},
{
Name: "gitHubApp.ownerUrl",
Value: plan.GithubApp.OwnerUrl.ValueString(),
},
{
Name: "gitHubApp.appId",
Value: plan.GithubApp.AppId.ValueString(),
},
{
Name: "gitHubApp.clientId",
Value: plan.GithubApp.ClientId.ValueString(),
},
{
Name: "secure:gitHubApp.clientSecret",
Value: plan.GithubApp.ClientSecret.ValueString(),
},
{
Name: "secure:gitHubApp.privateKey",
Value: plan.GithubApp.PrivateKey.ValueString(),
},
{
Name: "secure:gitHubApp.webhookSecret",
Value: plan.GithubApp.WebhookSecret.ValueString(),
},
},
},
}
result, err := r.client.NewProjectFeature(plan.ProjectId.ValueString(), feature)
if err != nil {
resp.Diagnostics.AddError(
"Error adding project feature",
err.Error(),
)
return
}
newState := r.readState(result, plan)
diags = resp.State.Set(ctx, newState)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
}