Add verify codegen and manifests

Signed-off-by: Howard Lau <howardlau1999@hotmail.com>
This commit is contained in:
Howard Lau 2020-10-30 05:15:18 +00:00
parent 7f453bdf05
commit 0bcbcd1d0b
No known key found for this signature in database
GPG Key ID: 5CCC55849E3CF8E2
7 changed files with 124 additions and 7 deletions

35
.github/workflows/verify.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Verify
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Verify Codegen
run: hack/verify-codegen.sh
- name: Verify Manifests
run: hack/verify-manifests.sh

View File

@ -122,11 +122,11 @@ type MasterSpec struct {
// Config in raw toml string
Config *string `json:"config,omitempty"`
VolumePreallocate *bool `json:"volumePreallocate,omitempty"`
VolumeSizeLimitMB *int32 `json:"volumeSizeLimitMB,omitempty"`
GarbageThreshold *float64 `json:"garbageThreshold,omitempty"`
PulseSeconds *int32 `json:"pulseSeconds,omitempty"`
DefaultReplication *string `json:"defaultReplication,omitempty"`
VolumePreallocate *bool `json:"volumePreallocate,omitempty"`
VolumeSizeLimitMB *int32 `json:"volumeSizeLimitMB,omitempty"`
GarbageThreshold *string `json:"garbageThreshold,omitempty"`
PulseSeconds *int32 `json:"pulseSeconds,omitempty"`
DefaultReplication *string `json:"defaultReplication,omitempty"`
}
// VolumeSpec is the spec for volume servers

View File

@ -176,7 +176,7 @@ func (in *MasterSpec) DeepCopyInto(out *MasterSpec) {
}
if in.GarbageThreshold != nil {
in, out := &in.GarbageThreshold, &out.GarbageThreshold
*out = new(float64)
*out = new(string)
**out = **in
}
if in.PulseSeconds != nil {

View File

@ -3525,6 +3525,9 @@ spec:
description: Annotations of the component. Merged into the cluster-level
annotations if non-empty
type: object
config:
description: Config in raw toml string
type: string
env:
description: List of environment variables to set in the container,
like v1.Container.Env. Note that following env names cannot be
@ -6715,6 +6718,11 @@ spec:
description: Annotations of the component. Merged into the cluster-level
annotations if non-empty
type: object
config:
description: Config in raw toml string
type: string
defaultReplication:
type: string
env:
description: List of environment variables to set in the container,
like v1.Container.Env. Note that following env names cannot be
@ -6824,6 +6832,8 @@ spec:
- name
type: object
type: array
garbageThreshold:
type: string
hostNetwork:
description: Whether Hostnetwork of the component is enabled. Override
the cluster-level setting if present
@ -6866,6 +6876,9 @@ spec:
description: PriorityClassName of the component. Override the cluster-level
one if present
type: string
pulseSeconds:
format: int32
type: integer
replicas:
description: The desired ready replicas
format: int32
@ -6968,6 +6981,11 @@ spec:
description: Version of the component. Override the cluster-level
version if non-empty
type: string
volumePreallocate:
type: boolean
volumeSizeLimitMB:
format: int32
type: integer
required:
- replicas
type: object

View File

@ -24,7 +24,7 @@ func buildMasterStartupScript(m *seaweedv1.Seaweed) string {
}
if spec.GarbageThreshold != nil {
command = append(command, fmt.Sprintf("-garbageThreshold=%f", *spec.GarbageThreshold))
command = append(command, fmt.Sprintf("-garbageThreshold=%s", *spec.GarbageThreshold))
}
if spec.PulseSeconds != nil {

32
hack/verify-codegen.sh Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
DIFFROOT="${ROOT}/api"
TMP_DIFFROOT="${ROOT}/_tmp/api"
_tmp="${ROOT}/_tmp"
cleanup() {
rm -rf "${_tmp}"
}
trap "cleanup" EXIT SIGINT
cleanup
mkdir -p "${TMP_DIFFROOT}"
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
make generate
echo "diffing ${DIFFROOT} against freshly generated codegen"
ret=0
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
if [[ $ret -eq 0 ]]; then
echo "${DIFFROOT} up to date."
else
echo "${DIFFROOT} is out of date. Please run make generate"
exit 1
fi

32
hack/verify-manifests.sh Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
DIFFROOT="${ROOT}/config"
TMP_DIFFROOT="${ROOT}/_tmp/config"
_tmp="${ROOT}/_tmp"
cleanup() {
rm -rf "${_tmp}"
}
trap "cleanup" EXIT SIGINT
cleanup
mkdir -p "${TMP_DIFFROOT}"
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
make manifests
echo "diffing ${DIFFROOT} against freshly generated manifests"
ret=0
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
if [[ $ret -eq 0 ]]; then
echo "${DIFFROOT} up to date."
else
echo "${DIFFROOT} is out of date. Please run make manifests"
exit 1
fi