ignore .git dir when formatting
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>pull/7757/head
parent
e1bef5b6c2
commit
3c937d42dd
|
@ -33,7 +33,7 @@ if ! command -v goimports > /dev/null; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
files="$(find . -type f -name '*.go' -not -path './.go/*' -not -path './vendor/*' -not -path './site/*' -not -path '*/generated/*' -not -name 'zz_generated*' -not -path '*/mocks/*')"
|
files="$(find . -type f -name '*.go' -not -path './.go/*' -not -path './vendor/*' -not -path './site/*' -not -path './.git/*' -not -path '*/generated/*' -not -name 'zz_generated*' -not -path '*/mocks/*')"
|
||||||
echo "${ACTION} gofmt"
|
echo "${ACTION} gofmt"
|
||||||
output=$(gofmt "${MODE}" -s ${files})
|
output=$(gofmt "${MODE}" -s ${files})
|
||||||
if [[ -n "${output}" ]]; then
|
if [[ -n "${output}" ]]; then
|
||||||
|
|
|
@ -37,9 +37,9 @@ import (
|
||||||
"github.com/vmware-tanzu/velero/pkg/cmd"
|
"github.com/vmware-tanzu/velero/pkg/cmd"
|
||||||
"github.com/vmware-tanzu/velero/pkg/cmd/util/flag"
|
"github.com/vmware-tanzu/velero/pkg/cmd/util/flag"
|
||||||
"github.com/vmware-tanzu/velero/pkg/cmd/util/output"
|
"github.com/vmware-tanzu/velero/pkg/cmd/util/output"
|
||||||
"github.com/vmware-tanzu/velero/pkg/restore/util"
|
|
||||||
"github.com/vmware-tanzu/velero/pkg/util/boolptr"
|
"github.com/vmware-tanzu/velero/pkg/util/boolptr"
|
||||||
"github.com/vmware-tanzu/velero/pkg/util/kube"
|
"github.com/vmware-tanzu/velero/pkg/util/kube"
|
||||||
|
"github.com/vmware-tanzu/velero/pkg/util/velero/restore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
||||||
|
@ -200,7 +200,7 @@ func (o *CreateOptions) Validate(c *cobra.Command, args []string, f client.Facto
|
||||||
return errors.New("either a 'selector' or an 'or-selector' can be specified, but not both")
|
return errors.New("either a 'selector' or an 'or-selector' can be specified, but not both")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(o.ExistingResourcePolicy) > 0 && !util.IsResourcePolicyValid(o.ExistingResourcePolicy) {
|
if len(o.ExistingResourcePolicy) > 0 && !restore.IsResourcePolicyValid(o.ExistingResourcePolicy) {
|
||||||
return errors.New("existing-resource-policy has invalid value, it accepts only none, update as value")
|
return errors.New("existing-resource-policy has invalid value, it accepts only none, update as value")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,11 @@ import (
|
||||||
"github.com/vmware-tanzu/velero/pkg/plugin/clientmgmt"
|
"github.com/vmware-tanzu/velero/pkg/plugin/clientmgmt"
|
||||||
"github.com/vmware-tanzu/velero/pkg/plugin/framework"
|
"github.com/vmware-tanzu/velero/pkg/plugin/framework"
|
||||||
pkgrestore "github.com/vmware-tanzu/velero/pkg/restore"
|
pkgrestore "github.com/vmware-tanzu/velero/pkg/restore"
|
||||||
"github.com/vmware-tanzu/velero/pkg/restore/util"
|
|
||||||
"github.com/vmware-tanzu/velero/pkg/util/collections"
|
"github.com/vmware-tanzu/velero/pkg/util/collections"
|
||||||
kubeutil "github.com/vmware-tanzu/velero/pkg/util/kube"
|
kubeutil "github.com/vmware-tanzu/velero/pkg/util/kube"
|
||||||
"github.com/vmware-tanzu/velero/pkg/util/logging"
|
"github.com/vmware-tanzu/velero/pkg/util/logging"
|
||||||
"github.com/vmware-tanzu/velero/pkg/util/results"
|
"github.com/vmware-tanzu/velero/pkg/util/results"
|
||||||
|
pkgrestoreUtil "github.com/vmware-tanzu/velero/pkg/util/velero/restore"
|
||||||
)
|
)
|
||||||
|
|
||||||
// nonRestorableResources is an exclusion list for the restoration process. Any resources
|
// nonRestorableResources is an exclusion list for the restoration process. Any resources
|
||||||
|
@ -348,7 +348,7 @@ func (r *restoreReconciler) validateAndComplete(restore *api.Restore) (backupInf
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate ExistingResourcePolicy
|
// validate ExistingResourcePolicy
|
||||||
if restore.Spec.ExistingResourcePolicy != "" && !util.IsResourcePolicyValid(string(restore.Spec.ExistingResourcePolicy)) {
|
if restore.Spec.ExistingResourcePolicy != "" && !pkgrestoreUtil.IsResourcePolicyValid(string(restore.Spec.ExistingResourcePolicy)) {
|
||||||
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, fmt.Sprintf("Invalid ExistingResourcePolicy: %s", restore.Spec.ExistingResourcePolicy))
|
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, fmt.Sprintf("Invalid ExistingResourcePolicy: %s", restore.Spec.ExistingResourcePolicy))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,6 +312,39 @@ func TestRestoreReconcile(t *testing.T) {
|
||||||
expectedRestoreErrors: 1,
|
expectedRestoreErrors: 1,
|
||||||
expectedRestorerCall: NewRestore("foo", "bar", "backup-1", "ns-1", "", velerov1api.RestorePhaseInProgress).Result(),
|
expectedRestorerCall: NewRestore("foo", "bar", "backup-1", "ns-1", "", velerov1api.RestorePhaseInProgress).Result(),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "valid restore with none existingresourcepolicy gets executed",
|
||||||
|
location: defaultStorageLocation,
|
||||||
|
restore: NewRestore("foo", "bar", "backup-1", "ns-1", "", velerov1api.RestorePhaseNew).ExistingResourcePolicy("none").Result(),
|
||||||
|
backup: defaultBackup().StorageLocation("default").Result(),
|
||||||
|
expectedErr: false,
|
||||||
|
expectedPhase: string(velerov1api.RestorePhaseInProgress),
|
||||||
|
expectedStartTime: ×tamp,
|
||||||
|
expectedCompletedTime: ×tamp,
|
||||||
|
expectedRestorerCall: NewRestore("foo", "bar", "backup-1", "ns-1", "", velerov1api.RestorePhaseInProgress).ExistingResourcePolicy("none").Result(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "valid restore with update existingresourcepolicy gets executed",
|
||||||
|
location: defaultStorageLocation,
|
||||||
|
restore: NewRestore("foo", "bar", "backup-1", "ns-1", "", velerov1api.RestorePhaseNew).ExistingResourcePolicy("update").Result(),
|
||||||
|
backup: defaultBackup().StorageLocation("default").Result(),
|
||||||
|
expectedErr: false,
|
||||||
|
expectedPhase: string(velerov1api.RestorePhaseInProgress),
|
||||||
|
expectedStartTime: ×tamp,
|
||||||
|
expectedCompletedTime: ×tamp,
|
||||||
|
expectedRestorerCall: NewRestore("foo", "bar", "backup-1", "ns-1", "", velerov1api.RestorePhaseInProgress).ExistingResourcePolicy("update").Result(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "invalid restore with invalid existingresourcepolicy errors",
|
||||||
|
location: defaultStorageLocation,
|
||||||
|
restore: NewRestore("foo", "invalidexistingresourcepolicy", "backup-1", "ns-1", "", velerov1api.RestorePhaseNew).ExistingResourcePolicy("invalid").Result(),
|
||||||
|
backup: defaultBackup().StorageLocation("default").Result(),
|
||||||
|
expectedErr: false,
|
||||||
|
expectedPhase: string(velerov1api.RestorePhaseFailedValidation),
|
||||||
|
expectedStartTime: ×tamp,
|
||||||
|
expectedCompletedTime: ×tamp,
|
||||||
|
expectedRestorerCall: nil, // this restore should fail validation and not be passed to the restorer
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "valid restore gets executed",
|
name: "valid restore gets executed",
|
||||||
location: defaultStorageLocation,
|
location: defaultStorageLocation,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package util
|
package restore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
|
@ -1,4 +1,4 @@
|
||||||
package util
|
package restore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
Loading…
Reference in New Issue