@@ -15,10 +15,10 @@ type VMUserSpec struct {
1515 // Name of the VMUser object.
1616 // +optional
1717 Name * string `json:"name,omitempty"`
18- // UserName basic auth user name for accessing protected endpoint,
18+ // Username basic auth user name for accessing protected endpoint,
1919 // will be replaced with metadata.name of VMUser if omitted.
2020 // +optional
21- UserName * string `json:"username,omitempty"`
21+ Username * string `json:"username,omitempty"`
2222 // Password basic auth password for accessing protected endpoint.
2323 // +optional
2424 Password * string `json:"password,omitempty"`
@@ -232,11 +232,25 @@ func (cr *VMUser) GetStatusMetadata() *StatusMetadata {
232232 return & cr .Status .StatusMetadata
233233}
234234
235+ func (cr * VMUser ) AsKey () string {
236+ var id string
237+ if cr .Spec .Username != nil {
238+ id = "basicAuth:" + * cr .Spec .Username
239+ }
240+ if cr .Spec .Password != nil {
241+ return id + ":" + * cr .Spec .Password
242+ }
243+ if cr .Spec .BearerToken != nil {
244+ return "bearerToken:" + * cr .Spec .BearerToken
245+ }
246+ return id
247+ }
248+
235249func (cr * VMUser ) Validate () error {
236250 if MustSkipCRValidation (cr ) {
237251 return nil
238252 }
239- if cr .Spec .UserName != nil && cr .Spec .BearerToken != nil {
253+ if cr .Spec .Username != nil && cr .Spec .BearerToken != nil {
240254 return fmt .Errorf ("one of spec.username and spec.bearerToken must be defined for user, got both" )
241255 }
242256 if cr .Spec .PasswordRef != nil && cr .Spec .Password != nil {
0 commit comments