Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.18.0
github.com/stackitcloud/stackit-sdk-go/services/certificates v1.8.0
github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0
github.com/stackitcloud/stackit-sdk-go/services/dremio v0.3.0
github.com/stackitcloud/stackit-sdk-go/services/dremio v0.4.0
github.com/stackitcloud/stackit-sdk-go/services/edge v0.12.0
github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ github.com/stackitcloud/stackit-sdk-go/services/certificates v1.8.0 h1:bINitVHAy
github.com/stackitcloud/stackit-sdk-go/services/certificates v1.8.0/go.mod h1:eJpB3/pukz+KzVPVHQ4g3DVtQkxGga18VbFBhq9ugdY=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0 h1:ZVkptfVCAqpaPWkE+WIopM9XdzqgbVcwmX5L1jZqqx8=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0/go.mod h1:FiYSv3D9rzgEVzi8Mpq5oYZBosrasa5uUYqVdEIbM1U=
github.com/stackitcloud/stackit-sdk-go/services/dremio v0.3.0 h1:LKreLAR425+EMYbKrPIAzeoTEQlDF8EpIMTVBpOhjmA=
github.com/stackitcloud/stackit-sdk-go/services/dremio v0.3.0/go.mod h1:iMoiM8fM1mXC1Nz8FBiiQ08Yh+0C3yN0GPCdAbOlRXo=
github.com/stackitcloud/stackit-sdk-go/services/dremio v0.4.0 h1:kAWRUptc9g6lA9XCgB4Fw8oQYOhDuV0mp+eZhpiyJ+Y=
github.com/stackitcloud/stackit-sdk-go/services/dremio v0.4.0/go.mod h1:iMoiM8fM1mXC1Nz8FBiiQ08Yh+0C3yN0GPCdAbOlRXo=
github.com/stackitcloud/stackit-sdk-go/services/edge v0.12.0 h1:qPhNo5m0K9ZKMnUx7e23fmvBmhOCxIFRzobwFhSHWUY=
github.com/stackitcloud/stackit-sdk-go/services/edge v0.12.0/go.mod h1:Ylse6gqGJtsd5TVmvha+hoLd1QQHLKvhY5dO15+q5kg=
github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0 h1:VZBneGprCmHqckcSMPs3puBlK8rBpLMtYKmBktwdoVE=
Expand Down
14 changes: 9 additions & 5 deletions stackit/internal/services/dremio/dremio_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ var resourceDremioInstanceMin string
//go:embed testdata/resource-max.tf
var resourceDremioInstanceMax string

const dremioInstanceResource = "stackit_dremio_instance.example"
const dremioInstanceDataResource = "data.stackit_dremio_instance.example"
const (
dremioInstanceResource = "stackit_dremio_instance.example"
dremioInstanceDataResource = "data.stackit_dremio_instance.example"
)

const dremioUserResource = "stackit_dremio_user.example"
const dremioUserDataResource = "data.stackit_dremio_user.example"
const (
dremioUserResource = "stackit_dremio_user.example"
dremioUserDataResource = "data.stackit_dremio_user.example"
)

var testDremioConfigVarsMin = config.Variables{
"project_id": config.StringVariable(testutil.ProjectId),
Expand Down Expand Up @@ -285,7 +289,6 @@ func TestAccDremioInstanceMax(t *testing.T) {

resource.TestCheckResourceAttr(dremioInstanceResource, "authentication.oauth.authority_url", testutil.ConvertConfigVariable(testDremioConfigVarsMax["authentication_oauth_authority_url"])),
resource.TestCheckResourceAttr(dremioInstanceResource, "authentication.oauth.client_id", testutil.ConvertConfigVariable(testDremioConfigVarsMax["authentication_oauth_client_id"])),
resource.TestCheckResourceAttr(dremioInstanceResource, "authentication.oauth.client_secret", testutil.ConvertConfigVariable(testDremioConfigVarsMax["authentication_oauth_client_secret"])),
resource.TestCheckResourceAttrSet(dremioInstanceResource, "authentication.oauth.redirect_url"),
resource.TestCheckResourceAttr(dremioInstanceResource, "authentication.oauth.jwt_claims.user_name", testutil.ConvertConfigVariable(testDremioConfigVarsMax["authentication_oauth_client_jwt_claims_user_name"])),
resource.TestCheckResourceAttr(dremioInstanceResource, "authentication.oauth.scope", testutil.ConvertConfigVariable(testDremioConfigVarsMax["authentication_oauth_scope"])),
Expand Down Expand Up @@ -432,6 +435,7 @@ func TestAccDremioInstanceMax(t *testing.T) {

return fmt.Sprintf("%s,%s,%s", testutil.ProjectId, testutil.Region, instanceId), nil
},
ImportStateVerifyIgnore: []string{"authentication.oauth.client_secret"},
},
{
ConfigVariables: testDremioConfigVarsMax,
Expand Down
49 changes: 26 additions & 23 deletions stackit/internal/services/dremio/instance/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,33 +708,39 @@ func mapAuthentication(instanceResp *dremioSdk.DremioResponse, model *Model) err
return fmt.Errorf("model input is nil")
}

authModel := AuthenticationModel{
Type: types.StringValue(string(instanceResp.Authentication.Type)),
if model.Authentication == nil {
model.Authentication = new(AuthenticationModel)
}

model.Authentication.Type = types.StringValue(string(instanceResp.Authentication.Type))

if instanceResp.Authentication.Azuread != nil {
azureADResp := instanceResp.Authentication.Azuread
authModel.AzureAD = &AzureADModel{
AuthorityUrl: types.StringValue(azureADResp.AuthorityUrl),
ClientId: types.StringValue(azureADResp.ClientId),
ClientSecret: types.StringValue(azureADResp.ClientSecret),
RedirectUrl: types.StringPointerValue(azureADResp.RedirectUrl),
if model.Authentication.AzureAD == nil {
model.Authentication.AzureAD = new(AzureADModel)
}

azureADResp := instanceResp.Authentication.Azuread
azureADModel := model.Authentication.AzureAD

azureADModel.AuthorityUrl = types.StringValue(azureADResp.AuthorityUrl)
azureADModel.ClientId = types.StringValue(azureADResp.ClientId)
azureADModel.RedirectUrl = types.StringValue(*azureADResp.RedirectUrl)
}

if instanceResp.Authentication.Oauth != nil {
oauthResp := instanceResp.Authentication.Oauth
oauthModel := &OAuthModel{
AuthorityUrl: types.StringValue(oauthResp.AuthorityUrl),
ClientId: types.StringValue(oauthResp.ClientId),
ClientSecret: types.StringValue(oauthResp.ClientSecret),
Scope: types.StringPointerValue(oauthResp.Scope),
RedirectUrl: types.StringPointerValue(oauthResp.RedirectUrl),
JwtClaims: &JwtClaimsModel{
UserName: types.StringValue(oauthResp.JwtClaims.UserName),
},
if model.Authentication.OAuth == nil {
model.Authentication.OAuth = new(OAuthModel)
}

oauthResp := instanceResp.Authentication.Oauth
oauthModel := model.Authentication.OAuth

oauthModel.AuthorityUrl = types.StringValue(oauthResp.AuthorityUrl)
oauthModel.ClientId = types.StringValue(oauthResp.ClientId)
oauthModel.Scope = types.StringPointerValue(oauthResp.Scope)
oauthModel.RedirectUrl = types.StringPointerValue(oauthResp.RedirectUrl)
oauthModel.JwtClaims = &JwtClaimsModel{UserName: types.StringValue(oauthResp.JwtClaims.UserName)}

if len(oauthResp.Parameters) > 0 {
var params []AuthParameterModel
for _, p := range oauthResp.Parameters {
Expand All @@ -746,11 +752,8 @@ func mapAuthentication(instanceResp *dremioSdk.DremioResponse, model *Model) err
oauthModel.Parameters = params
}

authModel.OAuth = oauthModel
}

model.Authentication = &authModel

return nil
}

Expand Down Expand Up @@ -827,7 +830,7 @@ func parseAuthentication(model *Model) (*dremioSdk.Authentication, error) {
oAuthPayload := &dremioSdk.Oauth{
AuthorityUrl: model.Authentication.OAuth.AuthorityUrl.ValueString(),
ClientId: model.Authentication.OAuth.ClientId.ValueString(),
ClientSecret: model.Authentication.OAuth.ClientSecret.ValueString(),
ClientSecret: model.Authentication.OAuth.ClientSecret.ValueStringPointer(),
JwtClaims: dremioSdk.OauthJwtClaims{
UserName: model.Authentication.OAuth.JwtClaims.UserName.ValueString(),
},
Expand All @@ -852,7 +855,7 @@ func parseAuthentication(model *Model) (*dremioSdk.Authentication, error) {
azureAdPayload := &dremioSdk.Azuread{
AuthorityUrl: model.Authentication.AzureAD.AuthorityUrl.ValueString(),
ClientId: model.Authentication.AzureAD.ClientId.ValueString(),
ClientSecret: model.Authentication.AzureAD.ClientSecret.ValueString(),
ClientSecret: model.Authentication.AzureAD.ClientSecret.ValueStringPointer(),
RedirectUrl: model.Authentication.AzureAD.RedirectUrl.ValueStringPointer(),
}
return &dremioSdk.Authentication{
Expand Down
14 changes: 6 additions & 8 deletions stackit/internal/services/dremio/instance/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ func TestMapFields(t *testing.T) {
Azuread: &dremioSdk.Azuread{
AuthorityUrl: "azure-authority",
ClientId: "azure-client",
ClientSecret: "azure-secret",
RedirectUrl: utils.Ptr("azure-redirect"),
},
Oauth: &dremioSdk.Oauth{
AuthorityUrl: "oauth-authority",
ClientId: "oauth-client",
ClientSecret: "oauth-secret",
JwtClaims: dremioSdk.OauthJwtClaims{
UserName: "oauth-username",
},
Expand Down Expand Up @@ -77,13 +75,13 @@ func TestMapFields(t *testing.T) {
AzureAD: &AzureADModel{
AuthorityUrl: types.StringValue("azure-authority"),
ClientId: types.StringValue("azure-client"),
ClientSecret: types.StringValue("azure-secret"),
ClientSecret: types.StringNull(),
RedirectUrl: types.StringValue("azure-redirect"),
},
OAuth: &OAuthModel{
AuthorityUrl: types.StringValue("oauth-authority"),
ClientId: types.StringValue("oauth-client"),
ClientSecret: types.StringValue("oauth-secret"),
ClientSecret: types.StringNull(),
JwtClaims: &JwtClaimsModel{
UserName: types.StringValue("oauth-username"),
},
Expand Down Expand Up @@ -207,7 +205,7 @@ func TestToCreatePayload(t *testing.T) {
Oauth: &dremioSdk.Oauth{
AuthorityUrl: "oauth-authority",
ClientId: "oauth-client",
ClientSecret: "oauth-secret",
ClientSecret: utils.Ptr("oauth-secret"),
JwtClaims: dremioSdk.OauthJwtClaims{
UserName: "oauth-username",
},
Expand Down Expand Up @@ -247,7 +245,7 @@ func TestToCreatePayload(t *testing.T) {
Azuread: &dremioSdk.Azuread{
AuthorityUrl: "azure-authority",
ClientId: "azure-client",
ClientSecret: "azure-secret",
ClientSecret: utils.Ptr("azure-secret"),
RedirectUrl: utils.Ptr("azure-redirect"),
},
Type: dremioSdk.AUTHENTICATIONTYPE_AZUREAD,
Expand Down Expand Up @@ -424,7 +422,7 @@ func TestToUpdatePayload(t *testing.T) {
Oauth: &dremioSdk.Oauth{
AuthorityUrl: "oauth-authority",
ClientId: "oauth-client",
ClientSecret: "oauth-secret",
ClientSecret: utils.Ptr("oauth-secret"),
JwtClaims: dremioSdk.OauthJwtClaims{
UserName: "oauth-username",
},
Expand Down Expand Up @@ -464,7 +462,7 @@ func TestToUpdatePayload(t *testing.T) {
Azuread: &dremioSdk.Azuread{
AuthorityUrl: "azure-authority",
ClientId: "azure-client",
ClientSecret: "azure-secret",
ClientSecret: utils.Ptr("azure-secret"),
RedirectUrl: utils.Ptr("azure-redirect"),
},
Type: dremioSdk.AUTHENTICATIONTYPE_AZUREAD,
Expand Down