From 4127045b61a1a4acef601b933479822605979898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Larivi=C3=A8re?= Date: Tue, 3 Jun 2025 14:52:07 -0400 Subject: [PATCH] fix: naming consistency for Id --- VERSION | 2 +- entries.go | 2 +- entry_attachments.go | 10 +-- entry_certificate.go | 14 ++--- entry_certificate_test.go | 18 +++--- entry_credential.go | 30 ++++----- entry_credential_test.go | 126 +++++++++++++++++++------------------- entry_host.go | 12 ++-- entry_host_test.go | 6 +- entry_website.go | 12 ++-- entry_website_test.go | 6 +- vaults.go | 10 +-- vaults_test.go | 12 ++-- 13 files changed, 130 insertions(+), 130 deletions(-) diff --git a/VERSION b/VERSION index ac454c6..34a8361 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.12.0 +0.12.1 diff --git a/entries.go b/entries.go index 6388f2d..d897bd3 100644 --- a/entries.go +++ b/entries.go @@ -21,7 +21,7 @@ type Entries struct { } type Entry struct { - ID string `json:"id,omitempty"` + Id string `json:"id,omitempty"` VaultId string `json:"vaultId,omitempty"` Name string `json:"name"` Path string `json:"path"` diff --git a/entry_attachments.go b/entry_attachments.go index ec09025..89075eb 100644 --- a/entry_attachments.go +++ b/entry_attachments.go @@ -9,10 +9,10 @@ import ( ) type EntryAttachment struct { - ID string `json:"id,omitempty"` - IDString string `json:"idString"` - EntryID string `json:"connectionID"` - EntryIDString string `json:"connectionIDString"` + Id string `json:"id,omitempty"` + IdString string `json:"idString"` + EntryId string `json:"connectionID"` + EntryIdString string `json:"connectionIDString"` Description string `json:"description"` FileName string `json:"filename"` IsPrivate bool `json:"isPrivate"` @@ -67,7 +67,7 @@ func (c *Client) newAttachmentRequest(attachment EntryAttachment) (string, error return "", fmt.Errorf("failed to unmarshal response body. error: %w", err) } - return attachment.ID, nil + return attachment.Id, nil } func (c *Client) uploadAttachment(fileBytes []byte, attachmentId string) error { diff --git a/entry_certificate.go b/entry_certificate.go index 2eab878..96bcc76 100644 --- a/entry_certificate.go +++ b/entry_certificate.go @@ -14,7 +14,7 @@ type EntryCertificateService service // EntryCertificate represents a certificate entry. type EntryCertificate struct { - ID string + Id string VaultId string Name string Description string @@ -31,7 +31,7 @@ type EntryCertificate struct { } type rawEntryCertificate struct { - ID string `json:"id,omitempty"` + Id string `json:"id,omitempty"` VaultId string `json:"repositoryId"` Name string `json:"name"` Description string `json:"description"` @@ -61,7 +61,7 @@ type entryCertificateData struct { // MarshalJSON implements the json.Marshaler interface. func (e EntryCertificate) MarshalJSON() ([]byte, error) { raw := rawEntryCertificate{ - ID: e.ID, + Id: e.Id, VaultId: e.VaultId, Name: e.Name, Description: e.Description, @@ -121,7 +121,7 @@ func (e *EntryCertificate) UnmarshalJSON(d []byte) error { } } - e.ID = raw.Data.ID + e.Id = raw.Data.Id e.VaultId = raw.Data.VaultId e.Name = raw.Data.Name e.Description = raw.Data.Description @@ -179,7 +179,7 @@ func (c *EntryCertificateService) GetFileContent(entryId string) ([]byte, error) // GetPassword returns the password of the entry specified by entry. func (c *EntryCertificateService) GetPassword(entry EntryCertificate) (EntryCertificate, error) { var entryPassword EntryCertificate - reqUrl, err := url.JoinPath(c.client.baseUri, entryEndpoint, entry.ID, "/sensitive-data") + reqUrl, err := url.JoinPath(c.client.baseUri, entryEndpoint, entry.Id, "/sensitive-data") if err != nil { return EntryCertificate{}, fmt.Errorf("failed to build entry url. error: %w", err) } @@ -243,7 +243,7 @@ func (c *EntryCertificateService) new(entry EntryCertificate, content []byte) (E if content != nil { attachment := EntryAttachment{ - EntryID: entry.ID, + EntryId: entry.Id, FileName: entry.CertificateIdentifier, Size: len(content), IsPrivate: true, @@ -265,7 +265,7 @@ func (c *EntryCertificateService) new(entry EntryCertificate, content []byte) (E // Update updates an EntryCertificate based on entry. Will replace all other fields whether included or not. func (c *EntryCertificateService) Update(entry EntryCertificate) (EntryCertificate, error) { - oldEntry, err := c.Get(entry.ID) + oldEntry, err := c.Get(entry.Id) if err != nil { return EntryCertificate{}, fmt.Errorf("error while fetching entry. error: %w", err) } diff --git a/entry_certificate_test.go b/entry_certificate_test.go index 473a9b4..99d1ef7 100644 --- a/entry_certificate_test.go +++ b/entry_certificate_test.go @@ -25,7 +25,7 @@ var ( func Test_EntryCertificate(t *testing.T) { testCertificateFilePath = os.Getenv("TEST_CERTIFICATE_FILE_PATH") testCertificateEntryId = os.Getenv("TEST_CERTIFICATE_ENTRY_ID") - testCertificateEntry.ID = testCertificateEntryId + testCertificateEntry.Id = testCertificateEntryId testCertificateEntry.VaultId = testVaultId location, err := time.LoadLocation("America/Montreal") if err != nil { @@ -44,7 +44,7 @@ func Test_EntryCertificate(t *testing.T) { func test_GetCertificateEntry(t *testing.T) { testGetEntry := testCertificateEntry - entry, err := testClient.Entries.Certificate.Get(testGetEntry.ID) + entry, err := testClient.Entries.Certificate.Get(testGetEntry.Id) if err != nil { t.Fatal(err) } @@ -69,7 +69,7 @@ func test_GetCertificateEntry(t *testing.T) { func test_NewCertificateEntryFile(t *testing.T) { entry := testCertificateEntry - entry.ID = "" + entry.Id = "" file, err := os.Open(testCertificateFilePath) if err != nil { t.Fatal(err) @@ -93,7 +93,7 @@ func test_NewCertificateEntryFile(t *testing.T) { t.Fatal(err) } - returnedFileBytes, err := testClient.Entries.Certificate.GetFileContent(newEntry.ID) + returnedFileBytes, err := testClient.Entries.Certificate.GetFileContent(newEntry.Id) if err != nil { t.Fatal(err) } @@ -102,7 +102,7 @@ func test_NewCertificateEntryFile(t *testing.T) { t.Fatalf("fetched file content did not match test file content. Expected %#v, got %#v", fileBytes, returnedFileBytes) } - entry.ID = newEntry.ID + entry.Id = newEntry.Id entry.data = newEntry.data newEntry, err = testClient.Entries.Certificate.GetPassword(newEntry) if err != nil { @@ -124,7 +124,7 @@ func test_NewCertificateEntryFile(t *testing.T) { func test_NewCertificateEntryURL(t *testing.T) { entry := testCertificateEntry - entry.ID = "" + entry.Id = "" entry.CertificateIdentifier = "https://devolutions.net/" newEntry, err := testClient.Entries.Certificate.NewURL(entry) @@ -132,7 +132,7 @@ func test_NewCertificateEntryURL(t *testing.T) { t.Fatal(err) } - entry.ID = newEntry.ID + entry.Id = newEntry.Id entry.data = newEntry.data newEntry, err = testClient.Entries.Certificate.GetPassword(newEntry) if err != nil { @@ -177,12 +177,12 @@ func test_UpdateCertificateEntry(t *testing.T) { } func test_DeleteCertificateEntry(t *testing.T) { - err := testClient.Entries.Certificate.Delete(testNewCertificateEntryURL.ID) + err := testClient.Entries.Certificate.Delete(testNewCertificateEntryURL.Id) if err != nil { t.Fatal(err) } - err = testClient.Entries.Certificate.Delete(testNewCertificateEntryFile.ID) + err = testClient.Entries.Certificate.Delete(testNewCertificateEntryFile.Id) if err != nil { t.Fatal(err) } diff --git a/entry_credential.go b/entry_credential.go index b85ae83..1a63ce5 100644 --- a/entry_credential.go +++ b/entry_credential.go @@ -26,15 +26,15 @@ type EntryCredentialAccessCodeData struct { } type EntryCredentialApiKeyData struct { - ApiID string `json:"apiId,omitempty"` + ApiId string `json:"apiId,omitempty"` ApiKey string `json:"apiKey,omitempty"` - TenantID string `json:"tenantId,omitempty"` + TenantId string `json:"tenantId,omitempty"` } type EntryCredentialAzureServicePrincipalData struct { - ClientID string `json:"clientId,omitempty"` + ClientId string `json:"clientId,omitempty"` ClientSecret string `json:"clientSecret,omitempty"` - TenantID string `json:"tenantId,omitempty"` + TenantId string `json:"tenantId,omitempty"` } type EntryCredentialConnectionStringData struct { @@ -145,13 +145,13 @@ func (c *EntryCredentialService) validateEntry(entry *Entry) error { // Get returns a single EntryCredential func (c *EntryCredentialService) Get(entry Entry) (Entry, error) { - return c.GetById(entry.VaultId, entry.ID) + return c.GetById(entry.VaultId, entry.Id) } -// Get returns a single EntryCredential based on vault ID and entry ID. +// Get returns a single EntryCredential based on vault Id and entry Id. func (c *EntryCredentialService) GetById(vaultId string, entryId string) (Entry, error) { if vaultId == "" || entryId == "" { - return Entry{}, fmt.Errorf("both entry ID and vault ID are required") + return Entry{}, fmt.Errorf("both entry Id and vault Id are required") } var entry Entry @@ -234,8 +234,8 @@ func (c *EntryCredentialService) Update(entry Entry) (Entry, error) { return Entry{}, err } - if entry.ID == "" { - return Entry{}, fmt.Errorf("entry ID is required for updates") + if entry.Id == "" { + return Entry{}, fmt.Errorf("entry Id is required for updates") } updateEntryRequest := struct { @@ -252,7 +252,7 @@ func (c *EntryCredentialService) Update(entry Entry) (Entry, error) { Tags: entry.Tags, } - entryUri := entryPublicEndpointReplacer(entry.VaultId, entry.ID) + entryUri := entryPublicEndpointReplacer(entry.VaultId, entry.Id) reqUrl, err := url.JoinPath(c.client.baseUri, entryUri) if err != nil { return Entry{}, fmt.Errorf("failed to build entry url. error: %w", err) @@ -268,7 +268,7 @@ func (c *EntryCredentialService) Update(entry Entry) (Entry, error) { return Entry{}, fmt.Errorf("error while updating entry. error: %w", err) } - entry, err = c.GetById(entry.VaultId, entry.ID) + entry, err = c.GetById(entry.VaultId, entry.Id) if err != nil { return Entry{}, fmt.Errorf("update succeeded but failed to fetch updated entry: %w", err) } @@ -278,13 +278,13 @@ func (c *EntryCredentialService) Update(entry Entry) (Entry, error) { // Delete deletes an entry func (c *EntryCredentialService) Delete(e Entry) error { - return c.DeleteByID(e.VaultId, e.ID) + return c.DeleteById(e.VaultId, e.Id) } -// Delete deletes an entry based on vault ID and entry ID -func (c *EntryCredentialService) DeleteByID(vaultId string, entryId string) error { +// Delete deletes an entry based on vault Id and entry Id +func (c *EntryCredentialService) DeleteById(vaultId string, entryId string) error { if vaultId == "" || entryId == "" { - return fmt.Errorf("both entry ID and vault ID are required") + return fmt.Errorf("both entry Id and vault Id are required") } entryUri := entryPublicEndpointReplacer(vaultId, entryId) diff --git a/entry_credential_test.go b/entry_credential_test.go index 33559ba..bf84a79 100644 --- a/entry_credential_test.go +++ b/entry_credential_test.go @@ -5,22 +5,22 @@ import ( ) var ( - testCredentialAccessCodeEntryID *string + testCredentialAccessCodeEntryId *string testCredentialAccessCodeEntry *Entry - testCredentialApiKeyEntryID *string + testCredentialApiKeyEntryId *string testCredentialApiKeyEntry *Entry - testCredentialAzureServicePrincipalEntryID *string + testCredentialAzureServicePrincipalEntryId *string testCredentialAzureServicePrincipalEntry *Entry - testCredentialConnectionStringEntryID *string + testCredentialConnectionStringEntryId *string testCredentialConnectionStringEntry *Entry - testCredentialDefaultEntryID *string + testCredentialDefaultEntryId *string testCredentialDefaultEntry *Entry - testCredentialPrivateKeyEntryID *string + testCredentialPrivateKeyEntryId *string testCredentialPrivateKeyEntry *Entry ) @@ -51,7 +51,7 @@ func test_NewUserEntry(t *testing.T) { // Credential/AccessCode testCredentialAccessCodeEntry := Entry{ - ID: "", + Id: "", VaultId: testVaultId, Name: "TestGoDvlsAccessCode", Path: "go-dvls\\accesscode", @@ -64,20 +64,20 @@ func test_NewUserEntry(t *testing.T) { Tags: []string{"accesscode"}, } - newCredentialAccessCodeEntryID, err := testClient.Entries.Credential.New(testCredentialAccessCodeEntry) + newCredentialAccessCodeEntryId, err := testClient.Entries.Credential.New(testCredentialAccessCodeEntry) if err != nil { t.Fatalf("Failed to create new AccessCode entry: %v", err) } - if newCredentialAccessCodeEntryID == "" { - t.Fatal("New AccessCode entry ID is empty after creation.") + if newCredentialAccessCodeEntryId == "" { + t.Fatal("New AccessCode entry Id is empty after creation.") } - testCredentialAccessCodeEntryID = &newCredentialAccessCodeEntryID + testCredentialAccessCodeEntryId = &newCredentialAccessCodeEntryId // Credential/ApiKey testCredentialApiKeyEntry := Entry{ - ID: "", + Id: "", VaultId: testVaultId, Name: "TestGoDvlsApiKey", Path: "go-dvls\\apikey", @@ -85,27 +85,27 @@ func test_NewUserEntry(t *testing.T) { Type: EntryCredentialType, SubType: EntryCredentialSubTypeApiKey, Data: EntryCredentialApiKeyData{ - ApiID: "abcd1234-abcd-1234-abcd-1234abcd1234", + ApiId: "abcd1234-abcd-1234-abcd-1234abcd1234", ApiKey: "123-abc", - TenantID: "00000000-aaaa-bbbb-cccc-000000000000", + TenantId: "00000000-aaaa-bbbb-cccc-000000000000", }, Tags: []string{"apikey"}, } - newCredentialApiKeyEntryID, err := testClient.Entries.Credential.New(testCredentialApiKeyEntry) + newCredentialApiKeyEntryId, err := testClient.Entries.Credential.New(testCredentialApiKeyEntry) if err != nil { t.Fatalf("Failed to create new ApiKey entry: %v", err) } - if newCredentialApiKeyEntryID == "" { - t.Fatal("New ApiKey entry ID is empty after creation.") + if newCredentialApiKeyEntryId == "" { + t.Fatal("New ApiKey entry Id is empty after creation.") } - testCredentialApiKeyEntryID = &newCredentialApiKeyEntryID + testCredentialApiKeyEntryId = &newCredentialApiKeyEntryId // Credential/AzureServicePrincipal testCredentialAzureServicePrincipalEntry := Entry{ - ID: "", + Id: "", VaultId: testVaultId, Name: "TestGoDvlsAzureServicePrincipal", Path: "go-dvls\\azureserviceprincipal", @@ -113,27 +113,27 @@ func test_NewUserEntry(t *testing.T) { Type: EntryCredentialType, SubType: EntryCredentialSubTypeAzureServicePrincipal, Data: EntryCredentialAzureServicePrincipalData{ - ClientID: "abcd1234-abcd-1234-abcd-1234abcd1234", + ClientId: "abcd1234-abcd-1234-abcd-1234abcd1234", ClientSecret: "123-abc", - TenantID: "00000000-aaaa-bbbb-cccc-000000000000", + TenantId: "00000000-aaaa-bbbb-cccc-000000000000", }, Tags: []string{"azureserviceprincipal"}, } - newCredentialAzureServicePrincipalEntryID, err := testClient.Entries.Credential.New(testCredentialAzureServicePrincipalEntry) + newCredentialAzureServicePrincipalEntryId, err := testClient.Entries.Credential.New(testCredentialAzureServicePrincipalEntry) if err != nil { t.Fatalf("Failed to create new AzureServicePrincipal entry: %v", err) } - if newCredentialAzureServicePrincipalEntryID == "" { - t.Fatal("New AzureServicePrincipal entry ID is empty after creation.") + if newCredentialAzureServicePrincipalEntryId == "" { + t.Fatal("New AzureServicePrincipal entry Id is empty after creation.") } - testCredentialAzureServicePrincipalEntryID = &newCredentialAzureServicePrincipalEntryID + testCredentialAzureServicePrincipalEntryId = &newCredentialAzureServicePrincipalEntryId // Credential/ConnectionString testCredentialConnectionStringEntry := Entry{ - ID: "", + Id: "", VaultId: testVaultId, Name: "TestGoDvlsConnectionString", Path: "go-dvls\\connectionstring", @@ -146,16 +146,16 @@ func test_NewUserEntry(t *testing.T) { Tags: []string{"connectionstring"}, } - newCredentialConnectionStringEntryID, err := testClient.Entries.Credential.New(testCredentialConnectionStringEntry) + newCredentialConnectionStringEntryId, err := testClient.Entries.Credential.New(testCredentialConnectionStringEntry) if err != nil { t.Fatalf("Failed to create new ConnectionString entry: %v", err) } - if newCredentialConnectionStringEntryID == "" { - t.Fatal("New ConnectionString entry ID is empty after creation.") + if newCredentialConnectionStringEntryId == "" { + t.Fatal("New ConnectionString entry Id is empty after creation.") } - testCredentialConnectionStringEntryID = &newCredentialConnectionStringEntryID + testCredentialConnectionStringEntryId = &newCredentialConnectionStringEntryId // Credential/Default testCredentialDefaultEntry := Entry{ @@ -173,20 +173,20 @@ func test_NewUserEntry(t *testing.T) { Tags: []string{"usernamepassword"}, } - newCredentialDefaultEntryID, err := testClient.Entries.Credential.New(testCredentialDefaultEntry) + newCredentialDefaultEntryId, err := testClient.Entries.Credential.New(testCredentialDefaultEntry) if err != nil { t.Fatalf("Failed to create new Default entry: %v", err) } - if newCredentialDefaultEntryID == "" { - t.Fatal("New Default entry ID is empty after creation.") + if newCredentialDefaultEntryId == "" { + t.Fatal("New Default entry Id is empty after creation.") } - testCredentialDefaultEntryID = &newCredentialDefaultEntryID + testCredentialDefaultEntryId = &newCredentialDefaultEntryId // Credential/PrivateKey testCredentialPrivateKeyEntry := Entry{ - ID: "", + Id: "", VaultId: testVaultId, Name: "TestGoDvlsPrivateKey", Path: "go-dvls\\privatekey", @@ -202,87 +202,87 @@ func test_NewUserEntry(t *testing.T) { Tags: []string{"testtag"}, } - newCredentialPrivateKeyEntryID, err := testClient.Entries.Credential.New(testCredentialPrivateKeyEntry) + newCredentialPrivateKeyEntryId, err := testClient.Entries.Credential.New(testCredentialPrivateKeyEntry) if err != nil { t.Fatalf("Failed to create new PrivateKey entry: %v", err) } - if newCredentialPrivateKeyEntryID == "" { - t.Fatal("New PrivateKey entry ID is empty after creation.") + if newCredentialPrivateKeyEntryId == "" { + t.Fatal("New PrivateKey entry Id is empty after creation.") } - testCredentialPrivateKeyEntryID = &newCredentialPrivateKeyEntryID + testCredentialPrivateKeyEntryId = &newCredentialPrivateKeyEntryId } func test_GetUserEntry(t *testing.T) { // Credential/AccessCode - credentialAccessCodeEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialAccessCodeEntryID) + credentialAccessCodeEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialAccessCodeEntryId) if err != nil { t.Fatalf("Failed to get AccessCode entry: %v", err) } - if credentialAccessCodeEntry.ID == "" { - t.Fatalf("AccessCode entry ID is empty after GET: %v", credentialAccessCodeEntry) + if credentialAccessCodeEntry.Id == "" { + t.Fatalf("AccessCode entry Id is empty after GET: %v", credentialAccessCodeEntry) } testCredentialAccessCodeEntry = &credentialAccessCodeEntry // Credential/ApiKey - credentialApiKeyEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialApiKeyEntryID) + credentialApiKeyEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialApiKeyEntryId) if err != nil { t.Fatalf("Failed to get ApiKey entry: %v", err) } - if credentialApiKeyEntry.ID == "" { - t.Fatalf("ApiKey entry ID is empty after GET: %v", credentialApiKeyEntry) + if credentialApiKeyEntry.Id == "" { + t.Fatalf("ApiKey entry Id is empty after GET: %v", credentialApiKeyEntry) } testCredentialApiKeyEntry = &credentialApiKeyEntry // Credential/AzureServicePrincipal - credentialAzureServicePrincipalEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialAzureServicePrincipalEntryID) + credentialAzureServicePrincipalEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialAzureServicePrincipalEntryId) if err != nil { t.Fatalf("Failed to get AzureServicePrincipal entry: %v", err) } - if credentialAzureServicePrincipalEntry.ID == "" { - t.Fatalf("AzureServicePrincipal entry ID is empty after GET: %v", credentialAzureServicePrincipalEntry) + if credentialAzureServicePrincipalEntry.Id == "" { + t.Fatalf("AzureServicePrincipal entry Id is empty after GET: %v", credentialAzureServicePrincipalEntry) } testCredentialAzureServicePrincipalEntry = &credentialAzureServicePrincipalEntry // Credential/ConnectionString - credentialConnectionStringEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialConnectionStringEntryID) + credentialConnectionStringEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialConnectionStringEntryId) if err != nil { t.Fatalf("Failed to get ConnectionString entry: %v", err) } - if credentialConnectionStringEntry.ID == "" { - t.Fatalf("ConnectionString entry ID is empty after GET: %v", credentialConnectionStringEntry) + if credentialConnectionStringEntry.Id == "" { + t.Fatalf("ConnectionString entry Id is empty after GET: %v", credentialConnectionStringEntry) } testCredentialConnectionStringEntry = &credentialConnectionStringEntry // Credential/Default - credentialDefaultEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialDefaultEntryID) + credentialDefaultEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialDefaultEntryId) if err != nil { t.Fatalf("Failed to get Default entry: %v", err) } - if credentialDefaultEntry.ID == "" { - t.Fatalf("Default entry ID is empty after GET: %v", credentialDefaultEntry) + if credentialDefaultEntry.Id == "" { + t.Fatalf("Default entry Id is empty after GET: %v", credentialDefaultEntry) } testCredentialDefaultEntry = &credentialDefaultEntry // Credential/PrivateKey - credentialPrivateKeyEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialPrivateKeyEntryID) + credentialPrivateKeyEntry, err := testClient.Entries.Credential.GetById(testVaultId, *testCredentialPrivateKeyEntryId) if err != nil { t.Fatalf("Failed to get PrivateKey entry: %v", err) } - if credentialPrivateKeyEntry.ID == "" { - t.Fatalf("PrivateKey entry ID is empty after GET: %v", credentialPrivateKeyEntry) + if credentialPrivateKeyEntry.Id == "" { + t.Fatalf("PrivateKey entry Id is empty after GET: %v", credentialPrivateKeyEntry) } testCredentialPrivateKeyEntry = &credentialPrivateKeyEntry @@ -417,7 +417,7 @@ func test_DeleteUserEntry(t *testing.T) { _, err = testClient.Entries.Credential.Get(*testCredentialAccessCodeEntry) if err == nil { - t.Fatalf("AccessCode entry still exists after deletion: %s", *testCredentialAccessCodeEntryID) + t.Fatalf("AccessCode entry still exists after deletion: %s", *testCredentialAccessCodeEntryId) } // Credential/ApiKey @@ -428,7 +428,7 @@ func test_DeleteUserEntry(t *testing.T) { _, err = testClient.Entries.Credential.Get(*testCredentialApiKeyEntry) if err == nil { - t.Fatalf("ApiKey entry still exists after deletion: %s", *testCredentialApiKeyEntryID) + t.Fatalf("ApiKey entry still exists after deletion: %s", *testCredentialApiKeyEntryId) } // Credential/AzureServicePrincipal @@ -439,7 +439,7 @@ func test_DeleteUserEntry(t *testing.T) { _, err = testClient.Entries.Credential.Get(*testCredentialAzureServicePrincipalEntry) if err == nil { - t.Fatalf("AzureServicePrincipal entry still exists after deletion: %s", *testCredentialAzureServicePrincipalEntryID) + t.Fatalf("AzureServicePrincipal entry still exists after deletion: %s", *testCredentialAzureServicePrincipalEntryId) } // Credential/ConnectionString @@ -450,7 +450,7 @@ func test_DeleteUserEntry(t *testing.T) { _, err = testClient.Entries.Credential.Get(*testCredentialConnectionStringEntry) if err == nil { - t.Fatalf("ConnectionString entry still exists after deletion: %s", *testCredentialConnectionStringEntryID) + t.Fatalf("ConnectionString entry still exists after deletion: %s", *testCredentialConnectionStringEntryId) } // Credential/Default @@ -461,7 +461,7 @@ func test_DeleteUserEntry(t *testing.T) { _, err = testClient.Entries.Credential.Get(*testCredentialDefaultEntry) if err == nil { - t.Fatalf("Default entry still exists after deletion: %s", *testCredentialDefaultEntryID) + t.Fatalf("Default entry still exists after deletion: %s", *testCredentialDefaultEntryId) } // Credential/PrivateKey @@ -472,6 +472,6 @@ func test_DeleteUserEntry(t *testing.T) { _, err = testClient.Entries.Credential.Get(*testCredentialPrivateKeyEntry) if err == nil { - t.Fatalf("PrivateKey entry still exists after deletion: %s", *testCredentialPrivateKeyEntryID) + t.Fatalf("PrivateKey entry still exists after deletion: %s", *testCredentialPrivateKeyEntryId) } } diff --git a/entry_host.go b/entry_host.go index 104d62d..9ac8f73 100644 --- a/entry_host.go +++ b/entry_host.go @@ -11,7 +11,7 @@ type EntryHostService service // EntryHost represents a host entry in DVLS type EntryHost struct { - ID string `json:"id,omitempty"` + Id string `json:"id,omitempty"` VaultId string `json:"repositoryId"` EntryName string `json:"name"` Description string `json:"description"` @@ -27,7 +27,7 @@ type EntryHost struct { // MarshalJSON implements the json.Marshaler interface. func (e EntryHost) MarshalJSON() ([]byte, error) { raw := struct { - ID string `json:"id,omitempty"` + Id string `json:"id,omitempty"` RepositoryId string `json:"repositoryId"` Name string `json:"name"` Description string `json:"description"` @@ -53,7 +53,7 @@ func (e EntryHost) MarshalJSON() ([]byte, error) { Keywords string `json:"keywords"` }{} - raw.ID = e.ID + raw.Id = e.Id raw.Keywords = sliceToKeywords(e.Tags) raw.Description = e.Description raw.RepositoryId = e.VaultId @@ -79,7 +79,7 @@ func (e EntryHost) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaler interface. func (e *EntryHost) UnmarshalJSON(d []byte) error { raw := struct { - ID string `json:"id"` + Id string `json:"id"` Description string `json:"description"` Name string `json:"name"` Group string `json:"group"` @@ -96,7 +96,7 @@ func (e *EntryHost) UnmarshalJSON(d []byte) error { return err } - e.ID = raw.ID + e.Id = raw.Id e.EntryName = raw.Name e.ConnectionType = raw.ConnectionType e.ConnectionSubType = raw.ConnectionSubType @@ -165,7 +165,7 @@ func (c *EntryHostService) GetHostDetails(entry EntryHost) (EntryHost, error) { Data string `json:"data"` } - reqUrl, err := url.JoinPath(c.client.baseUri, entryEndpoint, entry.ID, "/sensitive-data") + reqUrl, err := url.JoinPath(c.client.baseUri, entryEndpoint, entry.Id, "/sensitive-data") if err != nil { return EntryHost{}, fmt.Errorf("failed to build entry url. error: %w", err) } diff --git a/entry_host_test.go b/entry_host_test.go index 580363e..c1850fb 100644 --- a/entry_host_test.go +++ b/entry_host_test.go @@ -24,7 +24,7 @@ const ( func Test_EntryHost(t *testing.T) { testHostEntryId = os.Getenv("TEST_HOST_ENTRY_ID") - testHostEntry.ID = testHostEntryId + testHostEntry.Id = testHostEntryId testHostEntry.VaultId = testVaultId testHostEntry.HostDetails = EntryHostAuthDetails{ Username: testHostUsername, @@ -36,7 +36,7 @@ func Test_EntryHost(t *testing.T) { } func test_GetHostEntry(t *testing.T) { - entry, err := testClient.Entries.Host.Get(testHostEntry.ID) + entry, err := testClient.Entries.Host.Get(testHostEntry.Id) if err != nil { t.Fatal(err) } @@ -48,7 +48,7 @@ func test_GetHostEntry(t *testing.T) { } func test_GetHostDetails(t *testing.T) { - entry, err := testClient.Entries.Host.Get(testHostEntry.ID) + entry, err := testClient.Entries.Host.Get(testHostEntry.Id) if err != nil { t.Fatal(err) } diff --git a/entry_website.go b/entry_website.go index f3136e6..bf23115 100644 --- a/entry_website.go +++ b/entry_website.go @@ -11,7 +11,7 @@ type EntryWebsiteService service // EntryWebsite represents a website entry in DVLS type EntryWebsite struct { - ID string `json:"id,omitempty"` + Id string `json:"id,omitempty"` VaultId string `json:"repositoryId"` EntryName string `json:"name"` Description string `json:"description"` @@ -27,7 +27,7 @@ type EntryWebsite struct { // MarshalJSON implements the json.Marshaler interface. func (e EntryWebsite) MarshalJSON() ([]byte, error) { raw := struct { - ID string `json:"id,omitempty"` + Id string `json:"id,omitempty"` RepositoryId string `json:"repositoryId"` Name string `json:"name"` Description string `json:"description"` @@ -53,7 +53,7 @@ func (e EntryWebsite) MarshalJSON() ([]byte, error) { Keywords string `json:"keywords"` }{} - raw.ID = e.ID + raw.Id = e.Id raw.Keywords = sliceToKeywords(e.Tags) raw.Description = e.Description raw.RepositoryId = e.VaultId @@ -79,7 +79,7 @@ func (e EntryWebsite) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaler interface. func (e *EntryWebsite) UnmarshalJSON(d []byte) error { raw := struct { - ID string `json:"id"` + Id string `json:"id"` Description string `json:"description"` Name string `json:"name"` Group string `json:"group"` @@ -96,7 +96,7 @@ func (e *EntryWebsite) UnmarshalJSON(d []byte) error { return err } - e.ID = raw.ID + e.Id = raw.Id e.EntryName = raw.Name e.ConnectionType = raw.ConnectionType e.ConnectionSubType = raw.ConnectionSubType @@ -169,7 +169,7 @@ func (c *EntryWebsiteService) GetWebsiteDetails(entry EntryWebsite) (EntryWebsit Data string `json:"data"` } - reqUrl, err := url.JoinPath(c.client.baseUri, entryEndpoint, entry.ID, "/sensitive-data") + reqUrl, err := url.JoinPath(c.client.baseUri, entryEndpoint, entry.Id, "/sensitive-data") if err != nil { return EntryWebsite{}, fmt.Errorf("failed to build entry url. error: %w", err) } diff --git a/entry_website_test.go b/entry_website_test.go index d7271b1..8d0bbc0 100644 --- a/entry_website_test.go +++ b/entry_website_test.go @@ -26,7 +26,7 @@ const ( func Test_EntryWebsite(t *testing.T) { testWebsiteEntryId = os.Getenv("TEST_WEBSITE_ENTRY_ID") - testWebsiteEntry.ID = testWebsiteEntryId + testWebsiteEntry.Id = testWebsiteEntryId testWebsiteEntry.VaultId = testVaultId testWebsiteEntry.WebsiteDetails = EntryWebsiteAuthDetails{ Username: testWebsiteUsername, @@ -40,7 +40,7 @@ func Test_EntryWebsite(t *testing.T) { } func test_GetWebsiteEntry(t *testing.T) { - entry, err := testClient.Entries.Website.Get(testWebsiteEntry.ID) + entry, err := testClient.Entries.Website.Get(testWebsiteEntry.Id) if err != nil { t.Fatal(err) } @@ -52,7 +52,7 @@ func test_GetWebsiteEntry(t *testing.T) { } func test_GetWebsiteDetails(t *testing.T) { - entry, err := testClient.Entries.Website.Get(testWebsiteEntry.ID) + entry, err := testClient.Entries.Website.Get(testWebsiteEntry.Id) if err != nil { t.Fatal(err) } diff --git a/vaults.go b/vaults.go index 21c9b48..ee0c1c6 100644 --- a/vaults.go +++ b/vaults.go @@ -12,7 +12,7 @@ type Vaults service // Vault represents a DVLS vault. Contains relevant vault information. type Vault struct { - ID string + Id string Name string Description string SecurityLevel VaultSecurityLevel @@ -70,7 +70,7 @@ func (v *Vault) UnmarshalJSON(b []byte) error { } vault := Vault{ - ID: raw.Data.Id, + Id: raw.Data.Id, Name: raw.Data.Name, Description: raw.Data.Description, SecurityLevel: securityLevel, @@ -101,8 +101,8 @@ func (v Vault) MarshalJSON() ([]byte, error) { raw.Name = v.Name raw.Description = v.Description - raw.Id = v.ID - raw.IdString = v.ID + raw.Id = v.Id + raw.IdString = v.Id raw.RepositorySettings.VaultSecurityLevel = &securityLevel raw.RepositorySettings.VaultAllowAccessRequestRole = int(v.Visibility) @@ -176,7 +176,7 @@ func (c *Vaults) New(vault Vault, options *VaultOptions) error { // Update updates a Vault based on vault. func (c *Vaults) Update(vault Vault, options *VaultOptions) error { - _, err := c.client.Vaults.Get(vault.ID) + _, err := c.client.Vaults.Get(vault.Id) if err != nil { return fmt.Errorf("error while fetching vault. error: %w", err) } diff --git a/vaults_test.go b/vaults_test.go index 5a7f7be..f7532f1 100644 --- a/vaults_test.go +++ b/vaults_test.go @@ -15,13 +15,13 @@ var testVault Vault = Vault{ } var testNewVault Vault = Vault{ - ID: testNewVaultId, + Id: testNewVaultId, Name: "go-dvls new", Description: "Test", } func Test_Vaults(t *testing.T) { - testVault.ID = testVaultId + testVault.Id = testVaultId t.Run("GetVault", test_GetVault) t.Run("NewVault", test_NewVault) t.Run("UpdateVault", test_UpdateVault) @@ -48,7 +48,7 @@ func test_NewVault(t *testing.T) { t.Fatal(err) } - vault, err := testClient.Vaults.Get(testNewVault.ID) + vault, err := testClient.Vaults.Get(testNewVault.Id) if err != nil { t.Fatal(err) } @@ -71,7 +71,7 @@ func test_UpdateVault(t *testing.T) { t.Fatal(err) } - valid, err := testClient.Vaults.ValidatePassword(testNewVault.ID, testNewVaultPassword) + valid, err := testClient.Vaults.ValidatePassword(testNewVault.Id, testNewVaultPassword) if err != nil { t.Fatal(err) } @@ -80,7 +80,7 @@ func test_UpdateVault(t *testing.T) { t.Fatal("vault password validation failed, expected ", testNewVaultPassword) } - vault, err := testClient.Vaults.Get(testNewVault.ID) + vault, err := testClient.Vaults.Get(testNewVault.Id) if err != nil { t.Fatal(err) } @@ -94,7 +94,7 @@ func test_UpdateVault(t *testing.T) { } func test_DeleteVault(t *testing.T) { - err := testClient.Vaults.Delete(testNewVault.ID) + err := testClient.Vaults.Delete(testNewVault.Id) if err != nil { t.Fatal(err) }