From ea5cd14726832e3c20948b391c622e49d235b86a Mon Sep 17 00:00:00 2001 From: Sjur Millidahl Date: Fri, 22 Nov 2024 08:49:53 +0100 Subject: [PATCH] refactor: adhere golang convension of capitalized abbreviations --- internal/sdk/cloudian/sdk.go | 26 +++++++++++++------------- internal/sdk/cloudian/sdk_test.go | 12 ++++++------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/sdk/cloudian/sdk.go b/internal/sdk/cloudian/sdk.go index 5a15d26..581e773 100644 --- a/internal/sdk/cloudian/sdk.go +++ b/internal/sdk/cloudian/sdk.go @@ -13,24 +13,24 @@ import ( type Group struct { Active string `json:"active"` - GroupId string `json:"groupId"` + GroupID string `json:"groupId"` GroupName string `json:"groupName"` - LdapEnabled bool `json:"ldapEnabled"` - LdapGroup string `json:"ldapGroup"` - LdapMatchAttribute string `json:"ldapMatchAttribute"` - LdapSearch string `json:"ldapSearch"` - LdapSearchUserBase string `json:"ldapSearchUserBase"` - LdapServerURL string `json:"ldapServerURL"` - LdapUserDNTemplate string `json:"ldapUserDNTemplate"` + LDAPEnabled bool `json:"ldapEnabled"` + LDAPGroup string `json:"ldapGroup"` + LDAPMatchAttribute string `json:"ldapMatchAttribute"` + LDAPSearch string `json:"ldapSearch"` + LDAPSearchUserBase string `json:"ldapSearchUserBase"` + LDAPServerURL string `json:"ldapServerURL"` + LDAPUserDNTemplate string `json:"ldapUserDNTemplate"` S3endpointshttp []string `json:"s3endpointshttp"` S3endpointshttps []string `json:"s3endpointshttps"` S3websiteendpoints []string `json:"s3websiteendpoints"` } type User struct { - UserId string `json:"userId"` - GroupId string `json:"groupId"` - CanonicalUserId string `json:"canonicalUserId"` + UserID string `json:"userId"` + GroupID string `json:"groupId"` + CanonicalUserID string `json:"canonicalUserId"` } func marshalGroup(group Group) ([]byte, error) { @@ -105,7 +105,7 @@ func ListUsers(groupId string, offsetUserId *string, tokenBase64 string) ([]User // There is some ambiguity in the GET /user/list endpoint documentation, but it seems // that UserId is the correct key for this parameter (and not CanonicalUserId) // Fetch more results - moreUsers, err := ListUsers(groupId, &users[limit].UserId, tokenBase64) + moreUsers, err := ListUsers(groupId, &users[limit].UserID, tokenBase64) if err == nil { retVal = append(retVal, moreUsers...) @@ -122,7 +122,7 @@ func ListUsers(groupId string, offsetUserId *string, tokenBase64 string) ([]User // Delete a single user func DeleteUser(user User, tokenBase64 string) (*User, error) { - url := baseUrl + "/user?userId=" + user.UserId + "&groupId=" + user.GroupId + "&canonicalUserId=" + user.CanonicalUserId + url := baseUrl + "/user?userId=" + user.UserID + "&groupId=" + user.GroupID + "&canonicalUserId=" + user.CanonicalUserID // Create a context with a timeout ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) diff --git a/internal/sdk/cloudian/sdk_test.go b/internal/sdk/cloudian/sdk_test.go index 4c7f02e..e24c1a8 100644 --- a/internal/sdk/cloudian/sdk_test.go +++ b/internal/sdk/cloudian/sdk_test.go @@ -26,8 +26,8 @@ func TestRealisticGroupSerialization(t *testing.T) { t.Errorf("Error deserializing from JSON: %v", err) } - if group.GroupId != "QA" { - t.Errorf("Expected QA, got %v", group.GroupId) + if group.GroupID != "QA" { + t.Errorf("Expected QA, got %v", group.GroupID) } } @@ -75,12 +75,12 @@ func TestUnmarshalUsers(t *testing.T) { t.Errorf("Error deserializing users from JSON: %v", err) } - if users[0].UserId != "Glory" { - t.Errorf("Expected Glory as the userId of first user, got %v", users[0].UserId) + if users[0].UserID != "Glory" { + t.Errorf("Expected Glory as the userId of first user, got %v", users[0].UserID) } - if users[1].UserId != "John" { - t.Errorf("Expected John as the userId of second user, got %v", users[1].UserId) + if users[1].UserID != "John" { + t.Errorf("Expected John as the userId of second user, got %v", users[1].UserID) } }