Skip to content

Commit ac85871

Browse files
CLOUDP-277336: update endpoint removed change entries to include the sunset date (#302)
1 parent 4536f69 commit ac85871

File tree

5 files changed

+80
-17
lines changed

5 files changed

+80
-17
lines changed

tools/cli/internal/changelog/changelog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ func findChangelogEntry(changelog []*Entry, date, operationID, version, changeCo
457457
}
458458

459459
for _, v := range path.Versions {
460-
if v.Version != version {
460+
if version != "" && v.Version != version {
461461
continue
462462
}
463463

tools/cli/internal/changelog/changelog_test.go

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,68 @@ func TestFindChangelogEntry(t *testing.T) {
612612
changeCode string
613613
expectedEntries *Change
614614
}{
615-
615+
{
616+
name: "find changelog entry no API Version",
617+
entries: []*Entry{
618+
{
619+
Date: "2023-07-10",
620+
Paths: []*Path{
621+
{
622+
URI: "/api/atlas/v2/groups/{id}/clusters",
623+
HTTPMethod: "POST",
624+
OperationID: "createCluster",
625+
Tag: "Multi-Cloud Clusters",
626+
Versions: []*Version{
627+
{
628+
Version: "2023-02-01",
629+
StabilityLevel: "stable",
630+
ChangeType: "remove",
631+
Changes: []*Change{
632+
{
633+
Description: "endpoint removed",
634+
Code: "endpoint-removed",
635+
BackwardCompatible: true,
636+
}},
637+
},
638+
},
639+
},
640+
},
641+
},
642+
{
643+
Date: "2023-07-11",
644+
Paths: []*Path{
645+
{
646+
URI: "/api/atlas/v2/groups/{id}/clusters",
647+
HTTPMethod: "POST",
648+
OperationID: "createCluster",
649+
Tag: "Multi-Cloud Clusters",
650+
Versions: []*Version{
651+
{
652+
Version: "2023-02-01",
653+
StabilityLevel: "stable",
654+
ChangeType: "remove",
655+
Changes: []*Change{
656+
{
657+
Description: "endpoint removed",
658+
Code: "endpoint-removed",
659+
BackwardCompatible: true,
660+
}},
661+
},
662+
},
663+
},
664+
},
665+
},
666+
},
667+
operationID: "createCluster",
668+
date: "2023-07-10",
669+
version: "",
670+
changeCode: "endpoint-removed",
671+
expectedEntries: &Change{
672+
Description: "endpoint removed",
673+
Code: "endpoint-removed",
674+
BackwardCompatible: true,
675+
},
676+
},
616677
{
617678
name: "find changelog entry",
618679
entries: []*Entry{

tools/cli/internal/changelog/outputfilter/squash.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,35 +147,35 @@ func squashEntries(entries []*OasDiffEntry) ([]*OasDiffEntry, error) {
147147
entriesByIDandOperationID, hiddenEntriesByIDandOperationID := newEntriesMapPerIDAndOperationID(entries)
148148

149149
squashHandlers := newSquashHandlers()
150-
squashedEntries := []*OasDiffEntry{}
150+
squashedEntriesOut := []*OasDiffEntry{}
151151

152152
for _, entry := range entries {
153153
// if no squash handlers implemented for entry's code,
154154
// just append the entry to the result
155155
if _, ok := findHandler(entry.ID); !ok {
156-
squashedEntries = append(squashedEntries, entry)
156+
squashedEntriesOut = append(squashedEntriesOut, entry)
157157
continue
158158
}
159159
}
160160

161-
squashedEntriesNotHidden, err := appplySquashHandlerToMap(squashHandlers, entriesByIDandOperationID)
161+
squashedEntriesNotHidden, err := applySquashHandlerToMap(squashHandlers, entriesByIDandOperationID)
162162
if err != nil {
163163
return nil, err
164164
}
165165

166-
squashedEntriesHidden, err := appplySquashHandlerToMap(squashHandlers, hiddenEntriesByIDandOperationID)
166+
squashedEntriesHidden, err := applySquashHandlerToMap(squashHandlers, hiddenEntriesByIDandOperationID)
167167
if err != nil {
168168
return nil, err
169169
}
170170

171-
squashedEntries = append(squashedEntries, squashedEntriesNotHidden...)
172-
squashedEntries = append(squashedEntries, squashedEntriesHidden...)
171+
squashedEntriesOut = append(squashedEntriesOut, squashedEntriesNotHidden...)
172+
squashedEntriesOut = append(squashedEntriesOut, squashedEntriesHidden...)
173173

174-
return squashedEntries, nil
174+
return squashedEntriesOut, nil
175175
}
176176

177-
func appplySquashHandlerToMap(squashHandlers []handler, entriesMap map[string]map[string][]*OasDiffEntry) ([]*OasDiffEntry, error) {
178-
squashedEntries := []*OasDiffEntry{}
177+
func applySquashHandlerToMap(squashHandlers []handler, entriesMap map[string]map[string][]*OasDiffEntry) ([]*OasDiffEntry, error) {
178+
squashedEntriesOut := []*OasDiffEntry{}
179179
for _, handler := range squashHandlers {
180180
entryMapPerOperationID, ok := entriesMap[handler.id]
181181
if !ok {
@@ -187,9 +187,9 @@ func appplySquashHandlerToMap(squashHandlers []handler, entriesMap map[string]ma
187187
return nil, err
188188
}
189189

190-
squashedEntries = append(squashedEntries, sortEntriesByDescription(entries)...)
190+
squashedEntriesOut = append(squashedEntriesOut, sortEntriesByDescription(entries)...)
191191
}
192-
return squashedEntries, nil
192+
return squashedEntriesOut, nil
193193
}
194194

195195
func sortEntriesByDescription(entries []*OasDiffEntry) []*OasDiffEntry {

tools/cli/internal/changelog/sunset.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ func (m *Changelog) newOasDiffEntriesFromSunsetEndpoints(
4343
continue
4444
}
4545

46-
// Avoid adding duplicates in the changelog
47-
if findChangelogEntry(m.BaseChangelog, config.Revision.Sunset, operationID, version, endpointRemovedCode) == nil {
46+
// Avoid adding duplicates in the changelog.
47+
// Passing version="" to findChangelogEntry since the sunset date of the endpoint with API version "version"
48+
// is the same in all the specs.
49+
if findChangelogEntry(m.BaseChangelog, config.Revision.Sunset, operationID, "", endpointRemovedCode) == nil {
4850
changes = append(changes, &outputfilter.OasDiffEntry{
4951
Date: config.Revision.Sunset,
5052
ID: endpointRemovedCode,
51-
Text: "endpoint removed",
53+
Text: fmt.Sprintf("endpoint with API Version '%s' was removed as it has reached its sunset date '%s'", version, config.Revision.Sunset),
5254
Level: int(checker.ERR),
5355
Operation: config.Revision.HTTPMethod,
5456
OperationID: operationID,

tools/cli/internal/changelog/sunset_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func TestNewOasDiffEntriesFromSunsetEndpoints(t *testing.T) {
126126
Operation: "GET",
127127
OperationID: "listStreamInstances",
128128
Path: "/api/atlas/v2/groups/{id}/streams",
129-
Text: "endpoint removed",
129+
Text: "endpoint with API Version '2023-02-01' was removed as it has reached its sunset date '2023-07-12'",
130130
},
131131
}
132132

0 commit comments

Comments
 (0)