Skip to content

Commit

Permalink
Merge b359f49 into 6b51f29
Browse files Browse the repository at this point in the history
  • Loading branch information
tnqn committed Oct 18, 2022
2 parents 6b51f29 + b359f49 commit 311478b
Show file tree
Hide file tree
Showing 12 changed files with 2,385 additions and 108 deletions.
39 changes: 25 additions & 14 deletions hack/update-codegen-dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function generate_mocks {
"pkg/agent/ipassigner IPAssigner testing"
"pkg/agent/secondarynetwork/podwatch InterfaceConfigurator testing"
"pkg/agent/secondarynetwork/ipam IPAMDelegator testing"
"pkg/agent/util/ipset Interface testing"
"pkg/agent/util/iptables Interface testing mock_iptables_linux.go"
"pkg/agent/util/netlink Interface testing mock_netlink_linux.go"
"pkg/antctl AntctlClient ."
"pkg/controller/networkpolicy EndpointQuerier testing"
"pkg/controller/querier ControllerQuerier testing"
Expand All @@ -71,21 +74,29 @@ function generate_mocks {
current_year=$(date +"%Y")
sed -i "s/YEAR/${current_year}/g" hack/boilerplate/license_header.raw.txt
for target in "${MOCKGEN_TARGETS[@]}"; do
read -r package interfaces mock_package <<<"${target}"
package_name=$(basename "${package}")
if [[ "${mock_package}" == "." ]]; then # generate mocks in same package as src
$GOPATH/bin/mockgen \
-copyright_file hack/boilerplate/license_header.raw.txt \
-destination "${package}/mock_${package_name}_test.go" \
-package="${package_name}" \
"${ANTREA_PKG}/${package}" "${interfaces}"
else # generate mocks in subpackage
$GOPATH/bin/mockgen \
-copyright_file hack/boilerplate/license_header.raw.txt \
-destination "${package}/${mock_package}/mock_${package_name}.go" \
-package="${mock_package}" \
"${ANTREA_PKG}/${package}" "${interfaces}"
read -r src_package interfaces dst_package_name dst_file_name <<<"${target}"
src_package_name=$(basename "${src_package}")
# Generate mocks in the same package as src if dst_file_name is ".", otherwise create a sub package.
if [[ "${dst_package_name}" == "." ]]; then
package="${src_package_name}"
if [ -n "${dst_file_name}" ]; then
destination="${src_package}/${dst_file_name}"
else
destination="${src_package}/mock_${src_package_name}_test.go"
fi
else
package="${dst_package_name}"
if [ -n "${dst_file_name}" ]; then
destination="${src_package}/${dst_package_name}/${dst_file_name}"
else
destination="${src_package}/${dst_package_name}/mock_${src_package_name}.go"
fi
fi
$GOPATH/bin/mockgen \
-copyright_file hack/boilerplate/license_header.raw.txt \
-destination "${destination}" \
-package "${package}" \
"${ANTREA_PKG}/${src_package}" "${interfaces}"
done
git checkout HEAD -- hack/boilerplate/license_header.raw.txt
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/nodeportlocal/rules/iptable_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (ipt *iptablesRules) AddAllRules(nplList []PodNodePort) error {
}
}
writeLine(iptablesData, "COMMIT")
if err := ipt.table.Restore(iptablesData.Bytes(), false, false); err != nil {
if err := ipt.table.Restore(iptablesData.String(), false, false); err != nil {
return err
}
return nil
Expand Down
Loading

0 comments on commit 311478b

Please sign in to comment.