Skip to content

Commit

Permalink
Merge pull request #24 from claranet/develop
Browse files Browse the repository at this point in the history
Release v0.12.0
  • Loading branch information
jeremmfr authored Oct 4, 2023
2 parents f8b572e + dfeb800 commit 080550d
Show file tree
Hide file tree
Showing 32 changed files with 529 additions and 459 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Go Tests
on: [push, pull_request]
jobs:
build-1_19:
name: Build 1.19
build-1_20:
name: Build 1.20
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.20'
check-latest: true
id: go
- name: Disable cgo
Expand All @@ -21,14 +21,14 @@ jobs:
- name: Build
run: go build -v .

build-1_20:
name: Build 1.20
build-1_21:
name: Build 1.21
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.21'
check-latest: true
id: go
- name: Disable cgo
Expand All @@ -45,10 +45,10 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.21'
check-latest: true
id: go
- name: Disable cgo
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.21'
check-latest: true
id: go
- name: Disable cgo
Expand All @@ -19,7 +19,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53
version: v1.54
args: -c .golangci.yml -v

markdown-lint:
Expand All @@ -38,10 +38,10 @@ jobs:
name: terrafmt
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.21'
check-latest: true
id: go
- name: Show version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.21'
-
name: Import GPG key
uses: crazy-max/[email protected]
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<!-- markdownlint-disable-file MD013 MD041 -->
# changelog

## 0.12.0 (October 04, 2023)

ENHANCEMENTS:

* release now with golang 1.21
* resource/**wallix-bastion_user**: update the password when has changed in config to not empty value and `force_change_pwd` isn't true (instead of no-op on password when update resource)

BUG FIXES:

* reduced compute and memory usage to prepare the JSON payload when creating or updating resource

## 0.11.0 (September 26, 2023)

FEATURES:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

### In addition to develop

- [Go](https://golang.org/doc/install) `v1.19` or `v1.20`
- [Go](https://golang.org/doc/install) `v1.20` or `v1.21`
44 changes: 23 additions & 21 deletions bastion/resource_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,20 +326,22 @@ func prepareApplicationJSON(d *schema.ResourceData) jsonApplication {
Parameters: d.Get("parameters").(string),
Target: d.Get("target").(string),
}
for _, v := range d.Get("paths").(*schema.Set).List() {
m := v.(map[string]interface{})
jsonData.Paths = append(jsonData.Paths, jsonApplicationPath{
Target: m["target"].(string),
Program: m["program"].(string),
WorkingDir: m["working_dir"].(string),
})
}
if len(d.Get("global_domains").(*schema.Set).List()) > 0 {
for _, v := range d.Get("global_domains").(*schema.Set).List() {
jsonData.GlobalDomains = append(jsonData.GlobalDomains, v.(string))

listPaths := d.Get("paths").(*schema.Set).List()
jsonData.Paths = make([]jsonApplicationPath, len(listPaths))
for i, v := range listPaths {
paths := v.(map[string]interface{})
jsonData.Paths[i] = jsonApplicationPath{
Target: paths["target"].(string),
Program: paths["program"].(string),
WorkingDir: paths["working_dir"].(string),
}
} else {
jsonData.GlobalDomains = make([]string, 0)
}

listGlobalDomains := d.Get("global_domains").(*schema.Set).List()
jsonData.GlobalDomains = make([]string, len(listGlobalDomains))
for i, v := range listGlobalDomains {
jsonData.GlobalDomains[i] = v.(string)
}

return jsonData
Expand Down Expand Up @@ -377,13 +379,13 @@ func fillApplication(d *schema.ResourceData, jsonData jsonApplication) {
if tfErr := d.Set("connection_policy", jsonData.ConnectionPolicy); tfErr != nil {
panic(tfErr)
}
paths := make([]map[string]interface{}, 0)
for _, v := range jsonData.Paths {
paths = append(paths, map[string]interface{}{
paths := make([]map[string]interface{}, len(jsonData.Paths))
for i, v := range jsonData.Paths {
paths[i] = map[string]interface{}{
"target": v.Target,
"program": v.Program,
"working_dir": v.WorkingDir,
})
}
}
if tfErr := d.Set("paths", paths); tfErr != nil {
panic(tfErr)
Expand All @@ -400,17 +402,17 @@ func fillApplication(d *schema.ResourceData, jsonData jsonApplication) {
if tfErr := d.Set("parameters", jsonData.Parameters); tfErr != nil {
panic(tfErr)
}
localDomains := make([]map[string]interface{}, 0)
for _, v := range *jsonData.LocalDomains {
localDomains = append(localDomains, map[string]interface{}{
localDomains := make([]map[string]interface{}, len(*jsonData.LocalDomains))
for i, v := range *jsonData.LocalDomains {
localDomains[i] = map[string]interface{}{
"id": v.ID,
"admin_account": v.AdminAccount,
"domain_name": v.DomainName,
"description": v.Description,
"enable_password_change": v.EnablePasswordChange,
"password_change_policy": v.PasswordChangePolicy,
"password_change_plugin": v.PasswordChangePlugin,
})
}
pluginParameters, _ := json.Marshal(v.PasswordChangePluginParameters) //nolint: errchkjson
localDomains[len(localDomains)-1]["password_change_plugin_parameters"] = string(pluginParameters)
}
Expand Down
8 changes: 5 additions & 3 deletions bastion/resource_application_localdomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,11 @@ func deleteApplicationLocalDomain(
}

func prepareApplicationLocalDomainJSON(d *schema.ResourceData, newResource bool) jsonApplicationLocalDomain {
var jsonData jsonApplicationLocalDomain
jsonData.DomainName = d.Get("domain_name").(string)
jsonData.Description = d.Get("description").(string)
jsonData := jsonApplicationLocalDomain{
Description: d.Get("description").(string),
DomainName: d.Get("domain_name").(string),
}

if d.Get("enable_password_change").(bool) {
if !newResource {
adminAccount := d.Get("admin_account").(string)
Expand Down
14 changes: 8 additions & 6 deletions bastion/resource_application_localdomain_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,14 @@ func deleteApplicationLocalDomainAccount(
}

func prepareApplicationLocalDomainAccountJSON(d *schema.ResourceData) jsonApplicationLocalDomainAccount {
var jsonData jsonApplicationLocalDomainAccount
jsonData.AccountName = d.Get("account_name").(string)
jsonData.AccountLogin = d.Get("account_login").(string)
jsonData.CheckoutPolicy = d.Get("checkout_policy").(string)
jsonData.AutoChangePassword = d.Get("auto_change_password").(bool)
jsonData.Description = d.Get("description").(string)
jsonData := jsonApplicationLocalDomainAccount{
AccountLogin: d.Get("account_login").(string),
AccountName: d.Get("account_name").(string),
AutoChangePassword: d.Get("auto_change_password").(bool),
CheckoutPolicy: d.Get("checkout_policy").(string),
Description: d.Get("description").(string),
}

credentials := make([]jsonCredential, 0)
if d.Get("password").(string) != "" {
credentials = append(credentials, jsonCredential{
Expand Down
16 changes: 10 additions & 6 deletions bastion/resource_authdomain_ad.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ func prepareAuthDomainADJSON(d *schema.ResourceData) jsonAuthDomainAD {
AuthDomainName: d.Get("auth_domain_name").(string),
DefaultEmailDomain: d.Get("default_email_domain").(string),
DefaultLanguage: d.Get("default_language").(string),
ExternalAuths: make([]string, 0),
Description: d.Get("description").(string),
CheckX509SanEmail: d.Get("check_x509_san_email").(bool),
DisplayNameAttribute: d.Get("display_name_attribute").(string),
Expand All @@ -325,15 +324,20 @@ func prepareAuthDomainADJSON(d *schema.ResourceData) jsonAuthDomainAD {
LanguageAttribute: d.Get("language_attribute").(string),
PubKeyAttribute: d.Get("pubkey_attribute").(string),
SanDomainName: d.Get("san_domain_name").(string),
SecondaryAuth: make([]string, 0),
X509Condition: d.Get("x509_condition").(string),
X509SearchFilter: d.Get("x509_search_filter").(string),
}
for _, v := range d.Get("external_auths").([]interface{}) {
jsonData.ExternalAuths = append(jsonData.ExternalAuths, v.(string))

listExternalAuths := d.Get("external_auths").([]interface{})
jsonData.ExternalAuths = make([]string, len(listExternalAuths))
for i, v := range listExternalAuths {
jsonData.ExternalAuths[i] = v.(string)
}
for _, v := range d.Get("secondary_auth").([]interface{}) {
jsonData.SecondaryAuth = append(jsonData.SecondaryAuth, v.(string))

listSecondaryAuth := d.Get("secondary_auth").([]interface{})
jsonData.SecondaryAuth = make([]string, len(listSecondaryAuth))
for i, v := range listSecondaryAuth {
jsonData.SecondaryAuth[i] = v.(string)
}

return jsonData
Expand Down
16 changes: 10 additions & 6 deletions bastion/resource_authdomain_azuread.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,21 +312,25 @@ func prepareAuthDomainAzureADJSON(d *schema.ResourceData) jsonAuthDomainAzureAD
DefaultEmailDomain: d.Get("default_email_domain").(string),
DefaultLanguage: d.Get("default_language").(string),
EntityID: d.Get("entity_id").(string),
ExternalAuths: make([]string, 0),
Label: d.Get("label").(string),
Certificate: d.Get("certificate").(string),
ClientSecret: d.Get("client_secret").(string),
Description: d.Get("description").(string),
IsDefault: d.Get("is_default").(bool),
Passphrase: d.Get("passphrase").(string),
PrivateKey: d.Get("private_key").(string),
SecondaryAuth: make([]string, 0),
}
for _, v := range d.Get("external_auths").([]interface{}) {
jsonData.ExternalAuths = append(jsonData.ExternalAuths, v.(string))

listExternalAuths := d.Get("external_auths").([]interface{})
jsonData.ExternalAuths = make([]string, len(listExternalAuths))
for i, v := range listExternalAuths {
jsonData.ExternalAuths[i] = v.(string)
}
for _, v := range d.Get("secondary_auth").([]interface{}) {
jsonData.SecondaryAuth = append(jsonData.SecondaryAuth, v.(string))

listSecondaryAuth := d.Get("secondary_auth").([]interface{})
jsonData.SecondaryAuth = make([]string, len(listSecondaryAuth))
for i, v := range listSecondaryAuth {
jsonData.SecondaryAuth[i] = v.(string)
}

return jsonData
Expand Down
16 changes: 10 additions & 6 deletions bastion/resource_authdomain_ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ func prepareAuthDomainLdapJSON(d *schema.ResourceData) jsonAuthDomainLdap {
AuthDomainName: d.Get("auth_domain_name").(string),
DefaultEmailDomain: d.Get("default_email_domain").(string),
DefaultLanguage: d.Get("default_language").(string),
ExternalAuths: make([]string, 0),
Description: d.Get("description").(string),
CheckX509SanEmail: d.Get("check_x509_san_email").(bool),
DisplayNameAttribute: d.Get("display_name_attribute").(string),
Expand All @@ -325,15 +324,20 @@ func prepareAuthDomainLdapJSON(d *schema.ResourceData) jsonAuthDomainLdap {
LanguageAttribute: d.Get("language_attribute").(string),
PubKeyAttribute: d.Get("pubkey_attribute").(string),
SanDomainName: d.Get("san_domain_name").(string),
SecondaryAuth: make([]string, 0),
X509Condition: d.Get("x509_condition").(string),
X509SearchFilter: d.Get("x509_search_filter").(string),
}
for _, v := range d.Get("external_auths").([]interface{}) {
jsonData.ExternalAuths = append(jsonData.ExternalAuths, v.(string))

listExternalAuths := d.Get("external_auths").([]interface{})
jsonData.ExternalAuths = make([]string, len(listExternalAuths))
for i, v := range listExternalAuths {
jsonData.ExternalAuths[i] = v.(string)
}
for _, v := range d.Get("secondary_auth").([]interface{}) {
jsonData.SecondaryAuth = append(jsonData.SecondaryAuth, v.(string))

listSecondaryAuth := d.Get("secondary_auth").([]interface{})
jsonData.SecondaryAuth = make([]string, len(listSecondaryAuth))
for i, v := range listSecondaryAuth {
jsonData.SecondaryAuth[i] = v.(string)
}

return jsonData
Expand Down
18 changes: 11 additions & 7 deletions bastion/resource_authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,23 @@ func prepareAuthorizationJSON(d *schema.ResourceData, newResource bool) jsonAuth
IsCritical: d.Get("is_critical").(bool),
IsRecorded: d.Get("is_recorded").(bool),
}

if newResource {
jsonData.UserGroup = d.Get("user_group").(string)
jsonData.TargetGroup = d.Get("target_group").(string)
}

if d.Get("approval_required").(bool) {
activeQuorum := d.Get("active_quorum").(int)
jsonData.ActiveQuorum = &activeQuorum
inactiveQuorum := d.Get("inactive_quorum").(int)
jsonData.InactiveQuorum = &inactiveQuorum
approvalTimeout := d.Get("approval_timeout").(int)
jsonData.ApprovalTimeout = &approvalTimeout
approvers := make([]string, 0)
for _, v := range d.Get("approvers").([]interface{}) {
approvers = append(approvers, v.(string))
listApprovers := d.Get("approvers").([]interface{})
approvers := make([]string, len(listApprovers))
for i, v := range listApprovers {
approvers[i] = v.(string)
}
jsonData.Approvers = &approvers
hasComment := d.Get("has_comment").(bool)
Expand All @@ -369,10 +372,11 @@ func prepareAuthorizationJSON(d *schema.ResourceData, newResource bool) jsonAuth
singleConnection := d.Get("single_connection").(bool)
jsonData.SingleConnection = &singleConnection
}
if v := d.Get("subprotocols").(*schema.Set).List(); len(v) > 0 {
subProtocols := make([]string, 0)
for _, v2 := range v {
subProtocols = append(subProtocols, v2.(string))

if listSubProtocols := d.Get("subprotocols").(*schema.Set).List(); len(listSubProtocols) > 0 {
subProtocols := make([]string, len(listSubProtocols))
for i, v := range listSubProtocols {
subProtocols[i] = v.(string)
}
jsonData.SubProtocols = &subProtocols
}
Expand Down
17 changes: 9 additions & 8 deletions bastion/resource_checkout_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,15 @@ func deleteCheckoutPolicy(
}

func prepareCheckoutPolicyJSON(d *schema.ResourceData) jsonCheckoutPolicy {
var jsonData jsonCheckoutPolicy
jsonData.CheckoutPolicyName = d.Get("checkout_policy_name").(string)
jsonData.Description = d.Get("description").(string)
jsonData.EnableLock = d.Get("enable_lock").(bool)
jsonData.ChangeCredentialsAtCheckin = d.Get("change_credentials_at_checkin").(bool)
jsonData.Duration = d.Get("duration").(int)
jsonData.Extension = d.Get("extension").(int)
jsonData.MaxDuration = d.Get("max_duration").(int)
jsonData := jsonCheckoutPolicy{
ChangeCredentialsAtCheckin: d.Get("change_credentials_at_checkin").(bool),
CheckoutPolicyName: d.Get("checkout_policy_name").(string),
Description: d.Get("description").(string),
EnableLock: d.Get("enable_lock").(bool),
Duration: d.Get("duration").(int),
Extension: d.Get("extension").(int),
MaxDuration: d.Get("max_duration").(int),
}

return jsonData
}
Expand Down
Loading

0 comments on commit 080550d

Please sign in to comment.