Skip to content

Commit b1d0159

Browse files
authored
add DeletePackagesAssociatedWithReleases property (#336)
1 parent 36669bf commit b1d0159

5 files changed

Lines changed: 24 additions & 10 deletions

File tree

pkg/feeds/built_in_feed.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88

99
// BuiltInFeed represents a built-in feed.
1010
type BuiltInFeed struct {
11-
DeleteUnreleasedPackagesAfterDays int `json:"DeleteUnreleasedPackagesAfterDays"`
12-
DownloadAttempts int `json:"DownloadAttempts"`
13-
DownloadRetryBackoffSeconds int `json:"DownloadRetryBackoffSeconds"`
14-
IsBuiltInRepoSyncEnabled bool `json:"IsBuiltInRepoSyncEnabled"`
11+
DeletePackagesAssociatedWithReleases bool `json:"DeletePackagesAssociatedWithReleases"`
12+
DeleteUnreleasedPackagesAfterDays int `json:"DeleteUnreleasedPackagesAfterDays"`
13+
DownloadAttempts int `json:"DownloadAttempts"`
14+
DownloadRetryBackoffSeconds int `json:"DownloadRetryBackoffSeconds"`
15+
IsBuiltInRepoSyncEnabled bool `json:"IsBuiltInRepoSyncEnabled"`
1516

1617
feed
1718
}
@@ -23,11 +24,12 @@ func NewBuiltInFeed(name string) (*BuiltInFeed, error) {
2324
}
2425

2526
feed := BuiltInFeed{
26-
DeleteUnreleasedPackagesAfterDays: 30,
27-
DownloadAttempts: 5,
28-
DownloadRetryBackoffSeconds: 10,
29-
IsBuiltInRepoSyncEnabled: false,
30-
feed: *newFeed(name, FeedTypeBuiltIn),
27+
DeletePackagesAssociatedWithReleases: false,
28+
DeleteUnreleasedPackagesAfterDays: 30,
29+
DownloadAttempts: 5,
30+
DownloadRetryBackoffSeconds: 10,
31+
IsBuiltInRepoSyncEnabled: false,
32+
feed: *newFeed(name, FeedTypeBuiltIn),
3133
}
3234

3335
// validate to ensure that all expectations are met

pkg/feeds/feed_resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type FeedResource struct {
1212
AzureContainerRegistryOidcAuthentication *AzureContainerRegistryOidcAuthentication `json:"AzureContainerRegistryOidcAuthentication,omitempty"`
1313
ElasticContainerRegistryOidcAuthentication *AwsElasticContainerRegistryOidcAuthentication `json:"OidcAuthentication,omitempty"`
1414
APIVersion string `json:"ApiVersion,omitempty"`
15+
DeletePackagesAssociatedWithReleases bool `json:"DeletePackagesAssociatedWithReleases"`
1516
DeleteUnreleasedPackagesAfterDays int `json:"DeleteUnreleasedPackagesAfterDays"`
1617
DownloadAttempts int `json:"DownloadAttempts"`
1718
DownloadRetryBackoffSeconds int `json:"DownloadRetryBackoffSeconds"`

pkg/feeds/feed_utilities.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package feeds
33
import (
44
"errors"
55
"fmt"
6+
67
"github.com/OctopusDeploy/go-octopusdeploy/v2/internal"
78
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources"
89
)
@@ -39,6 +40,7 @@ func ToFeed(feedResource *FeedResource) (IFeed, error) {
3940
if err != nil {
4041
return nil, err
4142
}
43+
builtInFeed.DeletePackagesAssociatedWithReleases = feedResource.DeletePackagesAssociatedWithReleases
4244
builtInFeed.DeleteUnreleasedPackagesAfterDays = feedResource.DeleteUnreleasedPackagesAfterDays
4345
builtInFeed.DownloadAttempts = feedResource.DownloadAttempts
4446
builtInFeed.DownloadRetryBackoffSeconds = feedResource.DownloadRetryBackoffSeconds
@@ -189,6 +191,7 @@ func ToFeedResource(feed IFeed) (*FeedResource, error) {
189191
}
190192
case FeedTypeBuiltIn:
191193
builtInFeed := feed.(*BuiltInFeed)
194+
feedResource.DeletePackagesAssociatedWithReleases = builtInFeed.DeletePackagesAssociatedWithReleases
192195
feedResource.DeleteUnreleasedPackagesAfterDays = builtInFeed.DeleteUnreleasedPackagesAfterDays
193196
feedResource.DownloadAttempts = builtInFeed.DownloadAttempts
194197
feedResource.DownloadRetryBackoffSeconds = builtInFeed.DownloadRetryBackoffSeconds

pkg/feeds/feed_utilities_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package feeds
22

33
import (
4+
"testing"
5+
46
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
57
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources"
6-
"testing"
78
)
89

910
func TestUnexpectedFeed(t *testing.T) {

test/resources/feed_utilities_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@ func TestToFeed(t *testing.T) {
3333
require.NotNil(t, feed)
3434
require.NoError(t, err)
3535
require.EqualValues(t, feed.GetFeedType(), "AwsElasticContainerRegistry")
36+
37+
feedResource = feeds.NewFeedResource(internal.GetRandomName(), feeds.FeedTypeBuiltIn)
38+
feed, err = feeds.ToFeed(feedResource)
39+
require.NoError(t, err)
40+
builtinFeed, ok := feed.(*feeds.BuiltInFeed)
41+
require.True(t, ok)
42+
require.EqualValues(t, builtinFeed.DeletePackagesAssociatedWithReleases, false)
3643
}

0 commit comments

Comments
 (0)