Skip to content

Commit

Permalink
ResourceGroup implementing Inventory interface
Browse files Browse the repository at this point in the history
  • Loading branch information
seans3 committed Aug 25, 2020
1 parent d449fa3 commit 2fa7cc4
Show file tree
Hide file tree
Showing 6 changed files with 560 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ linters:
- varcheck
# - whitespace

issues:
exclude:
- Using the variable on range scope `tc` in function literal

linters-settings:
dupl:
threshold: 400
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
k8s.io/apimachinery v0.17.3
k8s.io/cli-runtime v0.17.3
k8s.io/client-go v0.17.3
k8s.io/klog v1.0.0
// Currently, we have to import the latest version of kubectl.
// Once there is a 0.18 release, we can import a semver release.
k8s.io/kubectl v0.0.0-20191219154910-1528d4eea6dd
Expand Down
213 changes: 213 additions & 0 deletions internal/live/example-resource-group-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Example ResourceGroup custom resource definition. This CRD is used
# to keep track of the resources that are applied together by
# storing references to the applied resources (aka inventory).
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
name: resourcegroups.configmanagement.gke.io
spec:
group: configmanagement.gke.io
names:
kind: ResourceGroup
listKind: ResourceGroupList
plural: resourcegroups
singular: resourcegroup
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: ResourceGroup is the Schema for the resourcegroups API
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: ResourceGroupSpec defines the desired state of ResourceGroup
properties:
descriptor:
description: Descriptor regroups the information and metadata about
a resource group
properties:
description:
description: Description is a brief description of a group of resources
type: string
links:
description: Links are a list of descriptive URLs intended to be
used to surface additional information
items:
properties:
description:
description: Description explains the purpose of the link
type: string
url:
description: Url is the URL of the link
type: string
required:
- description
- url
type: object
type: array
revision:
description: Revision is an optional revision for a group of resources
type: string
type:
description: Type can contain prefix, such as Application/WordPress
or Service/Spanner
type: string
type: object
resources:
description: Resources contains a list of resources that form the resource group
items:
description: ObjMetadata organizes and stores the identifying information
for an object. This struct (as a string) is stored in a grouping
object to keep track of sets of applied objects.
properties:
group:
type: string
kind:
type: string
name:
type: string
namespace:
type: string
required:
- group
- kind
- name
- namespace
type: object
type: array
type: object
status:
description: ResourceGroupStatus defines the observed state of ResourceGroup
properties:
conditions:
description: Conditions lists the conditions of the current status for
the group
items:
properties:
lastTransitionTime:
description: last time the condition transit from one status to
another
format: date-time
type: string
message:
description: human-readable message indicating details about last
transition
type: string
reason:
description: one-word CamelCase reason for the condition's last
transition
type: string
status:
description: Status of the condition
type: string
type:
description: Type of the condition
type: string
required:
- status
- type
type: object
type: array
observedGeneration:
description: ObservedGeneration is the most recent generation observed.
It corresponds to the Object's generation, which is updated on mutation
by the API Server. Everytime the controller does a successful reconcile,
it sets ObservedGeneration to match ResourceGroup.metadata.generation.
format: int64
type: integer
resourceStatuses:
description: ResourceStatuses lists the status for each resource in
the group
items:
description: ResourceStatus contains the status of a given resource
uniquely identified by its group, kind, name and namespace.
properties:
conditions:
items:
properties:
lastTransitionTime:
description: last time the condition transit from one status
to another
format: date-time
type: string
message:
description: human-readable message indicating details about
last transition
type: string
reason:
description: one-word CamelCase reason for the condition’s
last transition
type: string
status:
description: Status of the condition
type: string
type:
description: Type of the condition
type: string
required:
- status
- type
type: object
type: array
group:
type: string
kind:
type: string
name:
type: string
namespace:
type: string
status:
description: Status describes the status of a resource
type: string
required:
- group
- kind
- name
- namespace
- status
type: object
type: array
required:
- observedGeneration
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
31 changes: 31 additions & 0 deletions internal/live/example-resource-group.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Example ResourceGroup custom resource with references to
# two ConfigMaps in the inventory.
apiVersion: "configmanagement.gke.io/v1beta1"
kind: ResourceGroup
metadata:
namespace: default
name: example-inventory
spec:
resources:
- group: ""
kind: ConfigMap
namespace: default
name: cm-a
- group: ""
kind: ConfigMap
namespace: default
name: cm-b
Loading

0 comments on commit 2fa7cc4

Please sign in to comment.