-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for Tolerations on Build and BuildRun objects
Signed-off-by: Dylan Orzel <[email protected]>
- Loading branch information
Showing
12 changed files
with
335 additions
and
4 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
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,20 @@ | ||
--- | ||
apiVersion: shipwright.io/v1beta1 | ||
kind: Build | ||
metadata: | ||
name: buildah-tolerations-build | ||
spec: | ||
source: | ||
type: Git | ||
git: | ||
url: https://github.com/shipwright-io/sample-go | ||
contextDir: docker-build | ||
strategy: | ||
name: buildah-shipwright-managed-push | ||
kind: ClusterBuildStrategy | ||
output: | ||
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app | ||
tolerations: | ||
- key: "test-key" | ||
value: "test-value" | ||
operator: "Equal" |
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,8 @@ | ||
--- | ||
apiVersion: shipwright.io/v1beta1 | ||
kind: BuildRun | ||
metadata: | ||
name: buildah-tolerations-buildrun | ||
spec: | ||
build: | ||
name: buildah-tolerations-build |
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
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,17 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
kubeadmConfigPatches: | ||
- | | ||
kind: ClusterConfiguration | ||
metadata: | ||
name: config | ||
apiServer: | ||
extraArgs: | ||
enable-admission-plugins: PodSecurity | ||
nodes: | ||
- role: control-plane | ||
extraPortMappings: | ||
- containerPort: 32222 | ||
hostPort: 32222 | ||
- role: worker | ||
- role: worker |
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,51 @@ | ||
// Copyright The Shipwright Contributors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package utils | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
apply "k8s.io/client-go/applyconfigurations/core/v1" | ||
) | ||
|
||
// GetNodes returns all Nodes for the TestBuild object | ||
func (t *TestBuild) GetNodes() (*corev1.NodeList, error) { | ||
client := t.Clientset.CoreV1().Nodes() | ||
nodes, err := client.List(t.Context, metav1.ListOptions{}) | ||
return nodes, err | ||
} | ||
|
||
// AddNodeTaint sets a taint on the given Node name | ||
func (t *TestBuild) AddNodeTaint(name string, taint *corev1.Taint) error { | ||
client := t.Clientset.CoreV1().Nodes() | ||
taintApplyCfg := apply.Taint() | ||
taintApplyCfg.WithKey(taint.Key) | ||
taintApplyCfg.WithValue(taint.Value) | ||
taintApplyCfg.WithEffect(taint.Effect) | ||
nodeSpecApplyCfg := apply.NodeSpec() | ||
nodeSpecApplyCfg.WithTaints(taintApplyCfg) | ||
applyCfg := apply.Node(name) | ||
applyCfg.WithSpec(nodeSpecApplyCfg) | ||
_, err := client.Apply(t.Context, applyCfg, metav1.ApplyOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
// RemoveNodeTaints removes all taints on the given Node name | ||
func (t *TestBuild) RemoveNodeTaints(name string) error { | ||
client := t.Clientset.CoreV1().Nodes() | ||
applyCfg := apply.Node(name) | ||
taintApplyCfg := apply.Taint() | ||
nodeSpecApplyCfg := apply.NodeSpec() | ||
nodeSpecApplyCfg.WithTaints(taintApplyCfg) | ||
applyCfg.WithSpec(nodeSpecApplyCfg) | ||
_, err := client.Apply(t.Context, applyCfg, metav1.ApplyOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
Oops, something went wrong.