forked from crossplane/oam-kubernetes-runtime
-
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.
Merge pull request crossplane#198 from ryanzhang-oss/add-workload-type
Add an optional workload type field in the component workload spec.
- Loading branch information
Showing
16 changed files
with
776 additions
and
11 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
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 @@ | ||
apiVersion: core.oam.dev/v1alpha2 | ||
kind: WorkloadDefinition | ||
metadata: | ||
name: web-service | ||
spec: | ||
definitionRef: | ||
name: containerizedworkloads.core.oam.dev | ||
childResourceKinds: | ||
- apiVersion: apps/v1 | ||
kind: Deployment | ||
- apiVersion: v1 | ||
kind: Service |
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,30 @@ | ||
apiVersion: core.oam.dev/v1alpha2 | ||
kind: HealthScope | ||
metadata: | ||
name: example-health-scope | ||
spec: | ||
workloadRefs: [] | ||
--- | ||
apiVersion: core.oam.dev/v1alpha2 | ||
kind: ApplicationConfiguration | ||
metadata: | ||
name: example-appconfig | ||
spec: | ||
components: | ||
- componentName: web-service-component | ||
parameterValues: | ||
- name: image | ||
value: wordpress:php7.2 | ||
traits: | ||
- trait: | ||
apiVersion: core.oam.dev/v1alpha2 | ||
kind: ManualScalerTrait | ||
metadata: | ||
name: example-appconfig-trait | ||
spec: | ||
replicaCount: 3 | ||
scopes: | ||
- scopeRef: | ||
apiVersion: core.oam.dev/v1alpha2 | ||
kind: HealthScope | ||
name: example-health-scope |
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,21 @@ | ||
apiVersion: core.oam.dev/v1alpha2 | ||
kind: Component | ||
metadata: | ||
name: web-service-component | ||
spec: | ||
workload: | ||
type: web-service | ||
spec: | ||
containers: | ||
- name: wordpress | ||
image: wordpress:4.6.1-apache | ||
ports: | ||
- containerPort: 80 | ||
name: wordpress | ||
env: | ||
- name: TEST_ENV | ||
value: test | ||
parameters: | ||
- name: image | ||
fieldPaths: | ||
- spec.containers[0].image |
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
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,86 @@ | ||
package component_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
clientgoscheme "k8s.io/client-go/kubernetes/scheme" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||
"sigs.k8s.io/controller-runtime/pkg/webhook/admission" | ||
|
||
"github.com/crossplane/oam-kubernetes-runtime/apis/core" | ||
) | ||
|
||
var scheme = runtime.NewScheme() | ||
var crd crdv1.CustomResourceDefinition | ||
var reqResource metav1.GroupVersionResource | ||
var decoder *admission.Decoder | ||
|
||
func TestComponentWebHandler(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Component Web handler") | ||
} | ||
|
||
var _ = BeforeSuite(func(done Done) { | ||
By("Bootstrapping test environment") | ||
ctrl.SetLogger(zap.New(func(o *zap.Options) { | ||
o.Development = true | ||
o.DestWritter = os.Stdout | ||
})) | ||
By("Setup scheme") | ||
err := core.AddToScheme(scheme) | ||
Expect(err).Should(BeNil()) | ||
err = clientgoscheme.AddToScheme(scheme) | ||
Expect(err).Should(BeNil()) | ||
// the crd we will refer to | ||
crd = crdv1.CustomResourceDefinition{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "foo.example.com", | ||
Labels: map[string]string{"crd": "dependency"}, | ||
}, | ||
Spec: crdv1.CustomResourceDefinitionSpec{ | ||
Group: "example.com", | ||
Names: crdv1.CustomResourceDefinitionNames{ | ||
Kind: "Foo", | ||
ListKind: "FooList", | ||
Plural: "foo", | ||
Singular: "foo", | ||
}, | ||
Versions: []crdv1.CustomResourceDefinitionVersion{ | ||
{ | ||
Name: "v1", | ||
Served: true, | ||
Storage: true, | ||
Schema: &crdv1.CustomResourceValidation{ | ||
OpenAPIV3Schema: &crdv1.JSONSchemaProps{ | ||
Type: "object", | ||
Properties: map[string]crdv1.JSONSchemaProps{ | ||
"status": { | ||
Type: "object", | ||
Properties: map[string]crdv1.JSONSchemaProps{ | ||
"key": {Type: "string"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Scope: crdv1.NamespaceScoped, | ||
}, | ||
} | ||
By("Prepare for the admission resource") | ||
reqResource = metav1.GroupVersionResource{Group: "core.oam.dev", Version: "v1alpha2", Resource: "components"} | ||
By("Prepare for the admission decoder") | ||
decoder, err = admission.NewDecoder(scheme) | ||
Expect(err).Should(BeNil()) | ||
By("Finished test bootstrap") | ||
close(done) | ||
}) |
Oops, something went wrong.