@@ -153,7 +153,7 @@ func (d *GroupAlias) PrepareInternalValues(context context.Context, object clien
153153 log .Error (err , "authEngineMount not found at path" , "path" , d .Spec .AuthEngineMountPath )
154154 return err
155155 }
156- d . Spec . retrievedMountAccessor = secret .Data ["accessor" ].(string )
156+ mountAccessor : = secret .Data ["accessor" ].(string )
157157
158158 secret , found , err = vaultutils .ReadSecret (context , vaultutils .CleansePath ("/identity/group/name/" + d .Spec .GroupName ))
159159 if err != nil {
@@ -165,19 +165,14 @@ func (d *GroupAlias) PrepareInternalValues(context context.Context, object clien
165165 log .Error (err , "group not found" , "name" , d .Spec .GroupName )
166166 return err
167167 }
168- d .Spec .retrievedCanonicalID = secret .Data ["id" ].(string )
169- if d .Spec .Name != "" {
170- d .Spec .retrievedName = d .Spec .Name
171- } else {
172- d .Spec .retrievedName = d .Name
173- }
168+ canonicalID := secret .Data ["id" ].(string )
174169
175170 if d .Status .ID == "" {
176171 //we have to create the group alias as unfortunately this api is asymmetric
177172 payload := map [string ]interface {}{
178173 "name" : map [bool ]string {true : d .Spec .Name , false : d .Name }[d .Spec .Name != "" ],
179- "mount_accessor" : d . Spec . retrievedMountAccessor ,
180- "canonical_id" : d . Spec . retrievedCanonicalID ,
174+ "mount_accessor" : mountAccessor ,
175+ "canonical_id" : canonicalID ,
181176 }
182177 log .V (1 ).Info ("create group alias" , "payload" , payload )
183178 vaultClient := context .Value ("vaultClient" ).(* vault.Client )
@@ -195,7 +190,16 @@ func (d *GroupAlias) PrepareInternalValues(context context.Context, object clien
195190 }
196191 }
197192
193+ // Set all retrieved fields after any status update to ensure they're always available
194+ // Status().Update() overwrites the local object, clearing non-persisted fields
195+ d .Spec .retrievedMountAccessor = mountAccessor
196+ d .Spec .retrievedCanonicalID = canonicalID
198197 d .Spec .retrievedAliasID = d .Status .ID
198+ if d .Spec .Name != "" {
199+ d .Spec .retrievedName = d .Spec .Name
200+ } else {
201+ d .Spec .retrievedName = d .Name
202+ }
199203 return nil
200204}
201205
0 commit comments