本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api.ResourceName函数的典型用法代码示例。如果您正苦于以下问题:Golang ResourceName函数的具体用法?Golang ResourceName怎么用?Golang ResourceName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ResourceName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: OkStrategy
func OkStrategy() deployapi.DeploymentStrategy {
return deployapi.DeploymentStrategy{
Type: deployapi.DeploymentStrategyTypeRecreate,
Resources: kapi.ResourceRequirements{
Limits: kapi.ResourceList{
kapi.ResourceName(kapi.ResourceCPU): resource.MustParse("10"),
kapi.ResourceName(kapi.ResourceMemory): resource.MustParse("10G"),
},
},
}
}
示例2: mockSTIBuild
func mockSTIBuild() *buildapi.Build {
return &buildapi.Build{
ObjectMeta: kapi.ObjectMeta{
Name: "stiBuild",
Labels: map[string]string{
"name": "stiBuild",
},
},
Spec: buildapi.BuildSpec{
Revision: &buildapi.SourceRevision{
Git: &buildapi.GitSourceRevision{},
},
Source: buildapi.BuildSource{
Git: &buildapi.GitBuildSource{
URI: "http://my.build.com/the/stibuild/Dockerfile",
},
SourceSecret: &kapi.LocalObjectReference{Name: "fooSecret"},
},
Strategy: buildapi.BuildStrategy{
Type: buildapi.SourceBuildStrategyType,
SourceStrategy: &buildapi.SourceBuildStrategy{
From: kapi.ObjectReference{
Kind: "DockerImage",
Name: "repository/sti-builder",
},
PullSecret: &kapi.LocalObjectReference{Name: "bar"},
Scripts: "http://my.build.com/the/sti/scripts",
Env: []kapi.EnvVar{
{Name: "BUILD_LOGLEVEL", Value: "bar"},
{Name: "ILLEGAL", Value: "foo"},
},
},
},
Output: buildapi.BuildOutput{
To: &kapi.ObjectReference{
Kind: "DockerImage",
Name: "docker-registry/repository/stiBuild",
},
PushSecret: &kapi.LocalObjectReference{Name: "foo"},
},
Resources: kapi.ResourceRequirements{
Limits: kapi.ResourceList{
kapi.ResourceName(kapi.ResourceCPU): resource.MustParse("10"),
kapi.ResourceName(kapi.ResourceMemory): resource.MustParse("10G"),
},
},
},
Status: buildapi.BuildStatus{
Phase: buildapi.BuildPhaseNew,
},
}
}
示例3: mockCustomBuild
func mockCustomBuild() *buildapi.Build {
return &buildapi.Build{
ObjectMeta: kapi.ObjectMeta{
Name: "customBuild",
Labels: map[string]string{
"name": "customBuild",
},
},
Spec: buildapi.BuildSpec{
Revision: &buildapi.SourceRevision{
Git: &buildapi.GitSourceRevision{},
},
Source: buildapi.BuildSource{
Type: buildapi.BuildSourceGit,
Git: &buildapi.GitBuildSource{
URI: "http://my.build.com/the/dockerbuild/Dockerfile",
Ref: "master",
},
SourceSecret: &kapi.LocalObjectReference{Name: "secretFoo"},
},
Strategy: buildapi.BuildStrategy{
Type: buildapi.CustomBuildStrategyType,
CustomStrategy: &buildapi.CustomBuildStrategy{
From: kapi.ObjectReference{
Kind: "DockerImage",
Name: "builder-image",
},
Env: []kapi.EnvVar{
{Name: "FOO", Value: "BAR"},
},
ExposeDockerSocket: true,
},
},
Output: buildapi.BuildOutput{
To: &kapi.ObjectReference{
Kind: "DockerImage",
Name: "docker-registry/repository/customBuild",
},
PushSecret: &kapi.LocalObjectReference{Name: "foo"},
},
Resources: kapi.ResourceRequirements{
Limits: kapi.ResourceList{
kapi.ResourceName(kapi.ResourceCPU): resource.MustParse("10"),
kapi.ResourceName(kapi.ResourceMemory): resource.MustParse("10G"),
},
},
},
Status: buildapi.BuildStatus{
Phase: buildapi.BuildPhaseNew,
},
}
}
示例4: newNode
func newNode(name string) *api.Node {
return &api.Node{
ObjectMeta: api.ObjectMeta{Name: name},
Spec: api.NodeSpec{
ExternalID: name,
},
Status: api.NodeStatus{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceCPU): resource.MustParse("10"),
api.ResourceName(api.ResourceMemory): resource.MustParse("10G"),
},
},
}
}
示例5: TestPersistentVolumeClaimStatusUpdate
func TestPersistentVolumeClaimStatusUpdate(t *testing.T) {
ns := api.NamespaceDefault
persistentVolumeClaim := &api.PersistentVolumeClaim{
ObjectMeta: api.ObjectMeta{
Name: "abc",
ResourceVersion: "1",
},
Spec: api.PersistentVolumeClaimSpec{
AccessModes: []api.PersistentVolumeAccessMode{
api.ReadWriteOnce,
api.ReadOnlyMany,
},
Resources: api.ResourceRequirements{
Requests: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
},
},
Status: api.PersistentVolumeClaimStatus{
Phase: api.ClaimBound,
},
}
c := &testClient{
Request: testRequest{
Method: "PUT",
Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "abc") + "/status",
Query: buildQueryValues(ns, nil)},
Response: Response{StatusCode: 200, Body: persistentVolumeClaim},
}
response, err := c.Setup().PersistentVolumeClaims(ns).UpdateStatus(persistentVolumeClaim)
c.Validate(t, response, err)
}
示例6: TestPersistentVolumeClaimGet
func TestPersistentVolumeClaimGet(t *testing.T) {
ns := api.NamespaceDefault
persistentVolumeClaim := &api.PersistentVolumeClaim{
ObjectMeta: api.ObjectMeta{
Name: "abc",
Namespace: "foo",
},
Spec: api.PersistentVolumeClaimSpec{
AccessModes: []api.AccessModeType{
api.ReadWriteOnce,
api.ReadOnlyMany,
},
Resources: api.ResourceRequirements{
Requests: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
},
},
}
c := &testClient{
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "abc"),
Query: buildQueryValues(ns, nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: persistentVolumeClaim},
}
response, err := c.Setup().PersistentVolumeClaims(ns).Get("abc")
c.Validate(t, response, err)
}
示例7: makePersistentVolume
func makePersistentVolume(serverIP string) *api.PersistentVolume {
return &api.PersistentVolume{
ObjectMeta: api.ObjectMeta{
GenerateName: "nfs-",
},
Spec: api.PersistentVolumeSpec{
PersistentVolumeReclaimPolicy: api.PersistentVolumeReclaimRecycle,
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("2Gi"),
},
PersistentVolumeSource: api.PersistentVolumeSource{
NFS: &api.NFSVolumeSource{
Server: serverIP,
Path: "/",
ReadOnly: false,
},
},
AccessModes: []api.PersistentVolumeAccessMode{
api.ReadWriteOnce,
api.ReadOnlyMany,
api.ReadWriteMany,
},
},
}
}
示例8: TestPersistentVolumeStatusUpdate
func TestPersistentVolumeStatusUpdate(t *testing.T) {
persistentVolume := &api.PersistentVolume{
ObjectMeta: api.ObjectMeta{
Name: "abc",
ResourceVersion: "1",
},
Spec: api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/foo"},
},
},
Status: api.PersistentVolumeStatus{
Phase: api.VolumeBound,
},
}
c := &testClient{
Request: testRequest{
Method: "PUT",
Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", "abc") + "/status",
Query: buildQueryValues("", nil)},
Response: Response{StatusCode: 200, Body: persistentVolume},
}
response, err := c.Setup().PersistentVolumes().UpdateStatus(persistentVolume)
c.Validate(t, response, err)
}
示例9: TestPersistentVolumeGet
func TestPersistentVolumeGet(t *testing.T) {
persistentVolume := &api.PersistentVolume{
ObjectMeta: api.ObjectMeta{
Name: "abc",
Namespace: "foo",
},
Spec: api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/foo"},
},
},
}
c := &testClient{
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", "abc"),
Query: buildQueryValues("", nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: persistentVolume},
}
response, err := c.Setup().PersistentVolumes().Get("abc")
c.Validate(t, response, err)
}
示例10: createTestVolumes
func createTestVolumes() []*api.PersistentVolume {
return []*api.PersistentVolume{
{
ObjectMeta: api.ObjectMeta{
UID: "gce-pd-10",
Name: "gce003",
},
Spec: api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
PersistentVolumeSource: api.PersistentVolumeSource{
GCEPersistentDisk: &api.GCEPersistentDiskVolumeSource{
PDName: "gce123123123",
FSType: "foo",
},
},
AccessModes: []api.PersistentVolumeAccessMode{
api.ReadWriteOnce,
api.ReadOnlyMany,
},
},
},
{
ObjectMeta: api.ObjectMeta{
UID: "nfs-5",
Name: "nfs002",
},
Spec: api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("5G"),
},
PersistentVolumeSource: api.PersistentVolumeSource{
Glusterfs: &api.GlusterfsVolumeSource{
EndpointsName: "andintheend",
Path: "theloveyoutakeisequaltotheloveyoumake",
},
},
AccessModes: []api.PersistentVolumeAccessMode{
api.ReadWriteOnce,
api.ReadOnlyMany,
api.ReadWriteMany,
},
},
},
}
}
示例11: createTestClaims
func createTestClaims() []*api.PersistentVolumeClaim {
return []*api.PersistentVolumeClaim{
{
ObjectMeta: api.ObjectMeta{
Name: "claim03",
Namespace: api.NamespaceDefault,
},
Spec: api.PersistentVolumeClaimSpec{
AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce},
Resources: api.ResourceRequirements{
Requests: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("500G"),
},
},
},
},
{
ObjectMeta: api.ObjectMeta{
Name: "claim01",
Namespace: api.NamespaceDefault,
},
Spec: api.PersistentVolumeClaimSpec{
AccessModes: []api.PersistentVolumeAccessMode{api.ReadOnlyMany, api.ReadWriteOnce},
Resources: api.ResourceRequirements{
Requests: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("8G"),
},
},
},
},
{
ObjectMeta: api.ObjectMeta{
Name: "claim02",
Namespace: api.NamespaceDefault,
},
Spec: api.PersistentVolumeClaimSpec{
AccessModes: []api.PersistentVolumeAccessMode{api.ReadOnlyMany, api.ReadWriteOnce, api.ReadWriteMany},
Resources: api.ResourceRequirements{
Requests: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("5G"),
},
},
},
},
}
}
示例12: okContainer
func okContainer() *kapi.Container {
return &kapi.Container{
Image: "test/image",
Command: []string{"command"},
Env: []kapi.EnvVar{
{
Name: "env1",
Value: "val1",
},
},
Resources: kapi.ResourceRequirements{
Limits: kapi.ResourceList{
kapi.ResourceName(kapi.ResourceCPU): resource.MustParse("10"),
kapi.ResourceName(kapi.ResourceMemory): resource.MustParse("10G"),
},
},
}
}
示例13: validNewNode
func validNewNode() *api.Node {
return &api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"name": "foo",
},
},
Spec: api.NodeSpec{
ExternalID: "external",
},
Status: api.NodeStatus{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceCPU): resource.MustParse("10"),
api.ResourceName(api.ResourceMemory): resource.MustParse("0"),
},
},
}
}
示例14: mockDockerBuild
func mockDockerBuild() *buildapi.Build {
return &buildapi.Build{
ObjectMeta: kapi.ObjectMeta{
Name: "dockerBuild",
Labels: map[string]string{
"name": "dockerBuild",
},
},
Parameters: buildapi.BuildParameters{
Revision: &buildapi.SourceRevision{
Git: &buildapi.GitSourceRevision{},
},
Source: buildapi.BuildSource{
Git: &buildapi.GitBuildSource{
URI: "http://my.build.com/the/dockerbuild/Dockerfile",
},
ContextDir: "my/test/dir",
SourceSecret: &kapi.LocalObjectReference{Name: "secretFoo"},
},
Strategy: buildapi.BuildStrategy{
Type: buildapi.DockerBuildStrategyType,
DockerStrategy: &buildapi.DockerBuildStrategy{
PullSecret: &kapi.LocalObjectReference{Name: "bar"},
Env: []kapi.EnvVar{
{Name: "ILLEGAL", Value: "foo"},
{Name: "BUILD_LOGLEVEL", Value: "bar"},
},
},
},
Output: buildapi.BuildOutput{
DockerImageReference: "docker-registry/repository/dockerBuild",
PushSecret: &kapi.LocalObjectReference{Name: "foo"},
},
Resources: kapi.ResourceRequirements{
Limits: kapi.ResourceList{
kapi.ResourceName(kapi.ResourceCPU): resource.MustParse("10"),
kapi.ResourceName(kapi.ResourceMemory): resource.MustParse("10G"),
},
},
},
Status: buildapi.BuildStatusNew,
}
}
示例15: OkRollingStrategy
func OkRollingStrategy() deployapi.DeploymentStrategy {
mkintp := func(i int) *int64 {
v := int64(i)
return &v
}
return deployapi.DeploymentStrategy{
Type: deployapi.DeploymentStrategyTypeRolling,
RollingParams: &deployapi.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: mkintp(1),
IntervalSeconds: mkintp(1),
TimeoutSeconds: mkintp(20),
},
Resources: kapi.ResourceRequirements{
Limits: kapi.ResourceList{
kapi.ResourceName(kapi.ResourceCPU): resource.MustParse("10"),
kapi.ResourceName(kapi.ResourceMemory): resource.MustParse("10G"),
},
},
}
}