Skip to content

Commit

Permalink
added openapiv3 schema validation to crd
Browse files Browse the repository at this point in the history
  • Loading branch information
senthilrch committed Jan 30, 2020
1 parent 5d31a02 commit e981cf0
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 19 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ _kube-fledged_ provides CRUD APIs to manage the lifecycle of the image cache, an

These instructions install _kube-fledged_ using pre-built images of the latest stable release in [Docker Hub.](https://hub.docker.com/u/senthilrch)

- Clone the source code repository to your home directory
- Clone the source code repository

```
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/kube-fledged
$ cd $HOME/kube-fledged
$ mkdir -p $HOME/src/github.com/senthilrch
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/src/github.com/senthilrch/kube-fledged
$ cd $HOME/src/github.com/senthilrch/kube-fledged
```

- Deploy _kube-fledged_ to the cluster
Expand All @@ -56,11 +57,12 @@ These instructions will help you build _kube-fledged_ from source and deploy it

### Build

- Clone the source code repository to your home directory
- Clone the source code repository

```
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/kube-fledged
$ cd $HOME/kube-fledged
$ mkdir -p $HOME/src/github.com/senthilrch
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/src/github.com/senthilrch/kube-fledged
$ cd $HOME/src/github.com/senthilrch/kube-fledged
```

- If you are behind a proxy, export the following ENV variables (UPPER case)
Expand Down
4 changes: 2 additions & 2 deletions cmd/app/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (c *Controller) danglingImageCaches() error {
return nil
}
status := &fledgedv1alpha1.ImageCacheStatus{
Failures: map[string][]fledgedv1alpha1.NodeReasonMessage{},
Failures: map[string]fledgedv1alpha1.NodeReasonMessageList{},
Status: fledgedv1alpha1.ImageCacheActionStatusAborted,
Reason: fledgedv1alpha1.ImageCacheReasonImagePullAborted,
Message: fledgedv1alpha1.ImageCacheMessageImagePullAborted,
Expand Down Expand Up @@ -423,7 +423,7 @@ func (c *Controller) runRefreshWorker() {
// with the current status of the resource.
func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
status := &fledgedv1alpha1.ImageCacheStatus{
Failures: map[string][]fledgedv1alpha1.NodeReasonMessage{},
Failures: map[string]fledgedv1alpha1.NodeReasonMessageList{},
}

// Convert the namespace/name string into a distinct namespace and name
Expand Down
99 changes: 96 additions & 3 deletions deploy/fledged-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,106 @@ metadata:
spec:
group: fledged.k8s.io
versions:
- name: v1alpha1
served: true
storage: true
- name: v1alpha1
served: true
storage: true
scope: Namespaced
names:
plural: imagecaches
singular: imagecache
kind: ImageCache
shortNames:
- ic
"validation":
"openAPIV3Schema":
description: ImageCache is a specification for a ImageCache resource
type: object
required:
- spec
- status
properties:
apiVersion:
description: '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/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: '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/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ImageCacheSpec is the spec for a ImageCache resource
type: object
required:
- cacheSpec
properties:
cacheSpec:
type: array
items:
description: CacheSpecImages specifies the Images to be cached
type: object
required:
- images
properties:
images:
type: array
items:
type: string
nodeSelector:
type: object
additionalProperties:
type: string
imagePullSecrets:
type: array
items:
description: LocalObjectReference contains enough information to let
you locate the referenced object inside the same namespace.
type: object
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
status:
description: ImageCacheStatus is the status for a ImageCache resource
type: object
required:
- message
- reason
- status
properties:
completionTime:
type: string
format: date-time
failures:
type: object
additionalProperties:
type: array
items:
description: NodeReasonMessage has failure reason and message for
a node
type: object
required:
- message
- node
- reason
properties:
message:
type: string
node:
type: string
reason:
type: string
message:
type: string
reason:
type: string
startTime:
type: string
format: date-time
status:
description: ImageCacheActionStatus defines the status of ImageCacheAction
type: string
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ require (
k8s.io/api v0.17.2
k8s.io/apimachinery v0.17.2
k8s.io/client-go v0.17.2
k8s.io/code-generator v0.17.2 // indirect
k8s.io/utils v0.0.0-20200122174043-1e243dd1a584 // indirect
)
Loading

0 comments on commit e981cf0

Please sign in to comment.