forked from kubev2v/forklift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure namespace when validating VDDK
In order to validate the VDDK init image, we create a job on the destination provider. However, that would fail when the target namespace doesn't exist - it would be created only when the plan is triggered. So now we ensure the target namespace exists also during the validation of the VDDK init image. Signed-off-by: Arik Hadas <[email protected]>
- Loading branch information
Showing
4 changed files
with
57 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package plan | ||
|
||
import ( | ||
"context" | ||
|
||
api "github.com/konveyor/forklift-controller/pkg/apis/forklift/v1beta1" | ||
core "k8s.io/api/core/v1" | ||
k8serr "k8s.io/apimachinery/pkg/api/errors" | ||
meta "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
// Ensure the namespace exists on the destination. | ||
func ensureNamespace(plan *api.Plan, client client.Client) error { | ||
ns := &core.Namespace{ | ||
ObjectMeta: meta.ObjectMeta{ | ||
Name: plan.Spec.TargetNamespace, | ||
}, | ||
} | ||
err := client.Create(context.TODO(), ns) | ||
if err != nil && k8serr.IsAlreadyExists(err) { | ||
err = nil | ||
} | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters