Skip to content

Commit

Permalink
Merge pull request #459 from ecordell/apiserver-dependency
Browse files Browse the repository at this point in the history
feat(olm): support depending on APIservices
  • Loading branch information
openshift-merge-robot authored Sep 18, 2018
2 parents 0e00602 + 2a39d65 commit e573c9c
Show file tree
Hide file tree
Showing 54 changed files with 7,286 additions and 118 deletions.
22 changes: 22 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ required = ["k8s.io/kube-openapi/cmd/openapi-gen"]
name = "k8s.io/kube-openapi"
source = "github.com/kubernetes/kube-openapi"
revision = "d8ea2fe547a448256204cfc68dfee7b26c720acb"

[[constraint]]
branch = "release-1.11"
name = "k8s.io/kube-aggregator"
184 changes: 184 additions & 0 deletions deploy/chart/templates/03-clusterserviceversion.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,190 @@ spec:
values:
type: array
description: set of values for the expression
apiservicedefinitions:
type: object
properties:
owned:
type: array
description: What resources this operator is responsible for managing. No two running operators should manage the same resource.
items:
type: object
required:
- name
- version
- kind
- displayName
- description
properties:
name:
type: string
description: Fully qualified name of the APIService (e.g. my-resource-v1.app.coreos.com)
version:
type: string
description: The version field of the APIService
kind:
type: string
description: The kind field of the APIService
displayName:
type: string
description: A human-readable name for the APIService.
description:
type: string
description: A description of the APIService
resources:
type: array
items:
type: object
description: A list of resources that should be displayed for the APIService
required:
- kind
- version
properties:
name:
type: string
description: If a APIService, the fully qualified name of the APIService (e.g. my-resource-v1.app.coreos.com)
version:
type: string
description: The version of the resource kind
kind:
type: string
description: The kind field of the resource kind
statusDescriptors:
type: array
items:
type: object
description: A spec for a field in the status block of the API resource
required:
- path
- displayName
- description
properties:
path:
type: string
description: A jsonpath indexing into the status object on the API resource where the the status value can be found.
displayName:
type: string
description: A human-readable name for the status entry.
description:
type: string
description: A description of the status entry.
x-descriptors:
type: array
description: A list of descriptors for the status entry that indicate the meaning of the field.
items:
type: string
value:
type: object
description: If present, the value of this status is the same for all instances of the API resource and can be found here instead of on the API resource.
specDescriptors:
type: array
items:
type: object
description: A spec for a field in the spec block of the APIService resource.
required:
- path
- displayName
- description
properties:
path:
type: string
description: A jsonpath indexing into the spec object on the API resource where the the spec value can be found.
displayName:
type: string
description: A human-readable name for the spec entry.
description:
type: string
description: A description of the spec entry.
x-descriptors:
type: array
description: A list of descriptors for the spec entry that indicate the meaning of the field.
items:
type: string
value:
type: object
description: If present, the value of this spec is the same for all instances of the API Resource and can be found here instead of on the API resource.
actionDescriptors:
type: array
items:
type: object
description: A spec for actions that can be performed on instances of the API resource
required:
- path
- displayName
- description
properties:
path:
type: string
description: A jsonpath indexing into the spec object on the API resource where the the spec value can be found.
displayName:
type: string
description: A human-readable name for the action.
description:
type: string
description: A description of the action.
x-descriptors:
type: array
description: A list of descriptors for the action that indicate the meaning of the action.
items:
type: string
value:
type: object
description: If present, the value of this action is the same for all instances of the API resource and can be found here instead of on the API resource.
required:
type: array
description: What resources this operator is responsible for managing. No two running operators should manage the same resource.
items:
type: object
required:
- name
- version
- kind
- displayName
- description
properties:
name:
type: string
description: Fully qualified name of the APIService (e.g. my-resource-v1.app.coreos.com)
version:
type: string
description: The version field of the APIService
kind:
type: string
description: The kind field of the APIService
displayName:
type: string
description: A human-readable name for the APIService.
description:
type: string
description: A description of the APIService
statusDescriptors:
type: array
items:
type: object
description: A spec for a field in the status block of the APIService
required:
- path
- displayName
- description
properties:
path:
type: string
description: A jsonpath indexing into the status object on the API Resource where the the status value can be found.
displayName:
type: string
description: A human-readable name for the status entry.
description:
type: string
description: A description of the status entry.
x-descriptors:
type: array
description: A list of descriptors for the status entry that indicate the meaning of the field.
items:
type: string
value:
type: object
description: If present, the value of this status is the same for all instances of the API Resource and can be found here instead of on the API Resource.

customresourcedefinitions:
type: object
properties:
Expand Down
64 changes: 57 additions & 7 deletions pkg/api/apis/operators/v1alpha1/clusterserviceversion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type NamedInstallStrategy struct {
StrategySpecRaw json.RawMessage `json:"spec,omitempty"`
}

// StatusDescriptor describes a field in a status block of a CRD so that ALM can consume it
// StatusDescriptor describes a field in a status block of a CRD so that OLM can consume it
type StatusDescriptor struct {
Path string `json:"path"`
DisplayName string `json:"displayName,omitempty"`
Expand All @@ -32,7 +32,7 @@ type StatusDescriptor struct {
Value *json.RawMessage `json:"value,omitempty"`
}

// SpecDescriptor describes a field in a spec block of a CRD so that ALM can consume it
// SpecDescriptor describes a field in a spec block of a CRD so that OLM can consume it
type SpecDescriptor struct {
Path string `json:"path"`
DisplayName string `json:"displayName,omitempty"`
Expand All @@ -50,21 +50,34 @@ type ActionDescriptor struct {
Value *json.RawMessage `json:"value,omitempty"`
}

// CRDDescription provides details to ALM about the CRDs
// CRDDescription provides details to OLM about the CRDs
type CRDDescription struct {
Name string `json:"name"`
Version string `json:"version"`
Kind string `json:"kind"`
DisplayName string `json:"displayName,omitempty"`
Description string `json:"description,omitempty"`
Resources []CRDResourceReference `json:"resources,omitempty"`
Resources []APIResourceReference `json:"resources,omitempty"`
StatusDescriptors []StatusDescriptor `json:"statusDescriptors,omitempty"`
SpecDescriptors []SpecDescriptor `json:"specDescriptors,omitempty"`
ActionDescriptor []ActionDescriptor `json:"actionDescriptors,omitempty"`
}

// CRDResourceReference is a Kubernetes resource type used by a custom resource
type CRDResourceReference struct {
// APIServiceDescription provides details to OLM about apis provided via aggregation
type APIServiceDescription struct {
Name string `json:"name"`
Version string `json:"version"`
Kind string `json:"kind"`
DisplayName string `json:"displayName,omitempty"`
Description string `json:"description,omitempty"`
Resources []APIResourceReference `json:"resources,omitempty"`
StatusDescriptors []StatusDescriptor `json:"statusDescriptors,omitempty"`
SpecDescriptors []SpecDescriptor `json:"specDescriptors,omitempty"`
ActionDescriptor []ActionDescriptor `json:"actionDescriptors,omitempty"`
}

// APIResourceReference is a Kubernetes resource type used by a custom resource
type APIResourceReference struct {
Name string `json:"name"`
Kind string `json:"kind"`
Version string `json:"version"`
Expand All @@ -79,13 +92,21 @@ type CustomResourceDefinitions struct {
Required []CRDDescription `json:"required,omitempty"`
}

// ClusterServiceVersionSpec declarations tell the ALM how to install an operator
// APIServiceDefinitions declares all of the extension apis managed or required by
// an operator being ran by ClusterServiceVersion.
type APIServiceDefinitions struct {
Owned []APIServiceDescription `json:"owned,omitempty"`
Required []APIServiceDescription `json:"required,omitempty"`
}

// ClusterServiceVersionSpec declarations tell the OLM how to install an operator
// that can manage apps for given version and AppType.
type ClusterServiceVersionSpec struct {
InstallStrategy NamedInstallStrategy `json:"install"`
Version semver.Version `json:"version,omitempty"`
Maturity string `json:"maturity,omitempty"`
CustomResourceDefinitions CustomResourceDefinitions `json:"customresourcedefinitions,omitempty"`
APIServiceDefinitions APIServiceDefinitions `json:"apiservicedefinitions,omitempty"`
DisplayName string `json:"displayName"`
Description string `json:"description,omitempty"`
Keywords []string `json:"keywords,omitempty"`
Expand Down Expand Up @@ -282,3 +303,32 @@ func (csv ClusterServiceVersion) GetAllCRDDescriptions() []CRDDescription {

return descs
}

// GetAllAPIServiceDescriptions returns a deduplicated set of APIServiceDescriptions that is
// the union of the owned and required APIServiceDescriptions.
//
// Descriptions with the same name prefer the value in Owned.
// Descriptions are returned in alphabetical order.
func (csv ClusterServiceVersion) GetAllAPIServiceDescriptions() []APIServiceDescription {
set := make(map[string]APIServiceDescription)
for _, required := range csv.Spec.APIServiceDefinitions.Required {
set[required.Name] = required
}

for _, owned := range csv.Spec.APIServiceDefinitions.Owned {
set[owned.Name] = owned
}

keys := make([]string, 0)
for key := range set {
keys = append(keys, key)
}
sort.StringSlice(keys).Sort()

descs := make([]APIServiceDescription, 0)
for _, key := range keys {
descs = append(descs, set[key])
}

return descs
}
Loading

0 comments on commit e573c9c

Please sign in to comment.