Skip to content

Commit

Permalink
Merge pull request #723 from RafaySystems/ankit-fixexpiry-RC-34353-2.11
Browse files Browse the repository at this point in the history
RC-38515 - change expiry type to float64, include timezone field
  • Loading branch information
veerendra-rafay authored Nov 6, 2024
2 parents c4e9100 + 0c32ba3 commit 57f0381
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 5 additions & 1 deletion docs/resources/breakglassaccess.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ resource "rafay_breakglassaccess" "test_user" {
- `name` (String) Group Name which access will be added

***Optional***
- `start_time` (String) Time from when user access will be active
- `start_time` (String) Time from when user access will be active, if not provided it will be initialised with current time. If skipped then use lifecycle,ignore_changes to avoid changes in this field

***Optional***
- `timezone` (String) Timezone for the start_time



<a id="nestedblock--timeouts"></a>
Expand Down
11 changes: 9 additions & 2 deletions examples/resources/rafay_break_glass_access/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ resource "rafay_breakglassaccess" "test_user" {
groups {
group_expiry {
expiry = 7
name = "grp3"
name = "grp-2"
timezone = "America/Los_Angeles"
}
group_expiry {
expiry = 8
name = "grp1"
name = "grp-1"
start_time = "2024-09-20T08:00:00Z"
}
user_type = "local"
}
}

lifecycle {
ignore_changes = [
spec[0].groups[0].group_expiry[0].start_time
]
}
}
13 changes: 10 additions & 3 deletions rafay/resource_breakglassaccess.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,12 @@ func expandGroupExpiry(p []interface{}) []*systempb.GroupExpiryDetails {
expiryMap := expiry.(map[string]interface{})
ge := &systempb.GroupExpiryDetails{}

if v, ok := expiryMap["expiry"].(int); ok {
ge.Expiry = float32(v)
if v, ok := expiryMap["expiry"].(float64); ok {
ge.Expiry = v

Check failure on line 275 in rafay/resource_breakglassaccess.go

View workflow job for this annotation

GitHub Actions / goreleaser

cannot use v (variable of type float64) as float32 value in assignment
}

if v, ok := expiryMap["timezone"].(string); ok && len(v) > 0 {
ge.Timezone = v

Check failure on line 279 in rafay/resource_breakglassaccess.go

View workflow job for this annotation

GitHub Actions / goreleaser

ge.Timezone undefined (type *systempb.GroupExpiryDetails has no field or method Timezone)
}

if v, ok := expiryMap["name"].(string); ok && len(v) > 0 {
Expand Down Expand Up @@ -359,11 +363,14 @@ func flattenGroupExpiry(groupExpiries []*systempb.GroupExpiryDetails) []interfac
for i, expiry := range groupExpiries {
expiryMap := map[string]interface{}{}

expiryMap["expiry"] = int(expiry.Expiry)
expiryMap["expiry"] = expiry.Expiry

if len(expiry.Name) > 0 {
expiryMap["name"] = expiry.Name
}
if len(expiry.Timezone) > 0 {

Check failure on line 371 in rafay/resource_breakglassaccess.go

View workflow job for this annotation

GitHub Actions / goreleaser

expiry.Timezone undefined (type *systempb.GroupExpiryDetails has no field or method Timezone)
expiryMap["timezone"] = expiry.Timezone

Check failure on line 372 in rafay/resource_breakglassaccess.go

View workflow job for this annotation

GitHub Actions / goreleaser

expiry.Timezone undefined (type *systempb.GroupExpiryDetails has no field or method Timezone)
}

expiryMap["start_time"] = expiry.StartTime

Expand Down

0 comments on commit 57f0381

Please sign in to comment.