Skip to content

Commit 712c545

Browse files
committed
Add test for memcached-api-server project
1 parent 4507935 commit 712c545

18 files changed

+455
-0
lines changed

samples/memcached-api-server/test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"runtime"
6+
"os"
7+
"os/exec"
8+
"path/filepath"
9+
"strings"
10+
)
11+
12+
func main() {
13+
_, filename, _, _ := runtime.Caller(0)
14+
projectDir := filepath.Dir(filename)
15+
runProjectTest(projectDir)
16+
}
17+
18+
func runProjectTest(dir string) {
19+
os.Setenv("TEST_ASSET_KUBECTL", "/tmp/kubebuilder/bin/kubectl")
20+
os.Setenv("TEST_ASSET_KUBE_APISERVER", "/tmp/kubebuilder/bin/kube-apiserver")
21+
os.Setenv("TEST_ASSET_ETCD", "/tmp/kubebuilder/bin/etcd")
22+
23+
log.Printf("Testing the project %s", dir)
24+
cmds := []*exec.Cmd{
25+
exec.Command("dep", "ensure"),
26+
exec.Command("kubebuilder", "generate"),
27+
exec.Command("kubebuilder", "docs", "--docs-copyright", "Hello", "--title", "World", "--cleanup=false", "--brodocs=false"),
28+
exec.Command("diff", "test/docs/reference/includes", "docs/reference/includes"),
29+
exec.Command("diff", "test/docs/reference/config.yaml", "docs/reference/config.yaml"),
30+
exec.Command("diff", "test/docs/reference/manifest.json", "docs/reference/manifest.json"),
31+
exec.Command("go", "build", "./pkg/..."),
32+
exec.Command("go", "build", "./cmd/..."),
33+
exec.Command("go", "test", "./pkg/..."),
34+
exec.Command("go", "test", "./cmd/..."),
35+
exec.Command("kubebuilder", "create", "config", "--crds"),
36+
exec.Command("diff", "test/hack/install.yaml", "hack/install.yaml"),
37+
}
38+
39+
for _, c := range cmds {
40+
c.Dir = dir
41+
c.Env = os.Environ()
42+
command := strings.Join(c.Args, " ")
43+
log.Printf("Running the command %s", command)
44+
output, err := c.Output()
45+
if err != nil {
46+
log.Fatalf("%s finished with error: %s", command, string(output))
47+
}
48+
log.Printf("%s finished successfully", command)
49+
}
50+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
example_location: "examples"
2+
api_groups:
3+
- "Myapps"
4+
resource_categories:
5+
- name: "Myapps"
6+
include: "myapps"
7+
resources:
8+
- name: "Memcached"
9+
version: "v1alpha1"
10+
group: "myapps"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
# <strong>Field Definitions</strong>
3+
4+
------------
5+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Initializer v1
2+
3+
Group | Version | Kind
4+
------------ | ---------- | -----------
5+
`meta` | `v1` | `Initializer`
6+
7+
8+
9+
Initializer is information about an initializer that has not yet completed.
10+
11+
<aside class="notice">
12+
Appears In:
13+
14+
<ul>
15+
<li><a href="#initializers-v1">Initializers v1</a></li>
16+
</ul></aside>
17+
18+
Field | Description
19+
------------ | -----------
20+
`name`<br /> *string* | name of the process that is responsible for initializing this object.
21+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Initializers v1
2+
3+
Group | Version | Kind
4+
------------ | ---------- | -----------
5+
`meta` | `v1` | `Initializers`
6+
7+
8+
9+
Initializers tracks the progress of initialization.
10+
11+
<aside class="notice">
12+
Appears In:
13+
14+
<ul>
15+
<li><a href="#objectmeta-v1">ObjectMeta v1</a></li>
16+
</ul></aside>
17+
18+
Field | Description
19+
------------ | -----------
20+
`pending`<br /> *[Initializer](#initializer-v1) array* <br /> **patch type**: *merge* <br /> **patch merge key**: *name* | Pending is a list of initializers that must execute in order before this object is visible. When the last pending initializer is removed, and no failing result is set, the initializers struct will be set to nil and the object is considered as initialized and visible to all clients.
21+
`result`<br /> *[Status](#status-v1)* | If result is set with the Failure field, the object will be persisted to storage and then deleted, ensuring that other clients can observe the deletion.
22+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## ListMeta v1
2+
3+
Group | Version | Kind
4+
------------ | ---------- | -----------
5+
`meta` | `v1` | `ListMeta`
6+
7+
8+
9+
ListMeta describes metadata that synthetic resources must have, including lists and various status objects. A resource may have only one of {ObjectMeta, ListMeta}.
10+
11+
<aside class="notice">
12+
Appears In:
13+
14+
<ul>
15+
<li><a href="#status-v1">Status v1</a></li>
16+
</ul></aside>
17+
18+
Field | Description
19+
------------ | -----------
20+
`continue`<br /> *string* | continue may be set if the user set a limit on the number of items returned, and indicates that the server has more data available. The value is opaque and may be used to issue another request to the endpoint that served this list to retrieve the next set of available objects. Continuing a list may not be possible if the server configuration has changed or more than a few minutes have passed. The resourceVersion field returned when using this continue value will be identical to the value in the first response.
21+
`resourceVersion`<br /> *string* | String that identifies the server&#39;s internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency
22+
`selfLink`<br /> *string* | selfLink is a URL representing this object. Populated by the system. Read-only.
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
3+
-----------
4+
# Memcached v1alpha1
5+
6+
7+
8+
Group | Version | Kind
9+
------------ | ---------- | -----------
10+
`myapps` | `v1alpha1` | `Memcached`
11+
12+
13+
14+
15+
16+
17+
18+
Memcached
19+
20+
21+
22+
Field | Description
23+
------------ | -----------
24+
`apiVersion`<br /> *string* | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
25+
`kind`<br /> *string* | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
26+
`metadata`<br /> *[ObjectMeta](#objectmeta-v1)* |
27+
`spec`<br /> *[MemcachedSpec](#memcachedspec-v1alpha1)* |
28+
`status`<br /> *[MemcachedStatus](#memcachedstatus-v1alpha1)* |
29+
30+
31+
### MemcachedSpec v1alpha1
32+
33+
<aside class="notice">
34+
Appears In:
35+
36+
<ul>
37+
<li><a href="#memcached-v1alpha1">Memcached v1alpha1</a></li>
38+
</ul></aside>
39+
40+
Field | Description
41+
------------ | -----------
42+
`size`<br /> *integer* | INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
43+
44+
### MemcachedStatus v1alpha1
45+
46+
<aside class="notice">
47+
Appears In:
48+
49+
<ul>
50+
<li><a href="#memcached-v1alpha1">Memcached v1alpha1</a></li>
51+
</ul></aside>
52+
53+
Field | Description
54+
------------ | -----------
55+
`nodes`<br /> *string array* | INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
56+
57+
58+
59+
60+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## ObjectMeta v1
2+
3+
Group | Version | Kind
4+
------------ | ---------- | -----------
5+
`meta` | `v1` | `ObjectMeta`
6+
7+
8+
9+
ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.
10+
11+
<aside class="notice">
12+
Appears In:
13+
14+
<ul>
15+
<li><a href="#memcached-v1alpha1">Memcached v1alpha1</a></li>
16+
</ul></aside>
17+
18+
Field | Description
19+
------------ | -----------
20+
`annotations`<br /> *object* | Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations
21+
`clusterName`<br /> *string* | The name of the cluster which the object belongs to. This is used to distinguish resources with same name and namespace in different clusters. This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request.
22+
`creationTimestamp`<br /> *[Time](#time-v1)* | CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
23+
`deletionGracePeriodSeconds`<br /> *integer* | Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.
24+
`deletionTimestamp`<br /> *[Time](#time-v1)* | DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested. Populated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
25+
`finalizers`<br /> *string array* <br /> **patch type**: *merge* | Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed.
26+
`generateName`<br /> *string* | GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server. If this field is specified and the generated name exists, the server will NOT return a 409 - instead, it will either return 201 Created or 500 with Reason ServerTimeout indicating a unique name could not be found in the time allotted, and the client should retry (optionally after the time indicated in the Retry-After header). Applied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#idempotency
27+
`generation`<br /> *integer* | A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.
28+
`initializers`<br /> *[Initializers](#initializers-v1)* | An initializer is a controller which enforces some system invariant at object creation time. This field is a list of initializers that have not yet acted on this object. If nil or empty, this object has been completely initialized. Otherwise, the object is considered uninitialized and is hidden (in list/watch and get calls) from clients that haven&#39;t explicitly asked to observe uninitialized objects. When an object is created, the system will populate this list with the current set of initializers. Only privileged users may set or modify this list. Once it is empty, it may not be modified further by any user.
29+
`labels`<br /> *object* | Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels
30+
`name`<br /> *string* | Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names
31+
`namespace`<br /> *string* | Namespace defines the space within each name must be unique. An empty namespace is equivalent to the &#34;default&#34; namespace, but &#34;default&#34; is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces
32+
`ownerReferences`<br /> *[OwnerReference](#ownerreference-v1) array* <br /> **patch type**: *merge* <br /> **patch merge key**: *uid* | List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.
33+
`resourceVersion`<br /> *string* | An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources. Populated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency
34+
`selfLink`<br /> *string* | SelfLink is a URL representing this object. Populated by the system. Read-only.
35+
`uid`<br /> *string* | UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations. Populated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids
36+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## OwnerReference v1
2+
3+
Group | Version | Kind
4+
------------ | ---------- | -----------
5+
`meta` | `v1` | `OwnerReference`
6+
7+
8+
9+
OwnerReference contains enough information to let you identify an owning object. Currently, an owning object must be in the same namespace, so there is no namespace field.
10+
11+
<aside class="notice">
12+
Appears In:
13+
14+
<ul>
15+
<li><a href="#objectmeta-v1">ObjectMeta v1</a></li>
16+
</ul></aside>
17+
18+
Field | Description
19+
------------ | -----------
20+
`apiVersion`<br /> *string* | API version of the referent.
21+
`blockOwnerDeletion`<br /> *boolean* | If true, AND if the owner has the &#34;foregroundDeletion&#34; finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs &#34;delete&#34; permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.
22+
`controller`<br /> *boolean* | If true, this reference points to the managing controller.
23+
`kind`<br /> *string* | Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
24+
`name`<br /> *string* | Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names
25+
`uid`<br /> *string* | UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids
26+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Status v1
2+
3+
Group | Version | Kind
4+
------------ | ---------- | -----------
5+
`meta` | `v1` | `Status`
6+
7+
8+
9+
Status is a return value for calls that don&#39;t return other objects.
10+
11+
<aside class="notice">
12+
Appears In:
13+
14+
<ul>
15+
<li><a href="#initializers-v1">Initializers v1</a></li>
16+
</ul></aside>
17+
18+
Field | Description
19+
------------ | -----------
20+
`apiVersion`<br /> *string* | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
21+
`code`<br /> *integer* | Suggested HTTP return code for this status, 0 if not set.
22+
`details`<br /> *[StatusDetails](#statusdetails-v1)* | Extended data associated with the reason. Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.
23+
`kind`<br /> *string* | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
24+
`message`<br /> *string* | A human-readable description of the status of this operation.
25+
`metadata`<br /> *[ListMeta](#listmeta-v1)* | Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
26+
`reason`<br /> *string* | A machine-readable description of why this operation is in the &#34;Failure&#34; status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.
27+
`status`<br /> *string* | Status of the operation. One of: &#34;Success&#34; or &#34;Failure&#34;. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
28+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## StatusCause v1
2+
3+
Group | Version | Kind
4+
------------ | ---------- | -----------
5+
`meta` | `v1` | `StatusCause`
6+
7+
8+
9+
StatusCause provides more information about an api.Status failure, including cases when multiple errors are encountered.
10+
11+
<aside class="notice">
12+
Appears In:
13+
14+
<ul>
15+
<li><a href="#statusdetails-v1">StatusDetails v1</a></li>
16+
</ul></aside>
17+
18+
Field | Description
19+
------------ | -----------
20+
`field`<br /> *string* | The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional. Examples: &#34;name&#34; - the field &#34;name&#34; on the current resource &#34;items[0].name&#34; - the field &#34;name&#34; on the first array entry in &#34;items&#34;
21+
`message`<br /> *string* | A human-readable description of the cause of the error. This field may be presented as-is to a reader.
22+
`reason`<br /> *string* | A machine-readable description of the cause of the error. If this value is empty there is no information available.
23+

0 commit comments

Comments
 (0)