File tree Expand file tree Collapse file tree
cmd/thv-operator/pkg/controllerutil Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 "context"
88 "fmt"
99 "strings"
10- "time"
1110
1211 corev1 "k8s.io/api/core/v1"
1312 apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -583,20 +582,14 @@ func BuildAuthServerRunConfig(
583582 }
584583 config .Storage = storageCfg
585584
586- // Build CIMD configuration
585+ // Build CIMD configuration. CacheFallbackTTL is passed as-is (string);
586+ // resolveCIMDConfig in the runner parses it to time.Duration at startup.
587587 if authConfig .CIMD != nil && authConfig .CIMD .Enabled {
588- cimdCfg := & authserver.CIMDRunConfig {
589- Enabled : authConfig .CIMD .Enabled ,
590- CacheMaxSize : authConfig .CIMD .CacheMaxSize ,
588+ config .CIMD = & authserver.CIMDRunConfig {
589+ Enabled : authConfig .CIMD .Enabled ,
590+ CacheMaxSize : authConfig .CIMD .CacheMaxSize ,
591+ CacheFallbackTTL : authConfig .CIMD .CacheFallbackTTL ,
591592 }
592- if authConfig .CIMD .CacheFallbackTTL != "" {
593- ttl , err := time .ParseDuration (authConfig .CIMD .CacheFallbackTTL )
594- if err != nil {
595- return nil , fmt .Errorf ("cimd.cacheFallbackTtl: %w" , err )
596- }
597- cimdCfg .CacheFallbackTTL = ttl
598- }
599- config .CIMD = cimdCfg
600593 }
601594
602595 return config , nil
Original file line number Diff line number Diff line change 88 "fmt"
99 "strings"
1010 "testing"
11- "time"
1211
1312 "github.com/stretchr/testify/assert"
1413 "github.com/stretchr/testify/require"
@@ -2709,7 +2708,7 @@ func TestBuildAuthServerRunConfig_CIMD(t *testing.T) {
27092708 t .Helper ()
27102709 assert .True (t , got .Enabled )
27112710 assert .Equal (t , 512 , got .CacheMaxSize )
2712- assert .Equal (t , 10 * time . Minute , got .CacheFallbackTTL )
2711+ assert .Equal (t , "10m" , got .CacheFallbackTTL )
27132712 },
27142713 },
27152714 {
@@ -2726,13 +2725,18 @@ func TestBuildAuthServerRunConfig_CIMD(t *testing.T) {
27262725 },
27272726 },
27282727 {
2729- name : "invalid CacheFallbackTTL returns parse error " ,
2728+ name : "invalid CacheFallbackTTL passes through to runner for validation " ,
27302729 cimd : & mcpv1beta1.EmbeddedAuthServerCIMDConfig {
27312730 Enabled : true ,
27322731 CacheFallbackTTL : "not-a-duration" ,
27332732 },
2734- wantErr : true ,
2735- errContains : "cimd.cacheFallbackTtl" ,
2733+ wantCIMD : true ,
2734+ checkFunc : func (t * testing.T , got * authserver.CIMDRunConfig ) {
2735+ t .Helper ()
2736+ // The converter passes the string through; parse errors are caught
2737+ // by CIMDRunConfig.Validate() or resolveCIMDConfig in the runner.
2738+ assert .Equal (t , "not-a-duration" , got .CacheFallbackTTL )
2739+ },
27362740 },
27372741 }
27382742
You can’t perform that action at this time.
0 commit comments