@@ -92,7 +92,7 @@ func (r *DvlsSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request)
9292 }
9393 }
9494
95- entry , err := DvlsClient .GetEntry ( dvlsSecret .Spec .EntryID )
95+ entry , err := DvlsClient .Entries . Credential . GetById ( dvlsSecret . Spec . VaultID , dvlsSecret .Spec .EntryID )
9696 if err != nil {
9797 log .Error (err , "unable to fetch dvls entry" , "entryId" , dvlsSecret .Spec .EntryID )
9898 meta .SetStatusCondition (& dvlsSecret .Status .Conditions , v1.Condition {Type : statusDegradedDvlsSecret , Status : v1 .ConditionTrue , Reason : "Reconciling" , Message : "Unable to fetch entry on DVLS instance" })
@@ -102,8 +102,8 @@ func (r *DvlsSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request)
102102 return ctrl.Result {}, nil
103103 }
104104
105- if entry .ConnectionType != dvls .ServerConnectionCredential || entry .ConnectionSubType != dvls .ServerConnectionSubTypeDefault {
106- log .Error (err , "entry type not supported, only username/password entries are supported" , "entryId" , dvlsSecret .Spec .EntryID , "entryType" , entry .ConnectionType , "entrySubType" , entry .ConnectionSubType )
105+ if entry .Type != string ( dvls .ServerConnectionCredential ) || entry .SubType != string ( dvls .ServerConnectionSubTypeDefault ) {
106+ log .Error (err , "entry type not supported, only username/password entries are supported" , "entryId" , dvlsSecret .Spec .EntryID , "entryType" , entry .Type , "entrySubType" , entry .SubType )
107107 meta .SetStatusCondition (& dvlsSecret .Status .Conditions , v1.Condition {Type : statusDegradedDvlsSecret , Status : v1 .ConditionTrue , Reason : "Reconciling" , Message : "Entry type not supported, only username/password entries are supported" })
108108 if err := r .Status ().Update (ctx , dvlsSecret ); err != nil {
109109 log .Error (err , "Failed to update DvlsSecret status" )
@@ -119,9 +119,9 @@ func (r *DvlsSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request)
119119 kSecretNotFound := apierrors .IsNotFound (err )
120120
121121 var entryTime , secretTime time.Time
122- if ! dvlsSecret .Status .EntryModifiedDate .IsZero () && entry .ModifiedDate != nil {
122+ if ! dvlsSecret .Status .EntryModifiedDate .IsZero () && entry .ModifiedOn != nil {
123123 secretTime = dvlsSecret .Status .EntryModifiedDate .Time
124- entryTime = entry .ModifiedDate .Time
124+ entryTime = entry .ModifiedOn .Time
125125 }
126126
127127 if entryTime .Equal (secretTime ) && ! kSecretNotFound {
@@ -130,21 +130,19 @@ func (r *DvlsSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request)
130130 }, nil
131131 }
132132
133- secret , err := DvlsClient .GetEntryCredentialsPassword (entry )
134- if err != nil {
135- log .Error (err , "unable to fetch dvls secret" , "entryId" , dvlsSecret .Spec .EntryID )
136- meta .SetStatusCondition (& dvlsSecret .Status .Conditions , v1.Condition {Type : statusDegradedDvlsSecret , Status : v1 .ConditionTrue , Reason : "Reconciling" , Message : "Unable to fetch secret on DVLS instance" })
137- if err := r .Status ().Update (ctx , dvlsSecret ); err != nil {
138- log .Error (err , "Failed to update DvlsSecret status" )
139- }
140- return ctrl.Result {}, nil
133+ defaultData , ok := entry .GetCredentialDefaultData ()
134+ if ! ok {
135+ return ctrl.Result {}, fmt .Errorf (
136+ "failed to extract credential data for entry ID %s: unsupported or unexpected entry type (type: %s, subtype: %s)" ,
137+ dvlsSecret .Spec .EntryID , entry .Type , entry .SubType )
141138 }
139+
142140 secretMap := make (map [string ]string )
143- secretMap ["entry-id" ] = secret . ID
144- secretMap ["entry-name" ] = secret . EntryName
145- secretMap ["username" ] = secret . Credentials .Username
146- if secret . Credentials . Password != nil {
147- secretMap ["password" ] = * secret . Credentials .Password
141+ secretMap ["entry-id" ] = entry . Id
142+ secretMap ["entry-name" ] = entry . Name
143+ secretMap ["username" ] = defaultData .Username
144+ if defaultData . Password != "" {
145+ secretMap ["password" ] = defaultData .Password
148146 }
149147
150148 if kSecretNotFound {
0 commit comments