-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Validators and Transformers (#409)
- Loading branch information
Showing
19 changed files
with
459 additions
and
88 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,12 @@ | ||
package transformers | ||
|
||
func GetTransformer(variableKind string) func(string) (string, error) { | ||
switch variableKind { | ||
default: | ||
return DefaultTransformer | ||
} | ||
} | ||
|
||
func DefaultTransformer(inputVar string) (string, error) { | ||
return inputVar, nil | ||
} |
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 @@ | ||
package transformers | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetTransformer(t *testing.T) { | ||
assert.NotNil(t, GetTransformer("NonExistentKind")) | ||
} | ||
|
||
func TestDefaultTransformer(t *testing.T) { | ||
res, err := DefaultTransformer("test") | ||
assert.Nil(t, err) | ||
assert.Equal(t, "test", res) | ||
} |
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,12 @@ | ||
package validators | ||
|
||
func GetValidator(variableKind string) func(string) error { | ||
switch variableKind { | ||
default: | ||
return DefaultValidator | ||
} | ||
} | ||
|
||
func DefaultValidator(input string) error { | ||
return nil | ||
} |
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,15 @@ | ||
package validators | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetValidator(t *testing.T) { | ||
assert.NotNil(t, GetValidator("NonExistentKind")) | ||
} | ||
|
||
func TestDefaultValidator(t *testing.T) { | ||
assert.Nil(t, DefaultValidator("test")) | ||
} |
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,22 @@ | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: test-app | ||
labels: | ||
app.kubernetes.io/name: test-app | ||
app.kubernetes.io/part-of: test-app-project | ||
kubernetes.azure.com/generator: draft | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: test-app | ||
minReplicas: 2 | ||
maxReplicas: 5 | ||
metrics: | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
target: | ||
type: Utilization | ||
averageUtilization: 80 |
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,13 @@ | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: test-app | ||
labels: | ||
app.kubernetes.io/name: test-app | ||
app.kubernetes.io/part-of: test-app-project | ||
kubernetes.azure.com/generator: draft | ||
spec: | ||
maxUnavailable: 1 | ||
selector: | ||
matchLabels: | ||
app: test-app |
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,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: test-app | ||
labels: | ||
app.kubernetes.io/name: test-app | ||
app.kubernetes.io/part-of: test-app-project | ||
kubernetes.azure.com/generator: draft | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: test-app | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 80 |
Oops, something went wrong.