diff --git a/internal/resource/user.go b/internal/resource/user.go index 1040787..35ee6e7 100644 --- a/internal/resource/user.go +++ b/internal/resource/user.go @@ -60,7 +60,6 @@ type User struct { ReadCommand *command.Command `json:"-" yaml:"-"` UpdateCommand *command.Command `json:"-" yaml:"-"` DeleteCommand *command.Command `json:"-" yaml:"-"` - config data.ConfigurationValueGetter Resources data.ResourceMapper `json:"-" yaml:"-"` } @@ -96,8 +95,9 @@ func FindSystemUserType() UserType { func (u *User) Init(uri data.URIParser) error { if uri == nil { uri = folio.URI(u.URI()).Parse() + } else { + u.Name = uri.URL().Hostname() } - u.Name = uri.URL().Hostname() u.UID = LookupUIDString(uri.URL().Hostname()) u.CreateCommand, u.ReadCommand, u.UpdateCommand, u.DeleteCommand = u.UserType.NewCRUD() return u.SetParsedURI(uri) diff --git a/internal/resource/user_test.go b/internal/resource/user_test.go index 52da42d..d66b875 100644 --- a/internal/resource/user_test.go +++ b/internal/resource/user_test.go @@ -94,7 +94,9 @@ func TestSystemUser(t *testing.T) { return nil, fmt.Errorf("%w: %s", data.ErrUnknownConfigurationKey, key) })) + assert.Nil(t, u.Init(nil)) u.ResolveId(context.Background()) + assert.Equal(t, "bar", u.Name) }