Skip to content

Commit 20d75cd

Browse files
authored
Utility scripts (#391)
* Allow staticcheck to run in GitHub Actions * Add .changes section to avoid CHANGELOG confilcts * Add current release note to CHANGELOG.md * Add links replacement script * Add documentation for .changes Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
1 parent 4ac1946 commit 20d75cd

30 files changed

+268
-1
lines changed

.changes/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Handling of CHANGELOG entries
2+
3+
## PR operations
4+
5+
* All PRs, instead of updating CHANGELOG.md directly, will create individual files in a directory .changes/$version
6+
* The files will be named `xxx-section_name.md`, where xxx is the PR number, and `section_name` is one of
7+
* features
8+
* improvements
9+
* bug-fixes
10+
* deprecations
11+
* notes
12+
* removals
13+
14+
* The changes files must NOT contain the header
15+
16+
* You can update the file `.changes/sections` to add more headers
17+
* To see the full change set for the current version (or an old one), use `./scripts/make-changelog.sh [version]`
18+
19+
20+
## Post release initialization
21+
22+
After a release, the changelog will be initialized with the following template:
23+
24+
```
25+
## $VERSION (Unreleased)
26+
27+
Changes in progress for v$VERSION are available at [.changes/v$VERSION](https://github.com/vmware/go-vcloud-director/tree/master/.changes/v$VERSION) until the release.
28+
```
29+
30+
Run `.changes/init.sh version` to get the needed text

.changes/init.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
VERSION=$1
4+
5+
if [ -z "$VERSION" ]
6+
then
7+
echo "Syntax: $0 VERSION (without initial 'v')"
8+
9+
exit 1
10+
fi
11+
12+
starts_with_v=$(echo $VERSION | grep '^v')
13+
if [ -n "$starts_with_v" ]
14+
then
15+
echo "The version should be without the initial 'v'"
16+
exit 1
17+
fi
18+
19+
echo "Copy the following lines at the top of CHANGELOG.md"
20+
echo ""
21+
echo ""
22+
echo "## $VERSION (Unreleased)"
23+
echo ""
24+
echo "Changes in progress for v$VERSION are available at [.changes/v$VERSION](https://github.com/vmware/go-vcloud-director/tree/master/.changes/v$VERSION) until the release."
25+
echo ""
26+

.changes/sections

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
features
2+
improvements
3+
bug-fixes
4+
deprecations
5+
notes
6+
removals
7+
breaking-changes

.changes/v2.12.0/364-deprecations.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Deprecated `vdc.GetEdgeGatewayRecordsType` [GH-364]
2+

.changes/v2.12.0/364-features.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Added method `vdc.QueryEdgeGateway` [GH-364]
2+

.changes/v2.12.0/367-improvements.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Only send xml.Header when payload is not empty (some WAFs block empty requests with XML header)
2+
[GH-367]
3+

.changes/v2.12.0/368-features.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
* Added NSX-T Firewall Group type (which represents a Security Group or an IP Set) support by using
2+
structures `NsxtFirewallGroup` and `NsxtFirewallGroupMemberVms`. The following methods are
3+
introduced for managing Security Groups and Ip Sets: `Vdc.CreateNsxtFirewallGroup`,
4+
`NsxtEdgeGateway.CreateNsxtFirewallGroup`, `Org.GetAllNsxtFirewallGroups`,
5+
`Vdc.GetAllNsxtFirewallGroups`, `Org.GetNsxtFirewallGroupByName`,
6+
`Vdc.GetNsxtFirewallGroupByName`, `NsxtEdgeGateway.GetNsxtFirewallGroupByName`,
7+
`Org.GetNsxtFirewallGroupById`, `Vdc.GetNsxtFirewallGroupById`,
8+
`NsxtEdgeGateway.GetNsxtFirewallGroupById`, `NsxtFirewallGroup.Update`,
9+
`NsxtFirewallGroup.Delete`, `NsxtFirewallGroup.GetAssociatedVms`,
10+
`NsxtFirewallGroup.IsSecurityGroup`, `NsxtFirewallGroup.IsIpSet`
11+
[GH-368]
12+
* Added methods Org.QueryVmList and Org.QueryVmById to find VM by ID in an Org
13+
[GH-368]
14+

.changes/v2.12.0/368-improvements.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* Improved test entity cleanup to find standalone VMs in any VDC (not only default NSX-V one)
2+
[GH-368]
3+
* Improved test entity cleanup to allow specifying parent VDC for vApp removals
4+
[GH-368]
5+
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* Field `types.Disk.Size` is replaced with `types.Disk.SizeMb` as size in Kilobytes is not supported in V33.0
2+
[GH-371]
3+
* Field `types.DiskRecordType.SizeB` is replaced with `types.DiskRecordType.SizeMb` as size in Kilobytes is not
4+
supported in V33.0 [GH-371]
5+

.changes/v2.12.0/371-improvements.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* Methods `GetVDCById` and `GetVDCByName` for `Org` now use queries behind the scenes because Org
2+
structure does not list child VDCs anymore [GH-371], [GH-376], [GH-382]
3+
* Methods `GetCatalogById` and `GetCatalogByName` for `Org` now use queries behind the scenes because Org
4+
structure does not list child Catalogs anymore [GH-371] [GH-376]
5+

.changes/v2.12.0/371-notes.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* Dropped support for VCD 9.7 which is EOL now [GH-371]
2+
* Bumped Default API Version to V33.0 [GH-371]
3+
* Drop legacy authentication mechanism (vcdAuthorize) and use only new Cloud API provided (vcdCloudApiAuthorize) as
4+
API V33.0 is sufficient for it [GH-371]
5+
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Added parameter `description` to method `vdc.ComposeRawVapp` [GH-372]
2+
* Added methods `vapp.Rename`, `vapp.UpdateDescription`, `vapp.UpdateNameDescription` [GH-372]
3+

.changes/v2.12.0/378-features.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Added `NsxtAppPortProfile` and `types.NsxtAppPortProfile` for NSX-T Application Port Profile management
2+
[GH-378]
3+

.changes/v2.12.0/378-improvements.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* Improved `OpenApiGetAllItems` to still follow pages in VCD endpoints with BUG which don't return 'nextPage' link for
2+
pagination [GH-378]
3+
* Improved LDAP container related tests to use correct port mapping for latest LDAP container version
4+
[GH-378]
5+
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* Added parameter `additionalHeader map[string]string` to functions `Client.OpenApiDeleteItem`, `Client.OpenApiGetAllItems`,
2+
`Client.OpenApiGetItem`, `Client.OpenApiPostItem`, `Client.OpenApiPutItem`, `Client.OpenApiPutItemAsync`,
3+
`Client.OpenApiPutItemSync` [GH-380]
4+
* Renamed functions `GetOpenApiRoleById` -> `GetRoleById`, `GetOpenApiRoleByName` -> `GetRoleByName`,
5+
`GetAllOpenApiRoles` -> `GetAllRoles` [GH-380]
6+

.changes/v2.12.0/380-deprecations.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Removed deprecated method `adminOrg.GetRole` [GH-380]
2+

.changes/v2.12.0/380-features.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
* Added Tenant Context management functions `Client.RemoveCustomHeader`, `Client.SetCustomHeader`, `WithHttpHeader`,
2+
and many private methods to retrieve tenant context down the hierarchy. More details in `CODING_GUIDELINES.md`
3+
[GH-380]
4+
* Added Rights management methods `AdminOrg.GetAllRights`, `AdminOrg.GetAllRightsCategories`, `AdminOrg.GetRightById`,
5+
`AdminOrg.GetRightByName`, `Client.GetAllRights`, `Client.GetAllRightsCategories`, `Client.GetRightById`,
6+
`Client.GetRightByName`, `client.GetRightsCategoryById`, `AdminOrg.GetRightsCategoryById` [GH-380]
7+
* Added Global Role management methods `Client.GetAllGlobalRoles`, `Client.CreateGlobalRole`, `Client.GetGlobalRoleById`,
8+
`Client.GetGlobalRoleByName`, `GlobalRole.AddRights`, `GlobalRole.Delete`, `GlobalRole.GetRights`,
9+
`GlobalRole.GetTenants`, `GlobalRole.PublishAllTenants`, `GlobalRole.PublishTenants`, `GlobalRole.RemoveAllRights`,
10+
`GlobalRole.RemoveRights`, `GlobalRole.ReplacePublishedTenants`, `GlobalRole.UnpublishAllTenants`,
11+
`GlobalRole.UnpublishTenants`, `GlobalRole.Update`, `GlobalRole.UpdateRights` [GH-380]
12+
* Added Rights Bundle management methods `Client.CreateRightsBundle`, `Client.GetAllRightsBundles`,
13+
`Client.GetRightsBundleById`, `Client.GetRightsBundleByName`, `RightsBundle.AddRights`, `RightsBundle.Delete`,
14+
`RightsBundle.GetRights`, `RightsBundle.GetTenants`, `RightsBundle.PublishAllTenants`, `RightsBundle.PublishTenants`,
15+
`RightsBundle.RemoveAllRights`, `RightsBundle.RemoveRights`, `RightsBundle.ReplacePublishedTenants`,
16+
`RightsBundle.UnpublishAllTenants`, `RightsBundle.UnpublishTenants`, `RightsBundle.Update`, `RightsBundle.UpdateRights`
17+
[GH-380]
18+
* Added Role managemnt methods `AdminOrg.GetAllRoles`, `AdminOrg.GetRoleById`, `AdminOrg.GetRoleByName`,
19+
`Client.GetAllRoles`, `Role.AddRights`, `Role.GetRights`, `Role.RemoveAllRights`, `Role.RemoveRights`, `Role.UpdateRights`
20+
[GH-380]
21+
* Added convenience function `FindMissingImpliedRights` [GH-380]
22+

.changes/v2.12.0/381-features.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Added methods `NsxtEdgeGateway.UpdateNsxtFirewall()`, `NsxtEdgeGateway.GetNsxtFirewall()`, `nsxtFirewall.DeleteAllRules()`,
2+
`nsxtFirewall.DeleteRuleById` [GH-381]
3+

.changes/v2.12.0/381-improvements.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Cleanup a few unnecessary type conversions detected by new staticcheck version
2+
[GH-381]
3+

.changes/v2.12.0/382-features.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* Added NSX-T NAT support with types `NsxtNatRule` and `types.NsxtNatRule` as well as methods `edge.GetAllNsxtNatRules`,
2+
`edge.GetNsxtNatRuleByName`, `edge.GetNsxtNatRuleById`, `edge.CreateNatRule`, `nsxtNatRule.Update`, `nsxtNatRule.Delete`,
3+
`nsxtNatRule.IsEqualTo` [GH-382]
4+

.changes/v2.12.0/385-features.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Added `NsxtIpSecVpnTunnel` and `types.NsxtIpSecVpnTunnel` for NSX-T IPsec VPN Tunnel configuration
2+
[GH-385]
3+

.changes/v2.12.0/387-bug-fixes.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Deprecated methods `vdc.ComposeRawVApp` and `vdc.ComposeVApp` [#387](https://github.com/vmware/go-vcloud-director/pull/387)
2+
* Added method `vdc.CreateRawVApp` [#387](https://github.com/vmware/go-vcloud-director/pull/387)
3+

.changes/v2.12.1/389-bug-fixes.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* org.GetCatalogByName and org.GetCatalogById could not retrieve shared catalogs from different Orgs
2+
[GH-389]
3+

.changes/v2.13.0/391-bug-fixes.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Fix handling of `staticcheck` in GitGub Actions [GH-391]
2+

.changes/v2.13.0/391-improvements.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Add `.changes` directory for changelog items [GH-391]
2+

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.13.0 (Unreleased)
2+
3+
Changes in progress for v2.13.0 are available at [.changes/v2.13.0](https://github.com/vmware/go-vcloud-director/tree/master/.changes/v2.13.0) until the release.
4+
15
## 2.12.1 (5 July, 2021)
26

37
BUGS FIXED:

govcd/api_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ func printVerbose(format string, args ...interface{}) {
102102
}
103103
}
104104

105+
//lint:ignore U1000 this function is used on request for debugging purposes
105106
func logVerbose(t *testing.T, format string, args ...interface{}) {
106107
if testVerbose {
107108
t.Logf(format, args...)

scripts/changelog-links.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# This script rewrites [GH-nnnn]-style references in the CHANGELOG.md file to
4+
# be Markdown links to the given github issues.
5+
#
6+
# This is run during releases so that the issue references in all of the
7+
# released items are presented as clickable links, but we can just use the
8+
# easy [GH-nnnn] shorthand for quickly adding items to the "Unrelease" section
9+
# while merging things between releases.
10+
11+
set -e
12+
13+
if [[ ! -f CHANGELOG.md ]]; then
14+
echo "ERROR: CHANGELOG.md not found in pwd."
15+
echo "Please run this from the root of the go-vcloud-director repository"
16+
exit 1
17+
fi
18+
19+
if [[ `uname` == "Darwin" ]]; then
20+
echo "Using BSD sed"
21+
SED="sed -i.bak -E -e"
22+
else
23+
echo "Using GNU sed"
24+
SED="sed -i.bak -r -e"
25+
fi
26+
27+
GOVCD_URL="https:\/\/github.com\/vmware\/go-vcloud-director\/pull"
28+
29+
$SED "s/GH-([0-9]+)/\[#\1\]\($GOVCD_URL\/\1\)/g" -e 's/\[\[#(.+)([0-9])\)]$/(\[#\1\2))/g' CHANGELOG.md
30+
if [ "$?" != "0" ] ; then exit 1 ; fi
31+
rm CHANGELOG.md.bak

scripts/make-changelog.sh

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
3+
# This script collects the single change files and generates CHANGELOG entries
4+
# for the whole release
5+
6+
# .changes is the directory where the change files are
7+
sources=.changes
8+
9+
if [ ! -d $sources ]
10+
then
11+
echo "Directory $sources not found"
12+
exit 1
13+
fi
14+
15+
# We must indicate a version on the command line
16+
version=$1
17+
18+
# If no version was provided, we use the current release version
19+
if [ -z "$version" ]
20+
then
21+
echo "No version was provided"
22+
exit 1
23+
fi
24+
25+
26+
# If the provided version does not exist, there is nothing to do
27+
if [ ! -d $sources/$version ]
28+
then
29+
echo "# Changes directory $sources/$version not found"
30+
exit 1
31+
fi
32+
33+
# The "sections" file contains the CHANGELOG headers
34+
if [ ! -f $sources/sections ]
35+
then
36+
echo "File $sources/sections not found"
37+
exit 1
38+
fi
39+
sections=$(cat $sources/sections)
40+
41+
cd $sources/$version
42+
43+
for section in $sections
44+
do
45+
# Check whether we have any file for this section
46+
num=$(ls | grep "\-${section}.md" | wc -l | tr -d ' \t')
47+
# if there are no files for this section, we skip
48+
if [ "$num" == "0" ]
49+
then
50+
continue
51+
fi
52+
53+
# Generate the header
54+
echo "## $(echo $section | tr 'a-z' 'A-Z' | tr '-' ' ')"
55+
56+
# Print the changes files, sorted by PR number
57+
for f in $(ls *${section}.md | sort -n)
58+
do
59+
cat $f
60+
done
61+
echo ""
62+
done
63+

scripts/staticcheck.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function exists_in_path {
2727

2828
function get_check_static {
2929
static_check=$(exists_in_path staticcheck)
30-
if [ -z "$staticcheck" -a -n "$TRAVIS" ]
30+
if [ -z "$staticcheck" -a -n "$GITHUB_ACTIONS" ]
3131
then
3232
# Variables found in staticcheck-config.sh
3333
# STATICCHECK_URL

0 commit comments

Comments
 (0)