add application controller (#2652)
Signed-off-by: Jeff <zw0948@gmail.com>
This commit is contained in:
201
vendor/github.com/kubernetes-sigs/application/LICENSE
generated
vendored
201
vendor/github.com/kubernetes-sigs/application/LICENSE
generated
vendored
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
||||
180
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/application.go
generated
vendored
180
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/application.go
generated
vendored
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
"github.com/kubernetes-sigs/application/pkg/component"
|
||||
cr "github.com/kubernetes-sigs/application/pkg/customresource"
|
||||
"github.com/kubernetes-sigs/application/pkg/finalizer"
|
||||
"github.com/kubernetes-sigs/application/pkg/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Mutate - mutate expected
|
||||
func (a *Application) Mutate(rsrc interface{}, labels map[string]string, status interface{}, expected, dependent, observed *resource.ObjectBag) (*resource.ObjectBag, error) {
|
||||
exp := resource.ObjectBag{}
|
||||
for _, o := range observed.Items() {
|
||||
o.Lifecycle = resource.LifecycleManaged
|
||||
exp.Add(o)
|
||||
}
|
||||
return &exp, nil
|
||||
}
|
||||
|
||||
// Finalize - execute finalizers
|
||||
func (a *Application) Finalize(rsrc, sts interface{}, observed *resource.ObjectBag) error {
|
||||
finalizer.Remove(a, finalizer.Cleanup)
|
||||
return nil
|
||||
}
|
||||
|
||||
//DependentResources - returns dependent rsrc
|
||||
func (a *Application) DependentResources(rsrc interface{}) *resource.ObjectBag {
|
||||
return &resource.ObjectBag{}
|
||||
}
|
||||
|
||||
// ExpectedResources returns the list of resource/name for those resources created by
|
||||
// the operator for this spec and those resources referenced by this operator.
|
||||
// Mark resources as owned, referred
|
||||
func (a *Application) ExpectedResources(rsrc interface{}, rsrclabels map[string]string, dependent, aggregated *resource.ObjectBag) (*resource.ObjectBag, error) {
|
||||
return &resource.ObjectBag{}, nil
|
||||
}
|
||||
|
||||
// GKVersions returns the gvks for the given gk
|
||||
func GKVersions(s *runtime.Scheme, mgk metav1.GroupKind) []schema.GroupVersionKind {
|
||||
gvks := []schema.GroupVersionKind{}
|
||||
gk := schema.GroupKind{Group: mgk.Group, Kind: mgk.Kind}
|
||||
for gvk := range s.AllKnownTypes() {
|
||||
if gk != gvk.GroupKind() {
|
||||
continue
|
||||
}
|
||||
gvks = append(gvks, gvk)
|
||||
}
|
||||
return gvks
|
||||
}
|
||||
|
||||
// Observables - return selectors
|
||||
func (a *Application) Observables(scheme *runtime.Scheme, rsrc interface{}, rsrclabels map[string]string, expected *resource.ObjectBag) []resource.Observable {
|
||||
var observables []resource.Observable
|
||||
if a.Spec.Selector == nil || a.Spec.Selector.MatchLabels == nil {
|
||||
return observables
|
||||
}
|
||||
for _, gk := range a.Spec.ComponentGroupKinds {
|
||||
listGK := gk
|
||||
if !strings.HasSuffix(listGK.Kind, "List") {
|
||||
listGK.Kind = listGK.Kind + "List"
|
||||
}
|
||||
for _, gvk := range GKVersions(scheme, listGK) {
|
||||
ol, err := scheme.New(gvk)
|
||||
if err == nil {
|
||||
observable := resource.Observable{
|
||||
ObjList: ol.(metav1.ListInterface),
|
||||
Labels: a.Spec.Selector.MatchLabels,
|
||||
Namespace: rsrc.(metav1.Object).GetNamespace(),
|
||||
}
|
||||
observables = append(observables, observable)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return observables
|
||||
}
|
||||
|
||||
// Differs returns true if the resource needs to be updated
|
||||
func (a *Application) Differs(expected metav1.Object, observed metav1.Object) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// UpdateComponentStatus use reconciled objects to update component status
|
||||
func (a *Application) UpdateComponentStatus(rsrci, statusi interface{}, reconciled *resource.ObjectBag, err error) {
|
||||
if a != nil {
|
||||
stts := statusi.(*ApplicationStatus)
|
||||
stts.UpdateStatus(reconciled.Objs(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyDefaults default app crd
|
||||
func (a *Application) ApplyDefaults() {
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateRsrcStatus records status or error in status
|
||||
func (a *Application) UpdateRsrcStatus(status interface{}, err error) bool {
|
||||
appstatus := status.(*ApplicationStatus)
|
||||
if status != nil {
|
||||
a.Status = *appstatus
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
a.Status.SetError("ErrorSeen", err.Error())
|
||||
} else {
|
||||
a.Status.ClearError()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Validate the Application
|
||||
func (a *Application) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Components returns components for this resource
|
||||
func (a *Application) Components() []component.Component {
|
||||
c := []component.Component{}
|
||||
c = append(c, component.Component{
|
||||
Handle: a,
|
||||
Name: "app",
|
||||
CR: a,
|
||||
OwnerRef: a.OwnerRef(),
|
||||
})
|
||||
return c
|
||||
}
|
||||
|
||||
// OwnerRef returns owner ref object with the component's resource as owner
|
||||
func (a *Application) OwnerRef() *metav1.OwnerReference {
|
||||
if !a.Spec.AddOwnerRef {
|
||||
return nil
|
||||
}
|
||||
|
||||
isController := false
|
||||
gvk := schema.GroupVersionKind{
|
||||
Group: SchemeGroupVersion.Group,
|
||||
Version: SchemeGroupVersion.Version,
|
||||
Kind: "Application",
|
||||
}
|
||||
ref := metav1.NewControllerRef(a, gvk)
|
||||
ref.Controller = &isController
|
||||
return ref
|
||||
}
|
||||
|
||||
// NewRsrc - return a new resource object
|
||||
func (a *Application) NewRsrc() cr.Handle {
|
||||
return &Application{}
|
||||
}
|
||||
|
||||
// NewStatus - return a resource status object
|
||||
func (a *Application) NewStatus() interface{} {
|
||||
s := a.Status.DeepCopy()
|
||||
s.ComponentList = ComponentList{}
|
||||
return s
|
||||
}
|
||||
|
||||
// StatusDiffers returns True if there is a change in status
|
||||
func (a *Application) StatusDiffers(new ApplicationStatus) bool {
|
||||
return true
|
||||
}
|
||||
326
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/application_types.go
generated
vendored
326
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/application_types.go
generated
vendored
@@ -1,326 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// Constants for condition
|
||||
const (
|
||||
// Ready => controller considers this resource Ready
|
||||
Ready = "Ready"
|
||||
// Qualified => functionally tested
|
||||
Qualified = "Qualified"
|
||||
// Settled => observed generation == generation + settled means controller is done acting functionally tested
|
||||
Settled = "Settled"
|
||||
// Cleanup => it is set to track finalizer failures
|
||||
Cleanup = "Cleanup"
|
||||
// Error => last recorded error
|
||||
Error = "Error"
|
||||
|
||||
ReasonInit = "Init"
|
||||
)
|
||||
|
||||
// Descriptor defines the Metadata and informations about the Application.
|
||||
type Descriptor struct {
|
||||
// Type is the type of the application (e.g. WordPress, MySQL, Cassandra).
|
||||
Type string `json:"type,omitempty"`
|
||||
|
||||
// Version is an optional version indicator for the Application.
|
||||
Version string `json:"version,omitempty"`
|
||||
|
||||
// Description is a brief string description of the Application.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// Icons is an optional list of icons for an application. Icon information includes the source, size,
|
||||
// and mime type.
|
||||
Icons []ImageSpec `json:"icons,omitempty"`
|
||||
|
||||
// Maintainers is an optional list of maintainers of the application. The maintainers in this list maintain the
|
||||
// the source code, images, and package for the application.
|
||||
Maintainers []ContactData `json:"maintainers,omitempty"`
|
||||
|
||||
// Owners is an optional list of the owners of the installed application. The owners of the application should be
|
||||
// contacted in the event of a planned or unplanned disruption affecting the application.
|
||||
Owners []ContactData `json:"owners,omitempty"`
|
||||
|
||||
// Keywords is an optional list of key words associated with the application (e.g. MySQL, RDBMS, database).
|
||||
Keywords []string `json:"keywords,omitempty"`
|
||||
|
||||
// Links are a list of descriptive URLs intended to be used to surface additional documentation, dashboards, etc.
|
||||
Links []Link `json:"links,omitempty"`
|
||||
|
||||
// Notes contain a human readable snippets intended as a quick start for the users of the Application.
|
||||
// CommonMark markdown syntax may be used for rich text representation.
|
||||
Notes string `json:"notes,omitempty"`
|
||||
}
|
||||
|
||||
// ApplicationSpec defines the specification for an Application.
|
||||
type ApplicationSpec struct {
|
||||
// ComponentGroupKinds is a list of Kinds for Application's components (e.g. Deployments, Pods, Services, CRDs). It
|
||||
// can be used in conjunction with the Application's Selector to list or watch the Applications components.
|
||||
ComponentGroupKinds []metav1.GroupKind `json:"componentKinds,omitempty"`
|
||||
|
||||
// Descriptor regroups information and metadata about an application.
|
||||
Descriptor Descriptor `json:"descriptor,omitempty"`
|
||||
|
||||
// Selector is a label query over kinds that created by the application. It must match the component objects' labels.
|
||||
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
|
||||
Selector *metav1.LabelSelector `json:"selector,omitempty"`
|
||||
|
||||
// AddOwnerRef objects - flag to indicate if we need to add OwnerRefs to matching objects
|
||||
// Matching is done by using Selector to query all ComponentGroupKinds
|
||||
AddOwnerRef bool `json:"addOwnerRef,omitempty"`
|
||||
|
||||
// Info contains human readable key,value pairs for the Application.
|
||||
Info []InfoItem `json:"info,omitempty"`
|
||||
|
||||
// AssemblyPhase represents the current phase of the application's assembly.
|
||||
// An empty value is equivalent to "Succeeded".
|
||||
AssemblyPhase ApplicationAssemblyPhase `json:"assemblyPhase,omitempty"`
|
||||
}
|
||||
|
||||
// ComponentList is a generic status holder for the top level resource
|
||||
// +k8s:deepcopy-gen=true
|
||||
type ComponentList struct {
|
||||
// Object status array for all matching objects
|
||||
Objects []ObjectStatus `json:"components,omitempty"`
|
||||
}
|
||||
|
||||
// ObjectStatus is a generic status holder for objects
|
||||
// +k8s:deepcopy-gen=true
|
||||
type ObjectStatus struct {
|
||||
// Link to object
|
||||
Link string `json:"link,omitempty"`
|
||||
// Name of object
|
||||
Name string `json:"name,omitempty"`
|
||||
// Kind of object
|
||||
Kind string `json:"kind,omitempty"`
|
||||
// Object group
|
||||
Group string `json:"group,omitempty"`
|
||||
// Status. Values: InProgress, Ready, Unknown
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// ConditionType encodes information on the condition
|
||||
type ConditionType string
|
||||
|
||||
// Condition describes the state of an object at a certain point.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type Condition struct {
|
||||
// Type of condition.
|
||||
Type ConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=StatefulSetConditionType"`
|
||||
// Status of the condition, one of True, False, Unknown.
|
||||
Status corev1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
|
||||
// The reason for the condition's last transition.
|
||||
// +optional
|
||||
Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
|
||||
// A human readable message indicating details about the transition.
|
||||
// +optional
|
||||
Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
|
||||
// Last time the condition was probed
|
||||
// +optional
|
||||
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty" protobuf:"bytes,3,opt,name=lastProbeTime"`
|
||||
// Last time the condition transitioned from one status to another.
|
||||
// +optional
|
||||
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
|
||||
}
|
||||
|
||||
// ApplicationStatus defines controller's the observed state of Application
|
||||
type ApplicationStatus struct {
|
||||
// ObservedGeneration is the most recent generation observed. It corresponds to the
|
||||
// Object's generation, which is updated on mutation by the API Server.
|
||||
// +optional
|
||||
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
|
||||
// Conditions represents the latest state of the object
|
||||
// +optional
|
||||
// +patchMergeKey=type
|
||||
// +patchStrategy=merge
|
||||
Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"`
|
||||
// Resources embeds a list of object statuses
|
||||
// +optional
|
||||
ComponentList `json:",inline,omitempty"`
|
||||
}
|
||||
|
||||
// ImageSpec contains information about an image used as an icon.
|
||||
type ImageSpec struct {
|
||||
// The source for image represented as either an absolute URL to the image or a Data URL containing
|
||||
// the image. Data URLs are defined in RFC 2397.
|
||||
Source string `json:"src"`
|
||||
|
||||
// (optional) The size of the image in pixels (e.g., 25x25).
|
||||
Size string `json:"size,omitempty"`
|
||||
|
||||
// (optional) The mine type of the image (e.g., "image/png").
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// ContactData contains information about an individual or organization.
|
||||
type ContactData struct {
|
||||
// Name is the descriptive name.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// Url could typically be a website address.
|
||||
URL string `json:"url,omitempty"`
|
||||
|
||||
// Email is the email address.
|
||||
Email string `json:"email,omitempty"`
|
||||
}
|
||||
|
||||
// Link contains information about an URL to surface documentation, dashboards, etc.
|
||||
type Link struct {
|
||||
// Description is human readable content explaining the purpose of the link.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// Url typically points at a website address.
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// InfoItem is a human readable key,value pair containing important information about how to access the Application.
|
||||
type InfoItem struct {
|
||||
// Name is a human readable title for this piece of information.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// Type of the value for this InfoItem.
|
||||
Type InfoItemType `json:"type,omitempty"`
|
||||
|
||||
// Value is human readable content.
|
||||
Value string `json:"value,omitempty"`
|
||||
|
||||
// ValueFrom defines a reference to derive the value from another source.
|
||||
ValueFrom *InfoItemSource `json:"valueFrom,omitempty"`
|
||||
}
|
||||
|
||||
// InfoItemType is a string that describes the value of InfoItem
|
||||
type InfoItemType string
|
||||
|
||||
const (
|
||||
// ValueInfoItemType const string for value type
|
||||
ValueInfoItemType InfoItemType = "Value"
|
||||
// ReferenceInfoItemType const string for ref type
|
||||
ReferenceInfoItemType InfoItemType = "Reference"
|
||||
)
|
||||
|
||||
// InfoItemSource represents a source for the value of an InfoItem.
|
||||
type InfoItemSource struct {
|
||||
// Type of source.
|
||||
Type InfoItemSourceType `json:"type,omitempty"`
|
||||
|
||||
// Selects a key of a Secret.
|
||||
SecretKeyRef *SecretKeySelector `json:"secretKeyRef,omitempty"`
|
||||
|
||||
// Selects a key of a ConfigMap.
|
||||
ConfigMapKeyRef *ConfigMapKeySelector `json:"configMapKeyRef,omitempty"`
|
||||
|
||||
// Select a Service.
|
||||
ServiceRef *ServiceSelector `json:"serviceRef,omitempty"`
|
||||
|
||||
// Select an Ingress.
|
||||
IngressRef *IngressSelector `json:"ingressRef,omitempty"`
|
||||
}
|
||||
|
||||
// InfoItemSourceType is a string
|
||||
type InfoItemSourceType string
|
||||
|
||||
// Constants for info type
|
||||
const (
|
||||
SecretKeyRefInfoItemSourceType InfoItemSourceType = "SecretKeyRef"
|
||||
ConfigMapKeyRefInfoItemSourceType InfoItemSourceType = "ConfigMapKeyRef"
|
||||
ServiceRefInfoItemSourceType InfoItemSourceType = "ServiceRef"
|
||||
IngressRefInfoItemSourceType InfoItemSourceType = "IngressRef"
|
||||
)
|
||||
|
||||
// ConfigMapKeySelector selects a key from a ConfigMap.
|
||||
type ConfigMapKeySelector struct {
|
||||
// The ConfigMap to select from.
|
||||
corev1.ObjectReference `json:",inline"`
|
||||
// The key to select.
|
||||
Key string `json:"key,omitempty"`
|
||||
}
|
||||
|
||||
// SecretKeySelector selects a key from a Secret.
|
||||
type SecretKeySelector struct {
|
||||
// The Secret to select from.
|
||||
corev1.ObjectReference `json:",inline"`
|
||||
// The key to select.
|
||||
Key string `json:"key,omitempty"`
|
||||
}
|
||||
|
||||
// ServiceSelector selects a Service.
|
||||
type ServiceSelector struct {
|
||||
// The Service to select from.
|
||||
corev1.ObjectReference `json:",inline"`
|
||||
// The optional port to select.
|
||||
Port *int32 `json:"port,omitempty"`
|
||||
// The optional HTTP path.
|
||||
Path string `json:"path,omitempty"`
|
||||
}
|
||||
|
||||
// IngressSelector selects an Ingress.
|
||||
type IngressSelector struct {
|
||||
// The Ingress to select from.
|
||||
corev1.ObjectReference `json:",inline"`
|
||||
// The optional host to select.
|
||||
Host string `json:"host,omitempty"`
|
||||
// The optional HTTP path.
|
||||
Path string `json:"path,omitempty"`
|
||||
}
|
||||
|
||||
// ApplicationAssemblyPhase tracks the Application CRD phases: pending, succeded, failed
|
||||
type ApplicationAssemblyPhase string
|
||||
|
||||
// Constants
|
||||
const (
|
||||
// Used to indicate that not all of application's components
|
||||
// have been deployed yet.
|
||||
Pending ApplicationAssemblyPhase = "Pending"
|
||||
// Used to indicate that all of application's components
|
||||
// have already been deployed.
|
||||
Succeeded = "Succeeded"
|
||||
// Used to indicate that deployment of application's components
|
||||
// failed. Some components might be present, but deployment of
|
||||
// the remaining ones will not be re-attempted.
|
||||
Failed = "Failed"
|
||||
)
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// Application is the Schema for the applications API
|
||||
// +k8s:openapi-gen=true
|
||||
type Application struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ApplicationSpec `json:"spec,omitempty"`
|
||||
Status ApplicationStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ApplicationList contains a list of Application
|
||||
type ApplicationList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []Application `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&Application{}, &ApplicationList{})
|
||||
}
|
||||
168
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/condition.go
generated
vendored
168
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/condition.go
generated
vendored
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func (m *ApplicationStatus) addCondition(ctype ConditionType, status corev1.ConditionStatus, reason, message string) {
|
||||
now := metav1.Now()
|
||||
c := &Condition{
|
||||
Type: ctype,
|
||||
LastUpdateTime: now,
|
||||
LastTransitionTime: now,
|
||||
Status: status,
|
||||
Reason: reason,
|
||||
Message: message,
|
||||
}
|
||||
m.Conditions = append(m.Conditions, *c)
|
||||
}
|
||||
|
||||
// setConditionValue updates or creates a new condition
|
||||
func (m *ApplicationStatus) setConditionValue(ctype ConditionType, status corev1.ConditionStatus, reason, message string) {
|
||||
var c *Condition
|
||||
for i := range m.Conditions {
|
||||
if m.Conditions[i].Type == ctype {
|
||||
c = &m.Conditions[i]
|
||||
}
|
||||
}
|
||||
if c == nil {
|
||||
m.addCondition(ctype, status, reason, message)
|
||||
} else {
|
||||
// check message ?
|
||||
if c.Status == status && c.Reason == reason && c.Message == message {
|
||||
return
|
||||
}
|
||||
now := metav1.Now()
|
||||
c.LastUpdateTime = now
|
||||
if c.Status != status {
|
||||
c.LastTransitionTime = now
|
||||
}
|
||||
c.Status = status
|
||||
c.Reason = reason
|
||||
c.Message = message
|
||||
}
|
||||
}
|
||||
|
||||
// RemoveCondition removes the condition with the provided type.
|
||||
func (m *ApplicationStatus) RemoveCondition(ctype ConditionType) {
|
||||
for i, c := range m.Conditions {
|
||||
if c.Type == ctype {
|
||||
m.Conditions[i] = m.Conditions[len(m.Conditions)-1]
|
||||
m.Conditions = m.Conditions[:len(m.Conditions)-1]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetCondition get existing condition
|
||||
func (m *ApplicationStatus) GetCondition(ctype ConditionType) *Condition {
|
||||
for i := range m.Conditions {
|
||||
if m.Conditions[i].Type == ctype {
|
||||
return &m.Conditions[i]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsConditionTrue - if condition is true
|
||||
func (m *ApplicationStatus) IsConditionTrue(ctype ConditionType) bool {
|
||||
if c := m.GetCondition(ctype); c != nil {
|
||||
return c.Status == corev1.ConditionTrue
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsReady returns true if ready condition is set
|
||||
func (m *ApplicationStatus) IsReady() bool { return m.IsConditionTrue(Ready) }
|
||||
|
||||
// IsNotReady returns true if ready condition is set
|
||||
func (m *ApplicationStatus) IsNotReady() bool { return !m.IsConditionTrue(Ready) }
|
||||
|
||||
// ConditionReason - return condition reason
|
||||
func (m *ApplicationStatus) ConditionReason(ctype ConditionType) string {
|
||||
if c := m.GetCondition(ctype); c != nil {
|
||||
return c.Reason
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Ready - shortcut to set ready contition to true
|
||||
func (m *ApplicationStatus) Ready(reason, message string) {
|
||||
m.SetCondition(Ready, reason, message)
|
||||
}
|
||||
|
||||
// NotReady - shortcut to set ready contition to false
|
||||
func (m *ApplicationStatus) NotReady(reason, message string) {
|
||||
m.ClearCondition(Ready, reason, message)
|
||||
}
|
||||
|
||||
// SetError - shortcut to set error condition
|
||||
func (m *ApplicationStatus) SetError(reason, message string) {
|
||||
m.SetCondition(Error, reason, message)
|
||||
}
|
||||
|
||||
// ClearError - shortcut to set error condition
|
||||
func (m *ApplicationStatus) ClearError() {
|
||||
m.ClearCondition(Error, "NoError", "No error seen")
|
||||
}
|
||||
|
||||
// Settled - shortcut to set Settled contition to true
|
||||
func (m *ApplicationStatus) Settled(reason, message string) {
|
||||
m.SetCondition(Settled, reason, message)
|
||||
}
|
||||
|
||||
// NotSettled - shortcut to set Settled contition to false
|
||||
func (m *ApplicationStatus) NotSettled(reason, message string) {
|
||||
m.ClearCondition(Settled, reason, message)
|
||||
}
|
||||
|
||||
// EnsureCondition useful for adding default conditions
|
||||
func (m *ApplicationStatus) EnsureCondition(ctype ConditionType) {
|
||||
if c := m.GetCondition(ctype); c != nil {
|
||||
return
|
||||
}
|
||||
m.addCondition(ctype, corev1.ConditionUnknown, ReasonInit, "Not Observed")
|
||||
}
|
||||
|
||||
// EnsureStandardConditions - helper to inject standard conditions
|
||||
func (m *ApplicationStatus) EnsureStandardConditions() {
|
||||
m.EnsureCondition(Ready)
|
||||
m.EnsureCondition(Settled)
|
||||
m.EnsureCondition(Error)
|
||||
}
|
||||
|
||||
// ClearCondition updates or creates a new condition
|
||||
func (m *ApplicationStatus) ClearCondition(ctype ConditionType, reason, message string) {
|
||||
m.setConditionValue(ctype, corev1.ConditionFalse, reason, message)
|
||||
}
|
||||
|
||||
// SetCondition updates or creates a new condition
|
||||
func (m *ApplicationStatus) SetCondition(ctype ConditionType, reason, message string) {
|
||||
m.setConditionValue(ctype, corev1.ConditionTrue, reason, message)
|
||||
}
|
||||
|
||||
// RemoveAllConditions updates or creates a new condition
|
||||
func (m *ApplicationStatus) RemoveAllConditions() {
|
||||
m.Conditions = []Condition{}
|
||||
}
|
||||
|
||||
// ClearAllConditions updates or creates a new condition
|
||||
func (m *ApplicationStatus) ClearAllConditions() {
|
||||
for i := range m.Conditions {
|
||||
m.Conditions[i].Status = corev1.ConditionFalse
|
||||
}
|
||||
}
|
||||
23
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/doc.go
generated
vendored
23
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/doc.go
generated
vendored
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Package v1beta1 contains API Schema definitions for the app v1beta1 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=github.com/kubernetes-sigs/application/pkg/apis/app
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=app.k8s.io
|
||||
package v1beta1
|
||||
46
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/register.go
generated
vendored
46
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/register.go
generated
vendored
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// NOTE: Boilerplate only. Ignore this file.
|
||||
|
||||
// Package v1beta1 contains API Schema definitions for the app v1beta1 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=github.com/kubernetes-sigs/application/pkg/apis/app
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=app.k8s.io
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: "app.k8s.io", Version: "v1beta1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
|
||||
|
||||
// AddToScheme is required by pkg/client/...
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Resource is required by pkg/client/listers/...
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
193
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/status.go
generated
vendored
193
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/status.go
generated
vendored
@@ -1,193 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
policyv1 "k8s.io/api/policy/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// Constants defining labels
|
||||
const (
|
||||
StatusReady = "Ready"
|
||||
StatusInProgress = "InProgress"
|
||||
StatusDisabled = "Disabled"
|
||||
)
|
||||
|
||||
func (s *ObjectStatus) update(rsrc metav1.Object) {
|
||||
ro := rsrc.(runtime.Object)
|
||||
gvk := ro.GetObjectKind().GroupVersionKind()
|
||||
s.Link = rsrc.GetSelfLink()
|
||||
s.Name = rsrc.GetName()
|
||||
s.Group = gvk.GroupVersion().String()
|
||||
s.Kind = gvk.GroupKind().Kind
|
||||
s.Status = StatusReady
|
||||
}
|
||||
|
||||
// ResetComponentList - reset component list objects
|
||||
func (m *ApplicationStatus) ResetComponentList() {
|
||||
m.ComponentList.Objects = []ObjectStatus{}
|
||||
}
|
||||
|
||||
// UpdateStatus the component status
|
||||
func (m *ApplicationStatus) UpdateStatus(rsrcs []metav1.Object, err error) {
|
||||
var ready = true
|
||||
for _, r := range rsrcs {
|
||||
os := ObjectStatus{}
|
||||
os.update(r)
|
||||
switch r.(type) {
|
||||
case *appsv1.StatefulSet:
|
||||
os.Status = stsStatus(r.(*appsv1.StatefulSet))
|
||||
case *policyv1.PodDisruptionBudget:
|
||||
os.Status = pdbStatus(r.(*policyv1.PodDisruptionBudget))
|
||||
case *appsv1.Deployment:
|
||||
os.Status = deploymentStatus(r.(*appsv1.Deployment))
|
||||
case *appsv1.ReplicaSet:
|
||||
os.Status = replicasetStatus(r.(*appsv1.ReplicaSet))
|
||||
case *appsv1.DaemonSet:
|
||||
os.Status = daemonsetStatus(r.(*appsv1.DaemonSet))
|
||||
case *corev1.Pod:
|
||||
os.Status = podStatus(r.(*corev1.Pod))
|
||||
case *corev1.Service:
|
||||
os.Status = serviceStatus(r.(*corev1.Service))
|
||||
case *corev1.PersistentVolumeClaim:
|
||||
os.Status = pvcStatus(r.(*corev1.PersistentVolumeClaim))
|
||||
//case *corev1.ReplicationController:
|
||||
// Ingress
|
||||
default:
|
||||
os.Status = StatusReady
|
||||
}
|
||||
m.ComponentList.Objects = append(m.ComponentList.Objects, os)
|
||||
}
|
||||
for _, os := range m.ComponentList.Objects {
|
||||
if os.Status != StatusReady {
|
||||
ready = false
|
||||
}
|
||||
}
|
||||
|
||||
if ready {
|
||||
m.Ready("ComponentsReady", "all components ready")
|
||||
} else {
|
||||
m.NotReady("ComponentsNotReady", "some components not ready")
|
||||
}
|
||||
if err != nil {
|
||||
m.SetCondition(Error, "ErrorSeen", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// Resource specific logic -----------------------------------
|
||||
|
||||
// Statefulset
|
||||
func stsStatus(rsrc *appsv1.StatefulSet) string {
|
||||
if rsrc.Status.ReadyReplicas == *rsrc.Spec.Replicas && rsrc.Status.CurrentReplicas == *rsrc.Spec.Replicas {
|
||||
return StatusReady
|
||||
}
|
||||
return StatusInProgress
|
||||
}
|
||||
|
||||
// Deployment
|
||||
func deploymentStatus(rsrc *appsv1.Deployment) string {
|
||||
status := StatusInProgress
|
||||
progress := true
|
||||
available := true
|
||||
for _, c := range rsrc.Status.Conditions {
|
||||
switch c.Type {
|
||||
case appsv1.DeploymentProgressing:
|
||||
// https://github.com/kubernetes/kubernetes/blob/a3ccea9d8743f2ff82e41b6c2af6dc2c41dc7b10/pkg/controller/deployment/progress.go#L52
|
||||
if c.Status != corev1.ConditionTrue || c.Reason != "NewReplicaSetAvailable" {
|
||||
progress = false
|
||||
}
|
||||
case appsv1.DeploymentAvailable:
|
||||
if c.Status == corev1.ConditionFalse {
|
||||
available = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if progress && available {
|
||||
status = StatusReady
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
// Replicaset
|
||||
func replicasetStatus(rsrc *appsv1.ReplicaSet) string {
|
||||
status := StatusInProgress
|
||||
failure := false
|
||||
for _, c := range rsrc.Status.Conditions {
|
||||
switch c.Type {
|
||||
// https://github.com/kubernetes/kubernetes/blob/a3ccea9d8743f2ff82e41b6c2af6dc2c41dc7b10/pkg/controller/replicaset/replica_set_utils.go
|
||||
case appsv1.ReplicaSetReplicaFailure:
|
||||
if c.Status == corev1.ConditionTrue {
|
||||
failure = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !failure && rsrc.Status.ReadyReplicas == rsrc.Status.Replicas && rsrc.Status.Replicas == rsrc.Status.AvailableReplicas {
|
||||
status = StatusReady
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
// Daemonset
|
||||
func daemonsetStatus(rsrc *appsv1.DaemonSet) string {
|
||||
status := StatusInProgress
|
||||
if rsrc.Status.DesiredNumberScheduled == rsrc.Status.NumberAvailable && rsrc.Status.DesiredNumberScheduled == rsrc.Status.NumberReady {
|
||||
status = StatusReady
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
// PVC
|
||||
func pvcStatus(rsrc *corev1.PersistentVolumeClaim) string {
|
||||
status := StatusInProgress
|
||||
if rsrc.Status.Phase == corev1.ClaimBound {
|
||||
status = StatusReady
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
// Service
|
||||
func serviceStatus(rsrc *corev1.Service) string {
|
||||
status := StatusReady
|
||||
return status
|
||||
}
|
||||
|
||||
// Pod
|
||||
func podStatus(rsrc *corev1.Pod) string {
|
||||
status := StatusInProgress
|
||||
for i := range rsrc.Status.Conditions {
|
||||
if rsrc.Status.Conditions[i].Type == corev1.PodReady &&
|
||||
rsrc.Status.Conditions[i].Status == corev1.ConditionTrue {
|
||||
status = StatusReady
|
||||
break
|
||||
}
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
// PodDisruptionBudget
|
||||
func pdbStatus(rsrc *policyv1.PodDisruptionBudget) string {
|
||||
if rsrc.Status.CurrentHealthy >= rsrc.Status.DesiredHealthy {
|
||||
return StatusReady
|
||||
}
|
||||
return StatusInProgress
|
||||
}
|
||||
419
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/zz_generated.deepcopy.go
generated
vendored
419
vendor/github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1/zz_generated.deepcopy.go
generated
vendored
@@ -1,419 +0,0 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Application) DeepCopyInto(out *Application) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Application.
|
||||
func (in *Application) DeepCopy() *Application {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Application)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *Application) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ApplicationList) DeepCopyInto(out *ApplicationList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Application, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationList.
|
||||
func (in *ApplicationList) DeepCopy() *ApplicationList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ApplicationList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ApplicationList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ApplicationSpec) DeepCopyInto(out *ApplicationSpec) {
|
||||
*out = *in
|
||||
if in.ComponentGroupKinds != nil {
|
||||
in, out := &in.ComponentGroupKinds, &out.ComponentGroupKinds
|
||||
*out = make([]v1.GroupKind, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
in.Descriptor.DeepCopyInto(&out.Descriptor)
|
||||
if in.Selector != nil {
|
||||
in, out := &in.Selector, &out.Selector
|
||||
*out = new(v1.LabelSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Info != nil {
|
||||
in, out := &in.Info, &out.Info
|
||||
*out = make([]InfoItem, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSpec.
|
||||
func (in *ApplicationSpec) DeepCopy() *ApplicationSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ApplicationSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ApplicationStatus) DeepCopyInto(out *ApplicationStatus) {
|
||||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]Condition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
in.ComponentList.DeepCopyInto(&out.ComponentList)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationStatus.
|
||||
func (in *ApplicationStatus) DeepCopy() *ApplicationStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ApplicationStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ComponentList) DeepCopyInto(out *ComponentList) {
|
||||
*out = *in
|
||||
if in.Objects != nil {
|
||||
in, out := &in.Objects, &out.Objects
|
||||
*out = make([]ObjectStatus, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentList.
|
||||
func (in *ComponentList) DeepCopy() *ComponentList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ComponentList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Condition) DeepCopyInto(out *Condition) {
|
||||
*out = *in
|
||||
in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime)
|
||||
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition.
|
||||
func (in *Condition) DeepCopy() *Condition {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Condition)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ConfigMapKeySelector) DeepCopyInto(out *ConfigMapKeySelector) {
|
||||
*out = *in
|
||||
out.ObjectReference = in.ObjectReference
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapKeySelector.
|
||||
func (in *ConfigMapKeySelector) DeepCopy() *ConfigMapKeySelector {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ConfigMapKeySelector)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ContactData) DeepCopyInto(out *ContactData) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContactData.
|
||||
func (in *ContactData) DeepCopy() *ContactData {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ContactData)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Descriptor) DeepCopyInto(out *Descriptor) {
|
||||
*out = *in
|
||||
if in.Icons != nil {
|
||||
in, out := &in.Icons, &out.Icons
|
||||
*out = make([]ImageSpec, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Maintainers != nil {
|
||||
in, out := &in.Maintainers, &out.Maintainers
|
||||
*out = make([]ContactData, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Owners != nil {
|
||||
in, out := &in.Owners, &out.Owners
|
||||
*out = make([]ContactData, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Keywords != nil {
|
||||
in, out := &in.Keywords, &out.Keywords
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Links != nil {
|
||||
in, out := &in.Links, &out.Links
|
||||
*out = make([]Link, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Descriptor.
|
||||
func (in *Descriptor) DeepCopy() *Descriptor {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Descriptor)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ImageSpec) DeepCopyInto(out *ImageSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageSpec.
|
||||
func (in *ImageSpec) DeepCopy() *ImageSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ImageSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *InfoItem) DeepCopyInto(out *InfoItem) {
|
||||
*out = *in
|
||||
if in.ValueFrom != nil {
|
||||
in, out := &in.ValueFrom, &out.ValueFrom
|
||||
*out = new(InfoItemSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InfoItem.
|
||||
func (in *InfoItem) DeepCopy() *InfoItem {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(InfoItem)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *InfoItemSource) DeepCopyInto(out *InfoItemSource) {
|
||||
*out = *in
|
||||
if in.SecretKeyRef != nil {
|
||||
in, out := &in.SecretKeyRef, &out.SecretKeyRef
|
||||
*out = new(SecretKeySelector)
|
||||
**out = **in
|
||||
}
|
||||
if in.ConfigMapKeyRef != nil {
|
||||
in, out := &in.ConfigMapKeyRef, &out.ConfigMapKeyRef
|
||||
*out = new(ConfigMapKeySelector)
|
||||
**out = **in
|
||||
}
|
||||
if in.ServiceRef != nil {
|
||||
in, out := &in.ServiceRef, &out.ServiceRef
|
||||
*out = new(ServiceSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.IngressRef != nil {
|
||||
in, out := &in.IngressRef, &out.IngressRef
|
||||
*out = new(IngressSelector)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InfoItemSource.
|
||||
func (in *InfoItemSource) DeepCopy() *InfoItemSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(InfoItemSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IngressSelector) DeepCopyInto(out *IngressSelector) {
|
||||
*out = *in
|
||||
out.ObjectReference = in.ObjectReference
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressSelector.
|
||||
func (in *IngressSelector) DeepCopy() *IngressSelector {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IngressSelector)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Link) DeepCopyInto(out *Link) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Link.
|
||||
func (in *Link) DeepCopy() *Link {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Link)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ObjectStatus) DeepCopyInto(out *ObjectStatus) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectStatus.
|
||||
func (in *ObjectStatus) DeepCopy() *ObjectStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ObjectStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *SecretKeySelector) DeepCopyInto(out *SecretKeySelector) {
|
||||
*out = *in
|
||||
out.ObjectReference = in.ObjectReference
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretKeySelector.
|
||||
func (in *SecretKeySelector) DeepCopy() *SecretKeySelector {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SecretKeySelector)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ServiceSelector) DeepCopyInto(out *ServiceSelector) {
|
||||
*out = *in
|
||||
out.ObjectReference = in.ObjectReference
|
||||
if in.Port != nil {
|
||||
in, out := &in.Port, &out.Port
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSelector.
|
||||
func (in *ServiceSelector) DeepCopy() *ServiceSelector {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ServiceSelector)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package versioned
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
appv1beta1 "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/typed/app/v1beta1"
|
||||
discovery "k8s.io/client-go/discovery"
|
||||
rest "k8s.io/client-go/rest"
|
||||
flowcontrol "k8s.io/client-go/util/flowcontrol"
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
Discovery() discovery.DiscoveryInterface
|
||||
AppV1beta1() appv1beta1.AppV1beta1Interface
|
||||
}
|
||||
|
||||
// Clientset contains the clients for groups. Each group has exactly one
|
||||
// version included in a Clientset.
|
||||
type Clientset struct {
|
||||
*discovery.DiscoveryClient
|
||||
appV1beta1 *appv1beta1.AppV1beta1Client
|
||||
}
|
||||
|
||||
// AppV1beta1 retrieves the AppV1beta1Client
|
||||
func (c *Clientset) AppV1beta1() appv1beta1.AppV1beta1Interface {
|
||||
return c.appV1beta1
|
||||
}
|
||||
|
||||
// Discovery retrieves the DiscoveryClient
|
||||
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.DiscoveryClient
|
||||
}
|
||||
|
||||
// NewForConfig creates a new Clientset for the given config.
|
||||
// If config's RateLimiter is not set and QPS and Burst are acceptable,
|
||||
// NewForConfig will generate a rate-limiter in configShallowCopy.
|
||||
func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||
configShallowCopy := *c
|
||||
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
|
||||
if configShallowCopy.Burst <= 0 {
|
||||
return nil, fmt.Errorf("Burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
|
||||
}
|
||||
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
|
||||
}
|
||||
var cs Clientset
|
||||
var err error
|
||||
cs.appV1beta1, err = appv1beta1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &cs, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new Clientset for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||
var cs Clientset
|
||||
cs.appV1beta1 = appv1beta1.NewForConfigOrDie(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
|
||||
return &cs
|
||||
}
|
||||
|
||||
// New creates a new Clientset for the given RESTClient.
|
||||
func New(c rest.Interface) *Clientset {
|
||||
var cs Clientset
|
||||
cs.appV1beta1 = appv1beta1.New(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
|
||||
return &cs
|
||||
}
|
||||
20
vendor/github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/doc.go
generated
vendored
20
vendor/github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/doc.go
generated
vendored
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
// This package has the automatically generated clientset.
|
||||
package versioned
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
clientset "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned"
|
||||
appv1beta1 "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/typed/app/v1beta1"
|
||||
fakeappv1beta1 "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/typed/app/v1beta1/fake"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/discovery"
|
||||
fakediscovery "k8s.io/client-go/discovery/fake"
|
||||
"k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
// NewSimpleClientset returns a clientset that will respond with the provided objects.
|
||||
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
|
||||
// without applying any validations and/or defaults. It shouldn't be considered a replacement
|
||||
// for a real clientset and is mostly useful in simple unit tests.
|
||||
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
|
||||
for _, obj := range objects {
|
||||
if err := o.Add(obj); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
cs := &Clientset{tracker: o}
|
||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
gvr := action.GetResource()
|
||||
ns := action.GetNamespace()
|
||||
watch, err := o.Watch(gvr, ns)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
return true, watch, nil
|
||||
})
|
||||
|
||||
return cs
|
||||
}
|
||||
|
||||
// Clientset implements clientset.Interface. Meant to be embedded into a
|
||||
// struct to get a default implementation. This makes faking out just the method
|
||||
// you want to test easier.
|
||||
type Clientset struct {
|
||||
testing.Fake
|
||||
discovery *fakediscovery.FakeDiscovery
|
||||
tracker testing.ObjectTracker
|
||||
}
|
||||
|
||||
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||
return c.discovery
|
||||
}
|
||||
|
||||
func (c *Clientset) Tracker() testing.ObjectTracker {
|
||||
return c.tracker
|
||||
}
|
||||
|
||||
var _ clientset.Interface = &Clientset{}
|
||||
|
||||
// AppV1beta1 retrieves the AppV1beta1Client
|
||||
func (c *Clientset) AppV1beta1() appv1beta1.AppV1beta1Interface {
|
||||
return &fakeappv1beta1.FakeAppV1beta1{Fake: &c.Fake}
|
||||
}
|
||||
20
vendor/github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/fake/doc.go
generated
vendored
20
vendor/github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/fake/doc.go
generated
vendored
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
// This package has the automatically generated fake clientset.
|
||||
package fake
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
appv1beta1 "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
)
|
||||
|
||||
var scheme = runtime.NewScheme()
|
||||
var codecs = serializer.NewCodecFactory(scheme)
|
||||
var parameterCodec = runtime.NewParameterCodec(scheme)
|
||||
var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
appv1beta1.AddToScheme,
|
||||
}
|
||||
|
||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
||||
// of clientsets, like in:
|
||||
//
|
||||
// import (
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
||||
// )
|
||||
//
|
||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
||||
//
|
||||
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
|
||||
// correctly.
|
||||
var AddToScheme = localSchemeBuilder.AddToScheme
|
||||
|
||||
func init() {
|
||||
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
|
||||
utilruntime.Must(AddToScheme(scheme))
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
// This package contains the scheme of the automatically generated clientset.
|
||||
package scheme
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package scheme
|
||||
|
||||
import (
|
||||
appv1beta1 "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
)
|
||||
|
||||
var Scheme = runtime.NewScheme()
|
||||
var Codecs = serializer.NewCodecFactory(Scheme)
|
||||
var ParameterCodec = runtime.NewParameterCodec(Scheme)
|
||||
var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
appv1beta1.AddToScheme,
|
||||
}
|
||||
|
||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
||||
// of clientsets, like in:
|
||||
//
|
||||
// import (
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
||||
// )
|
||||
//
|
||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
||||
//
|
||||
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
|
||||
// correctly.
|
||||
var AddToScheme = localSchemeBuilder.AddToScheme
|
||||
|
||||
func init() {
|
||||
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
|
||||
utilruntime.Must(AddToScheme(Scheme))
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
v1beta1 "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
|
||||
"github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type AppV1beta1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
ApplicationsGetter
|
||||
}
|
||||
|
||||
// AppV1beta1Client is used to interact with features provided by the app.k8s.io group.
|
||||
type AppV1beta1Client struct {
|
||||
restClient rest.Interface
|
||||
}
|
||||
|
||||
func (c *AppV1beta1Client) Applications(namespace string) ApplicationInterface {
|
||||
return newApplications(c, namespace)
|
||||
}
|
||||
|
||||
// NewForConfig creates a new AppV1beta1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*AppV1beta1Client, error) {
|
||||
config := *c
|
||||
if err := setConfigDefaults(&config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, err := rest.RESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &AppV1beta1Client{client}, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new AppV1beta1Client for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *AppV1beta1Client {
|
||||
client, err := NewForConfig(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// New creates a new AppV1beta1Client for the given RESTClient.
|
||||
func New(c rest.Interface) *AppV1beta1Client {
|
||||
return &AppV1beta1Client{c}
|
||||
}
|
||||
|
||||
func setConfigDefaults(config *rest.Config) error {
|
||||
gv := v1beta1.SchemeGroupVersion
|
||||
config.GroupVersion = &gv
|
||||
config.APIPath = "/apis"
|
||||
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
|
||||
|
||||
if config.UserAgent == "" {
|
||||
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *AppV1beta1Client) RESTClient() rest.Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.restClient
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
v1beta1 "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
|
||||
scheme "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/scheme"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
// ApplicationsGetter has a method to return a ApplicationInterface.
|
||||
// A group's client should implement this interface.
|
||||
type ApplicationsGetter interface {
|
||||
Applications(namespace string) ApplicationInterface
|
||||
}
|
||||
|
||||
// ApplicationInterface has methods to work with Application resources.
|
||||
type ApplicationInterface interface {
|
||||
Create(*v1beta1.Application) (*v1beta1.Application, error)
|
||||
Update(*v1beta1.Application) (*v1beta1.Application, error)
|
||||
UpdateStatus(*v1beta1.Application) (*v1beta1.Application, error)
|
||||
Delete(name string, options *v1.DeleteOptions) error
|
||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
||||
Get(name string, options v1.GetOptions) (*v1beta1.Application, error)
|
||||
List(opts v1.ListOptions) (*v1beta1.ApplicationList, error)
|
||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Application, err error)
|
||||
ApplicationExpansion
|
||||
}
|
||||
|
||||
// applications implements ApplicationInterface
|
||||
type applications struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
}
|
||||
|
||||
// newApplications returns a Applications
|
||||
func newApplications(c *AppV1beta1Client, namespace string) *applications {
|
||||
return &applications{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the application, and returns the corresponding application object, and an error if there is any.
|
||||
func (c *applications) Get(name string, options v1.GetOptions) (result *v1beta1.Application, err error) {
|
||||
result = &v1beta1.Application{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("applications").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of Applications that match those selectors.
|
||||
func (c *applications) List(opts v1.ListOptions) (result *v1beta1.ApplicationList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1beta1.ApplicationList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("applications").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested applications.
|
||||
func (c *applications) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("applications").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Create takes the representation of a application and creates it. Returns the server's representation of the application, and an error, if there is any.
|
||||
func (c *applications) Create(application *v1beta1.Application) (result *v1beta1.Application, err error) {
|
||||
result = &v1beta1.Application{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("applications").
|
||||
Body(application).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a application and updates it. Returns the server's representation of the application, and an error, if there is any.
|
||||
func (c *applications) Update(application *v1beta1.Application) (result *v1beta1.Application, err error) {
|
||||
result = &v1beta1.Application{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("applications").
|
||||
Name(application.Name).
|
||||
Body(application).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
|
||||
func (c *applications) UpdateStatus(application *v1beta1.Application) (result *v1beta1.Application, err error) {
|
||||
result = &v1beta1.Application{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("applications").
|
||||
Name(application.Name).
|
||||
SubResource("status").
|
||||
Body(application).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the application and deletes it. Returns an error if one occurs.
|
||||
func (c *applications) Delete(name string, options *v1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("applications").
|
||||
Name(name).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *applications) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOptions.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("applications").
|
||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched application.
|
||||
func (c *applications) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Application, err error) {
|
||||
result = &v1beta1.Application{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("applications").
|
||||
SubResource(subresources...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
// This package has the automatically generated typed clients.
|
||||
package v1beta1
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
// Package fake has the automatically generated clients.
|
||||
package fake
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
v1beta1 "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/typed/app/v1beta1"
|
||||
rest "k8s.io/client-go/rest"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
type FakeAppV1beta1 struct {
|
||||
*testing.Fake
|
||||
}
|
||||
|
||||
func (c *FakeAppV1beta1) Applications(namespace string) v1beta1.ApplicationInterface {
|
||||
return &FakeApplications{c, namespace}
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakeAppV1beta1) RESTClient() rest.Interface {
|
||||
var ret *rest.RESTClient
|
||||
return ret
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
v1beta1 "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
labels "k8s.io/apimachinery/pkg/labels"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
// FakeApplications implements ApplicationInterface
|
||||
type FakeApplications struct {
|
||||
Fake *FakeAppV1beta1
|
||||
ns string
|
||||
}
|
||||
|
||||
var applicationsResource = schema.GroupVersionResource{Group: "app.k8s.io", Version: "v1beta1", Resource: "applications"}
|
||||
|
||||
var applicationsKind = schema.GroupVersionKind{Group: "app.k8s.io", Version: "v1beta1", Kind: "Application"}
|
||||
|
||||
// Get takes name of the application, and returns the corresponding application object, and an error if there is any.
|
||||
func (c *FakeApplications) Get(name string, options v1.GetOptions) (result *v1beta1.Application, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(applicationsResource, c.ns, name), &v1beta1.Application{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Application), err
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of Applications that match those selectors.
|
||||
func (c *FakeApplications) List(opts v1.ListOptions) (result *v1beta1.ApplicationList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(applicationsResource, applicationsKind, c.ns, opts), &v1beta1.ApplicationList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1beta1.ApplicationList{ListMeta: obj.(*v1beta1.ApplicationList).ListMeta}
|
||||
for _, item := range obj.(*v1beta1.ApplicationList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested applications.
|
||||
func (c *FakeApplications) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(applicationsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Create takes the representation of a application and creates it. Returns the server's representation of the application, and an error, if there is any.
|
||||
func (c *FakeApplications) Create(application *v1beta1.Application) (result *v1beta1.Application, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(applicationsResource, c.ns, application), &v1beta1.Application{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Application), err
|
||||
}
|
||||
|
||||
// Update takes the representation of a application and updates it. Returns the server's representation of the application, and an error, if there is any.
|
||||
func (c *FakeApplications) Update(application *v1beta1.Application) (result *v1beta1.Application, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(applicationsResource, c.ns, application), &v1beta1.Application{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Application), err
|
||||
}
|
||||
|
||||
// UpdateStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
func (c *FakeApplications) UpdateStatus(application *v1beta1.Application) (*v1beta1.Application, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateSubresourceAction(applicationsResource, "status", c.ns, application), &v1beta1.Application{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Application), err
|
||||
}
|
||||
|
||||
// Delete takes name of the application and deletes it. Returns an error if one occurs.
|
||||
func (c *FakeApplications) Delete(name string, options *v1.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(applicationsResource, c.ns, name), &v1beta1.Application{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *FakeApplications) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(applicationsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1beta1.ApplicationList{})
|
||||
return err
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched application.
|
||||
func (c *FakeApplications) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Application, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(applicationsResource, c.ns, name, pt, data, subresources...), &v1beta1.Application{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Application), err
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
type ApplicationExpansion interface{}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
v1beta1 "github.com/kubernetes-sigs/application/pkg/client/informers/externalversions/app/v1beta1"
|
||||
internalinterfaces "github.com/kubernetes-sigs/application/pkg/client/informers/externalversions/internalinterfaces"
|
||||
)
|
||||
|
||||
// Interface provides access to each of this group's versions.
|
||||
type Interface interface {
|
||||
// V1beta1 provides access to shared informers for resources in V1beta1.
|
||||
V1beta1() v1beta1.Interface
|
||||
}
|
||||
|
||||
type group struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
namespace string
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
}
|
||||
|
||||
// New returns a new Interface.
|
||||
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
|
||||
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
|
||||
}
|
||||
|
||||
// V1beta1 returns a new v1beta1.Interface.
|
||||
func (g *group) V1beta1() v1beta1.Interface {
|
||||
return v1beta1.New(g.factory, g.namespace, g.tweakListOptions)
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
appv1beta1 "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
|
||||
versioned "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned"
|
||||
internalinterfaces "github.com/kubernetes-sigs/application/pkg/client/informers/externalversions/internalinterfaces"
|
||||
v1beta1 "github.com/kubernetes-sigs/application/pkg/client/listers/app/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// ApplicationInformer provides access to a shared informer and lister for
|
||||
// Applications.
|
||||
type ApplicationInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1beta1.ApplicationLister
|
||||
}
|
||||
|
||||
type applicationInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewApplicationInformer constructs a new informer for Application type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewApplicationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredApplicationInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredApplicationInformer constructs a new informer for Application type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewFilteredApplicationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
||||
return cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.AppV1beta1().Applications(namespace).List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.AppV1beta1().Applications(namespace).Watch(options)
|
||||
},
|
||||
},
|
||||
&appv1beta1.Application{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *applicationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredApplicationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *applicationInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&appv1beta1.Application{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *applicationInformer) Lister() v1beta1.ApplicationLister {
|
||||
return v1beta1.NewApplicationLister(f.Informer().GetIndexer())
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
internalinterfaces "github.com/kubernetes-sigs/application/pkg/client/informers/externalversions/internalinterfaces"
|
||||
)
|
||||
|
||||
// Interface provides access to all the informers in this group version.
|
||||
type Interface interface {
|
||||
// Applications returns a ApplicationInformer.
|
||||
Applications() ApplicationInformer
|
||||
}
|
||||
|
||||
type version struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
namespace string
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
}
|
||||
|
||||
// New returns a new Interface.
|
||||
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
|
||||
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
|
||||
}
|
||||
|
||||
// Applications returns a ApplicationInformer.
|
||||
func (v *version) Applications() ApplicationInformer {
|
||||
return &applicationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package externalversions
|
||||
|
||||
import (
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
time "time"
|
||||
|
||||
versioned "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned"
|
||||
app "github.com/kubernetes-sigs/application/pkg/client/informers/externalversions/app"
|
||||
internalinterfaces "github.com/kubernetes-sigs/application/pkg/client/informers/externalversions/internalinterfaces"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// SharedInformerOption defines the functional option type for SharedInformerFactory.
|
||||
type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory
|
||||
|
||||
type sharedInformerFactory struct {
|
||||
client versioned.Interface
|
||||
namespace string
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
lock sync.Mutex
|
||||
defaultResync time.Duration
|
||||
customResync map[reflect.Type]time.Duration
|
||||
|
||||
informers map[reflect.Type]cache.SharedIndexInformer
|
||||
// startedInformers is used for tracking which informers have been started.
|
||||
// This allows Start() to be called multiple times safely.
|
||||
startedInformers map[reflect.Type]bool
|
||||
}
|
||||
|
||||
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
|
||||
func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption {
|
||||
return func(factory *sharedInformerFactory) *sharedInformerFactory {
|
||||
for k, v := range resyncConfig {
|
||||
factory.customResync[reflect.TypeOf(k)] = v
|
||||
}
|
||||
return factory
|
||||
}
|
||||
}
|
||||
|
||||
// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory.
|
||||
func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption {
|
||||
return func(factory *sharedInformerFactory) *sharedInformerFactory {
|
||||
factory.tweakListOptions = tweakListOptions
|
||||
return factory
|
||||
}
|
||||
}
|
||||
|
||||
// WithNamespace limits the SharedInformerFactory to the specified namespace.
|
||||
func WithNamespace(namespace string) SharedInformerOption {
|
||||
return func(factory *sharedInformerFactory) *sharedInformerFactory {
|
||||
factory.namespace = namespace
|
||||
return factory
|
||||
}
|
||||
}
|
||||
|
||||
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
|
||||
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
|
||||
return NewSharedInformerFactoryWithOptions(client, defaultResync)
|
||||
}
|
||||
|
||||
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
|
||||
// Listers obtained via this SharedInformerFactory will be subject to the same filters
|
||||
// as specified here.
|
||||
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
|
||||
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
|
||||
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
|
||||
}
|
||||
|
||||
// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options.
|
||||
func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory {
|
||||
factory := &sharedInformerFactory{
|
||||
client: client,
|
||||
namespace: v1.NamespaceAll,
|
||||
defaultResync: defaultResync,
|
||||
informers: make(map[reflect.Type]cache.SharedIndexInformer),
|
||||
startedInformers: make(map[reflect.Type]bool),
|
||||
customResync: make(map[reflect.Type]time.Duration),
|
||||
}
|
||||
|
||||
// Apply all options
|
||||
for _, opt := range options {
|
||||
factory = opt(factory)
|
||||
}
|
||||
|
||||
return factory
|
||||
}
|
||||
|
||||
// Start initializes all requested informers.
|
||||
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
for informerType, informer := range f.informers {
|
||||
if !f.startedInformers[informerType] {
|
||||
go informer.Run(stopCh)
|
||||
f.startedInformers[informerType] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WaitForCacheSync waits for all started informers' cache were synced.
|
||||
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
|
||||
informers := func() map[reflect.Type]cache.SharedIndexInformer {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
informers := map[reflect.Type]cache.SharedIndexInformer{}
|
||||
for informerType, informer := range f.informers {
|
||||
if f.startedInformers[informerType] {
|
||||
informers[informerType] = informer
|
||||
}
|
||||
}
|
||||
return informers
|
||||
}()
|
||||
|
||||
res := map[reflect.Type]bool{}
|
||||
for informType, informer := range informers {
|
||||
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
|
||||
// client.
|
||||
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
informerType := reflect.TypeOf(obj)
|
||||
informer, exists := f.informers[informerType]
|
||||
if exists {
|
||||
return informer
|
||||
}
|
||||
|
||||
resyncPeriod, exists := f.customResync[informerType]
|
||||
if !exists {
|
||||
resyncPeriod = f.defaultResync
|
||||
}
|
||||
|
||||
informer = newFunc(f.client, resyncPeriod)
|
||||
f.informers[informerType] = informer
|
||||
|
||||
return informer
|
||||
}
|
||||
|
||||
// SharedInformerFactory provides shared informers for resources in all known
|
||||
// API group versions.
|
||||
type SharedInformerFactory interface {
|
||||
internalinterfaces.SharedInformerFactory
|
||||
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
|
||||
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
|
||||
|
||||
App() app.Interface
|
||||
}
|
||||
|
||||
func (f *sharedInformerFactory) App() app.Interface {
|
||||
return app.New(f, f.namespace, f.tweakListOptions)
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package externalversions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
v1beta1 "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
|
||||
// sharedInformers based on type
|
||||
type GenericInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() cache.GenericLister
|
||||
}
|
||||
|
||||
type genericInformer struct {
|
||||
informer cache.SharedIndexInformer
|
||||
resource schema.GroupResource
|
||||
}
|
||||
|
||||
// Informer returns the SharedIndexInformer.
|
||||
func (f *genericInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.informer
|
||||
}
|
||||
|
||||
// Lister returns the GenericLister.
|
||||
func (f *genericInformer) Lister() cache.GenericLister {
|
||||
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
|
||||
}
|
||||
|
||||
// ForResource gives generic access to a shared informer of the matching type
|
||||
// TODO extend this to unknown resources with a client pool
|
||||
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
|
||||
switch resource {
|
||||
// Group=app.k8s.io, Version=v1beta1
|
||||
case v1beta1.SchemeGroupVersion.WithResource("applications"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.App().V1beta1().Applications().Informer()}, nil
|
||||
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("no informer found for %v", resource)
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package internalinterfaces
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
versioned "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
|
||||
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
|
||||
|
||||
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
|
||||
type SharedInformerFactory interface {
|
||||
Start(stopCh <-chan struct{})
|
||||
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
|
||||
}
|
||||
|
||||
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
|
||||
type TweakListOptionsFunc func(*v1.ListOptions)
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
v1beta1 "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// ApplicationLister helps list Applications.
|
||||
type ApplicationLister interface {
|
||||
// List lists all Applications in the indexer.
|
||||
List(selector labels.Selector) (ret []*v1beta1.Application, err error)
|
||||
// Applications returns an object that can list and get Applications.
|
||||
Applications(namespace string) ApplicationNamespaceLister
|
||||
ApplicationListerExpansion
|
||||
}
|
||||
|
||||
// applicationLister implements the ApplicationLister interface.
|
||||
type applicationLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewApplicationLister returns a new ApplicationLister.
|
||||
func NewApplicationLister(indexer cache.Indexer) ApplicationLister {
|
||||
return &applicationLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all Applications in the indexer.
|
||||
func (s *applicationLister) List(selector labels.Selector) (ret []*v1beta1.Application, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1beta1.Application))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Applications returns an object that can list and get Applications.
|
||||
func (s *applicationLister) Applications(namespace string) ApplicationNamespaceLister {
|
||||
return applicationNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
}
|
||||
|
||||
// ApplicationNamespaceLister helps list and get Applications.
|
||||
type ApplicationNamespaceLister interface {
|
||||
// List lists all Applications in the indexer for a given namespace.
|
||||
List(selector labels.Selector) (ret []*v1beta1.Application, err error)
|
||||
// Get retrieves the Application from the indexer for a given namespace and name.
|
||||
Get(name string) (*v1beta1.Application, error)
|
||||
ApplicationNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// applicationNamespaceLister implements the ApplicationNamespaceLister
|
||||
// interface.
|
||||
type applicationNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all Applications in the indexer for a given namespace.
|
||||
func (s applicationNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Application, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1beta1.Application))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the Application from the indexer for a given namespace and name.
|
||||
func (s applicationNamespaceLister) Get(name string) (*v1beta1.Application, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1beta1.Resource("application"), name)
|
||||
}
|
||||
return obj.(*v1beta1.Application), nil
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
// ApplicationListerExpansion allows custom methods to be added to
|
||||
// ApplicationLister.
|
||||
type ApplicationListerExpansion interface{}
|
||||
|
||||
// ApplicationNamespaceListerExpansion allows custom methods to be added to
|
||||
// ApplicationNamespaceLister.
|
||||
type ApplicationNamespaceListerExpansion interface{}
|
||||
52
vendor/github.com/kubernetes-sigs/application/pkg/component/component.go
generated
vendored
52
vendor/github.com/kubernetes-sigs/application/pkg/component/component.go
generated
vendored
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package component
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Constants defining labels
|
||||
const (
|
||||
LabelCR = "custom-resource"
|
||||
LabelCRName = "custom-resource-name"
|
||||
LabelCRNamespace = "custom-resource-namespace"
|
||||
LabelComponent = "component"
|
||||
)
|
||||
|
||||
// Labels return
|
||||
func Labels(cr metav1.Object, component string) map[string]string {
|
||||
return map[string]string{
|
||||
LabelCR: strings.Trim(reflect.TypeOf(cr).String(), "*"),
|
||||
LabelCRName: cr.GetName(),
|
||||
LabelCRNamespace: cr.GetNamespace(),
|
||||
LabelComponent: component,
|
||||
}
|
||||
}
|
||||
|
||||
// Labels return the common labels for a resource
|
||||
func (c *Component) Labels() map[string]string {
|
||||
return Labels(c.CR, c.Name)
|
||||
}
|
||||
|
||||
// Merge is used to merge multiple maps into the target map
|
||||
func (out KVMap) Merge(kvmaps ...KVMap) {
|
||||
for _, kvmap := range kvmaps {
|
||||
for k, v := range kvmap {
|
||||
out[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
18
vendor/github.com/kubernetes-sigs/application/pkg/component/doc.go
generated
vendored
18
vendor/github.com/kubernetes-sigs/application/pkg/component/doc.go
generated
vendored
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Package component contains component definition
|
||||
package component
|
||||
31
vendor/github.com/kubernetes-sigs/application/pkg/component/interface.go
generated
vendored
31
vendor/github.com/kubernetes-sigs/application/pkg/component/interface.go
generated
vendored
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package component
|
||||
|
||||
import (
|
||||
"github.com/kubernetes-sigs/application/pkg/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// Handle is an interface for operating on logical Components of a CR
|
||||
type Handle interface {
|
||||
DependentResources(rsrc interface{}) *resource.ObjectBag
|
||||
ExpectedResources(rsrc interface{}, labels map[string]string, dependent, aggregated *resource.ObjectBag) (*resource.ObjectBag, error)
|
||||
Observables(scheme *runtime.Scheme, rsrc interface{}, labels map[string]string, expected *resource.ObjectBag) []resource.Observable
|
||||
Mutate(rsrc interface{}, rsrclabels map[string]string, status interface{}, expected, dependent, observed *resource.ObjectBag) (*resource.ObjectBag, error)
|
||||
Differs(expected metav1.Object, observed metav1.Object) bool
|
||||
UpdateComponentStatus(rsrc, status interface{}, reconciled *resource.ObjectBag, err error)
|
||||
Finalize(rsrc, status interface{}, observed *resource.ObjectBag) error
|
||||
}
|
||||
35
vendor/github.com/kubernetes-sigs/application/pkg/component/types.go
generated
vendored
35
vendor/github.com/kubernetes-sigs/application/pkg/component/types.go
generated
vendored
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package component
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// Common const definitions
|
||||
const (
|
||||
LifecycleManaged = "managed"
|
||||
LifecycleReferred = "referred"
|
||||
)
|
||||
|
||||
// Component represents a logical collection of resources
|
||||
type Component struct {
|
||||
Handle
|
||||
Name string
|
||||
CR metav1.Object
|
||||
OwnerRef *metav1.OwnerReference
|
||||
}
|
||||
|
||||
// KVMap is a map[string]string
|
||||
type KVMap map[string]string
|
||||
31
vendor/github.com/kubernetes-sigs/application/pkg/customresource/customresource.go
generated
vendored
31
vendor/github.com/kubernetes-sigs/application/pkg/customresource/customresource.go
generated
vendored
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package customresource
|
||||
|
||||
import (
|
||||
component "github.com/kubernetes-sigs/application/pkg/component"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Labels return custom resource label
|
||||
func (hv *HandleValue) Labels() map[string]string {
|
||||
c := hv.Handle.(metav1.Object)
|
||||
return map[string]string{
|
||||
component.LabelCR: strings.Trim(reflect.TypeOf(c).String(), "*"),
|
||||
component.LabelCRName: c.GetName(),
|
||||
component.LabelCRNamespace: c.GetNamespace(),
|
||||
}
|
||||
}
|
||||
18
vendor/github.com/kubernetes-sigs/application/pkg/customresource/doc.go
generated
vendored
18
vendor/github.com/kubernetes-sigs/application/pkg/customresource/doc.go
generated
vendored
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Package customresource contains component definition
|
||||
package customresource
|
||||
28
vendor/github.com/kubernetes-sigs/application/pkg/customresource/interface.go
generated
vendored
28
vendor/github.com/kubernetes-sigs/application/pkg/customresource/interface.go
generated
vendored
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package customresource
|
||||
|
||||
import (
|
||||
"github.com/kubernetes-sigs/application/pkg/component"
|
||||
)
|
||||
|
||||
// Handle is an interface for operating on CRs
|
||||
type Handle interface {
|
||||
ApplyDefaults()
|
||||
Validate() error
|
||||
Components() []component.Component
|
||||
UpdateRsrcStatus(interface{}, error) bool
|
||||
NewRsrc() Handle
|
||||
NewStatus() interface{}
|
||||
}
|
||||
19
vendor/github.com/kubernetes-sigs/application/pkg/customresource/type.go
generated
vendored
19
vendor/github.com/kubernetes-sigs/application/pkg/customresource/type.go
generated
vendored
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package customresource
|
||||
|
||||
// HandleValue is to add methods for an interface object
|
||||
type HandleValue struct {
|
||||
Handle
|
||||
}
|
||||
19
vendor/github.com/kubernetes-sigs/application/pkg/finalizer/doc.go
generated
vendored
19
vendor/github.com/kubernetes-sigs/application/pkg/finalizer/doc.go
generated
vendored
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Package finalizer contains storage releated code
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
package finalizer
|
||||
61
vendor/github.com/kubernetes-sigs/application/pkg/finalizer/finalizer.go
generated
vendored
61
vendor/github.com/kubernetes-sigs/application/pkg/finalizer/finalizer.go
generated
vendored
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package finalizer
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// const fileds
|
||||
const (
|
||||
Cleanup = "cleanup"
|
||||
)
|
||||
|
||||
// Add adds the finalizer string
|
||||
func Add(o metav1.Object, new string) {
|
||||
exists := false
|
||||
existing := o.GetFinalizers()
|
||||
for _, f := range existing {
|
||||
if f == new {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !exists {
|
||||
existing = append(existing, new)
|
||||
o.SetFinalizers(existing)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove removes the finalizer string
|
||||
func Remove(o metav1.Object, new string) {
|
||||
foundat := -1
|
||||
existing := o.GetFinalizers()
|
||||
for i, f := range existing {
|
||||
if f == new {
|
||||
foundat = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if foundat != -1 {
|
||||
existing[foundat] = existing[len(existing)-1]
|
||||
o.SetFinalizers(existing[:len(existing)-1])
|
||||
}
|
||||
}
|
||||
|
||||
// EnsureStandard adds standard finalizers
|
||||
func EnsureStandard(o metav1.Object) {
|
||||
Add(o, Cleanup)
|
||||
}
|
||||
20
vendor/github.com/kubernetes-sigs/application/pkg/finalizer/zz_generated.deepcopy.go
generated
vendored
20
vendor/github.com/kubernetes-sigs/application/pkg/finalizer/zz_generated.deepcopy.go
generated
vendored
@@ -1,20 +0,0 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package finalizer
|
||||
18
vendor/github.com/kubernetes-sigs/application/pkg/resource/doc.go
generated
vendored
18
vendor/github.com/kubernetes-sigs/application/pkg/resource/doc.go
generated
vendored
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Package resource contains resource methods
|
||||
package resource
|
||||
183
vendor/github.com/kubernetes-sigs/application/pkg/resource/resource.go
generated
vendored
183
vendor/github.com/kubernetes-sigs/application/pkg/resource/resource.go
generated
vendored
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package resource
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/apimachinery/pkg/util/yaml"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// objFromReader reads Object from []byte spec
|
||||
func objFromReader(b *bufio.Reader, data interface{}, list metav1.ListInterface) (*Object, error) {
|
||||
var exdoc bytes.Buffer
|
||||
r := yaml.NewYAMLReader(b)
|
||||
doc, err := r.Read()
|
||||
if err == nil {
|
||||
tmpl, e := template.New("tmpl").Parse(string(doc))
|
||||
err = e
|
||||
if err == nil {
|
||||
err = tmpl.Execute(&exdoc, data)
|
||||
if err == nil {
|
||||
d := scheme.Codecs.UniversalDeserializer()
|
||||
obj, _, e := d.Decode(exdoc.Bytes(), nil, nil)
|
||||
err = e
|
||||
if err == nil {
|
||||
return &Object{
|
||||
Obj: obj.DeepCopyObject().(metav1.Object),
|
||||
ObjList: list,
|
||||
Lifecycle: LifecycleManaged,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// ObjFromString populates Object from string spec
|
||||
func ObjFromString(spec string, values interface{}, list metav1.ListInterface) (*Object, error) {
|
||||
return objFromReader(bufio.NewReader(strings.NewReader(spec)), values, list)
|
||||
}
|
||||
|
||||
// ObjFromFile populates Object from file
|
||||
func ObjFromFile(path string, values interface{}, list metav1.ListInterface) (*Object, error) {
|
||||
f, err := os.Open(path)
|
||||
if err == nil {
|
||||
return objFromReader(bufio.NewReader(f), values, list)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// ObservablesFromObjects returns ObservablesFromObjects
|
||||
func ObservablesFromObjects(scheme *runtime.Scheme, bag *ObjectBag, labels map[string]string) []Observable {
|
||||
var gk schema.GroupKind
|
||||
var observables []Observable
|
||||
gkmap := map[schema.GroupKind]struct{}{}
|
||||
for _, obj := range bag.Items() {
|
||||
if obj.ObjList != nil {
|
||||
ro := obj.Obj.(runtime.Object)
|
||||
kinds, _, err := scheme.ObjectKinds(ro)
|
||||
if err == nil {
|
||||
// Expect only 1 kind. If there is more than one kind this is probably an edge case such as ListOptions.
|
||||
if len(kinds) != 1 {
|
||||
err = fmt.Errorf("Expected exactly 1 kind for Object %T, but found %s kinds", ro, kinds)
|
||||
|
||||
}
|
||||
}
|
||||
// Cache the Group and Kind for the OwnerType
|
||||
if err == nil {
|
||||
gk = schema.GroupKind{Group: kinds[0].Group, Kind: kinds[0].Kind}
|
||||
} else {
|
||||
gk = ro.GetObjectKind().GroupVersionKind().GroupKind()
|
||||
}
|
||||
if _, ok := gkmap[gk]; !ok {
|
||||
gkmap[gk] = struct{}{}
|
||||
observable := Observable{
|
||||
ObjList: obj.ObjList,
|
||||
Labels: labels,
|
||||
}
|
||||
observables = append(observables, observable)
|
||||
}
|
||||
} else {
|
||||
observable := Observable{
|
||||
Obj: obj.Obj,
|
||||
}
|
||||
observables = append(observables, observable)
|
||||
}
|
||||
}
|
||||
return observables
|
||||
}
|
||||
|
||||
// ReferredObject returns a reffered object
|
||||
func ReferredObject(obj metav1.Object, name, namespace string) Object {
|
||||
obj.SetName(name)
|
||||
obj.SetNamespace(namespace)
|
||||
return Object{
|
||||
Lifecycle: LifecycleReferred,
|
||||
Obj: obj,
|
||||
}
|
||||
}
|
||||
|
||||
// Add adds to the Object bag
|
||||
func (b *ObjectBag) Add(objs ...Object) {
|
||||
b.objects = append(b.objects, objs...)
|
||||
}
|
||||
|
||||
// Items get items from the Object bag
|
||||
func (b *ObjectBag) Items() []Object {
|
||||
return b.objects
|
||||
}
|
||||
|
||||
// Objs get items from the Object bag
|
||||
func (b *ObjectBag) Objs() []metav1.Object {
|
||||
var objs []metav1.Object
|
||||
for _, o := range b.Items() {
|
||||
objs = append(objs, o.Obj)
|
||||
}
|
||||
return objs
|
||||
}
|
||||
|
||||
// Get returns an item which matched the kind and name
|
||||
func (b *ObjectBag) Get(inobj metav1.Object, name, namespace string) metav1.Object {
|
||||
inobj.SetName(name)
|
||||
inobj.SetNamespace(namespace)
|
||||
for _, obj := range b.Items() {
|
||||
otype := reflect.TypeOf(obj.Obj).String()
|
||||
intype := reflect.TypeOf(inobj).String()
|
||||
if otype == intype && obj.Obj.GetName() == inobj.GetName() && obj.Obj.GetNamespace() == inobj.GetNamespace() {
|
||||
return obj.Obj
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete returns an item which matched the kind and name
|
||||
func (b *ObjectBag) Delete(inobj metav1.Object) {
|
||||
for i, obj := range b.objects {
|
||||
otype := reflect.TypeOf(obj.Obj).String()
|
||||
intype := reflect.TypeOf(inobj).String()
|
||||
if otype == intype && obj.Obj.GetName() == inobj.GetName() && obj.Obj.GetNamespace() == inobj.GetNamespace() {
|
||||
b.objects[i] = b.objects[len(b.objects)-1]
|
||||
b.objects = b.objects[:len(b.objects)-1]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate validates the LocalObjectReference
|
||||
func (s *LocalObjectReference) Validate(fp *field.Path, sfield string, errs field.ErrorList, required bool) field.ErrorList {
|
||||
fp = fp.Child(sfield)
|
||||
if s == nil {
|
||||
if required {
|
||||
errs = append(errs, field.Required(fp, "Required "+sfield+" missing"))
|
||||
}
|
||||
return errs
|
||||
}
|
||||
|
||||
if s.Name == "" {
|
||||
errs = append(errs, field.Required(fp.Child("name"), "name is required"))
|
||||
}
|
||||
return errs
|
||||
}
|
||||
63
vendor/github.com/kubernetes-sigs/application/pkg/resource/types.go
generated
vendored
63
vendor/github.com/kubernetes-sigs/application/pkg/resource/types.go
generated
vendored
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
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.
|
||||
*/
|
||||
|
||||
package resource
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// Common const definitions
|
||||
const (
|
||||
LifecycleManaged = "managed"
|
||||
LifecycleReferred = "referred"
|
||||
)
|
||||
|
||||
// ObjectBag abstracts dealing with group of objects
|
||||
// For now it is a simple list
|
||||
type ObjectBag struct {
|
||||
objects []Object
|
||||
}
|
||||
|
||||
// Object is a container to capture the k8s resource info to be used by controller
|
||||
type Object struct {
|
||||
// Lifecycle can be: managed, reference
|
||||
Lifecycle string
|
||||
// Obj refers to the resource object can be: sts, service, secret, pvc, ..
|
||||
Obj metav1.Object
|
||||
// ObjList refers to the list of resource objects
|
||||
ObjList metav1.ListInterface
|
||||
}
|
||||
|
||||
// Observable captures the k8s resource info and selector to fetch child resources
|
||||
type Observable struct {
|
||||
// ObjList refers to the list of resource objects
|
||||
ObjList metav1.ListInterface
|
||||
// Obj refers to the resource object can be: sts, service, secret, pvc, ..
|
||||
Obj metav1.Object
|
||||
// Labels list of labels
|
||||
Labels map[string]string
|
||||
// Typemeta - needed for go test fake client
|
||||
Type metav1.TypeMeta
|
||||
// Namespace - only observe resources in this namespace
|
||||
Namespace string
|
||||
}
|
||||
|
||||
// LocalObjectReference with validation
|
||||
type LocalObjectReference struct {
|
||||
corev1.LocalObjectReference `json:",inline"`
|
||||
}
|
||||
|
||||
// GetObjectFn is a type for any function that returns resource info
|
||||
type GetObjectFn func(interface{}) (*Object, error)
|
||||
Reference in New Issue
Block a user