mirror of
https://github.com/ysoftdevs/gardener-extension-shoot-fleet-agent.git
synced 2026-04-22 16:28:53 +02:00
Initial v1.0.0 commit
This commit is contained in:
178
vendor/github.com/rancher/fleet/pkg/apis/LICENSE
generated
vendored
Normal file
178
vendor/github.com/rancher/fleet/pkg/apis/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
|
||||
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
|
||||
|
||||
265
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/bundle.go
generated
vendored
Normal file
265
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/bundle.go
generated
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/wrangler/pkg/genericcondition"
|
||||
"github.com/rancher/wrangler/pkg/summary"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
var (
|
||||
Ready BundleState = "Ready"
|
||||
NotReady BundleState = "NotReady"
|
||||
WaitApplied BundleState = "WaitApplied"
|
||||
ErrApplied BundleState = "ErrApplied"
|
||||
OutOfSync BundleState = "OutOfSync"
|
||||
Pending BundleState = "Pending"
|
||||
Modified BundleState = "Modified"
|
||||
|
||||
StateRank = map[BundleState]int{
|
||||
ErrApplied: 7,
|
||||
WaitApplied: 6,
|
||||
Modified: 5,
|
||||
OutOfSync: 4,
|
||||
Pending: 3,
|
||||
NotReady: 2,
|
||||
Ready: 1,
|
||||
}
|
||||
)
|
||||
|
||||
type BundleState string
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type Bundle struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec BundleSpec `json:"spec"`
|
||||
Status BundleStatus `json:"status"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type BundleNamespaceMapping struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
BundleSelector *metav1.LabelSelector `json:"bundleSelector,omitempty"`
|
||||
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`
|
||||
}
|
||||
|
||||
type BundleSpec struct {
|
||||
BundleDeploymentOptions
|
||||
|
||||
Paused bool `json:"paused,omitempty"`
|
||||
RolloutStrategy *RolloutStrategy `json:"rolloutStrategy,omitempty"`
|
||||
Resources []BundleResource `json:"resources,omitempty"`
|
||||
Overlays []BundleOverlay `json:"overlays,omitempty"`
|
||||
Targets []BundleTarget `json:"targets,omitempty"`
|
||||
TargetRestrictions []BundleTargetRestriction `json:"targetRestrictions,omitempty"`
|
||||
}
|
||||
|
||||
type BundleResource struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Content string `json:"content,omitempty"`
|
||||
Encoding string `json:"encoding,omitempty"`
|
||||
}
|
||||
|
||||
type RolloutStrategy struct {
|
||||
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
|
||||
MaxUnavailablePartitions *intstr.IntOrString `json:"maxUnavailablePartitions,omitempty"`
|
||||
AutoPartitionSize *intstr.IntOrString `json:"autoPartitionSize,omitempty"`
|
||||
Partitions []Partition `json:"partitions,omitempty"`
|
||||
}
|
||||
|
||||
type Partition struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
|
||||
ClusterSelector *metav1.LabelSelector `json:"clusterSelector,omitempty"`
|
||||
ClusterGroup string `json:"clusterGroup,omitempty"`
|
||||
ClusterGroupSelector *metav1.LabelSelector `json:"clusterGroupSelector,omitempty"`
|
||||
}
|
||||
|
||||
type BundleOverlay struct {
|
||||
BundleDeploymentOptions
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
Overlays []string `json:"overlays,omitempty"`
|
||||
Resources []BundleResource `json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
type BundleTargetRestriction struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
ClusterSelector *metav1.LabelSelector `json:"clusterSelector,omitempty"`
|
||||
ClusterGroup string `json:"clusterGroup,omitempty"`
|
||||
ClusterGroupSelector *metav1.LabelSelector `json:"clusterGroupSelector,omitempty"`
|
||||
}
|
||||
|
||||
type BundleTarget struct {
|
||||
BundleDeploymentOptions
|
||||
Name string `json:"name,omitempty"`
|
||||
ClusterSelector *metav1.LabelSelector `json:"clusterSelector,omitempty"`
|
||||
ClusterGroup string `json:"clusterGroup,omitempty"`
|
||||
ClusterGroupSelector *metav1.LabelSelector `json:"clusterGroupSelector,omitempty"`
|
||||
Overlays []string `json:"overlays,omitempty"`
|
||||
}
|
||||
|
||||
type BundleSummary struct {
|
||||
NotReady int `json:"notReady,omitempty"`
|
||||
WaitApplied int `json:"waitApplied,omitempty"`
|
||||
ErrApplied int `json:"errApplied,omitempty"`
|
||||
OutOfSync int `json:"outOfSync,omitempty"`
|
||||
Modified int `json:"modified,omitempty"`
|
||||
Ready int `json:"ready"`
|
||||
Pending int `json:"pending,omitempty"`
|
||||
DesiredReady int `json:"desiredReady"`
|
||||
NonReadyResources []NonReadyResource `json:"nonReadyResources,omitempty"`
|
||||
}
|
||||
|
||||
type NonReadyResource struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
State BundleState `json:"bundleState,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
BundleConditionReady = "Ready"
|
||||
BundleDeploymentConditionReady = "Ready"
|
||||
BundleDeploymentConditionDeployed = "Deployed"
|
||||
)
|
||||
|
||||
type BundleStatus struct {
|
||||
Conditions []genericcondition.GenericCondition `json:"conditions,omitempty"`
|
||||
|
||||
Summary BundleSummary `json:"summary,omitempty"`
|
||||
NewlyCreated int `json:"newlyCreated,omitempty"`
|
||||
Unavailable int `json:"unavailable,omitempty"`
|
||||
UnavailablePartitions int `json:"unavailablePartitions,omitempty"`
|
||||
MaxUnavailable int `json:"maxUnavailable,omitempty"`
|
||||
MaxUnavailablePartitions int `json:"maxUnavailablePartitions,omitempty"`
|
||||
MaxNew int `json:"maxNew,omitempty"`
|
||||
PartitionStatus []PartitionStatus `json:"partitions,omitempty"`
|
||||
Display BundleDisplay `json:"display,omitempty"`
|
||||
}
|
||||
|
||||
type BundleDisplay struct {
|
||||
ReadyClusters string `json:"readyClusters,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
type PartitionStatus struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Count int `json:"count,omitempty"`
|
||||
MaxUnavailable int `json:"maxUnavailable,omitempty"`
|
||||
Unavailable int `json:"unavailable,omitempty"`
|
||||
Summary BundleSummary `json:"summary,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type BundleDeployment struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec BundleDeploymentSpec `json:"spec,omitempty"`
|
||||
Status BundleDeploymentStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type BundleDeploymentOptions struct {
|
||||
DefaultNamespace string `json:"namespace,omitempty"`
|
||||
KustomizeDir string `json:"kustomizeDir,omitempty"`
|
||||
TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
|
||||
Values *GenericMap `json:"values,omitempty"`
|
||||
ServiceAccount string `json:"serviceAccount,omitempty"`
|
||||
Force bool `json:"force,omitempty"`
|
||||
TakeOwnership bool `json:"takeOwnership,omitempty"`
|
||||
}
|
||||
|
||||
type BundleDeploymentSpec struct {
|
||||
StagedOptions BundleDeploymentOptions `json:"stagedOptions,omitempty"`
|
||||
StagedDeploymentID string `json:"stagedDeploymentID,omitempty"`
|
||||
Options BundleDeploymentOptions `json:"options,omitempty"`
|
||||
DeploymentID string `json:"deploymentID,omitempty"`
|
||||
}
|
||||
|
||||
type BundleDeploymentStatus struct {
|
||||
Conditions []genericcondition.GenericCondition `json:"conditions,omitempty"`
|
||||
AppliedDeploymentID string `json:"appliedDeploymentID,omitempty"`
|
||||
Release string `json:"release,omitempty"`
|
||||
Ready bool `json:"ready,omitempty"`
|
||||
NonModified bool `json:"nonModified,omitempty"`
|
||||
NonReadyStatus []NonReadyStatus `json:"nonReadyStatus,omitempty"`
|
||||
ModifiedStatus []ModifiedStatus `json:"modifiedStatus,omitempty"`
|
||||
Display BundleDeploymentDisplay `json:"display,omitempty"`
|
||||
}
|
||||
|
||||
type BundleDeploymentDisplay struct {
|
||||
Deployed string `json:"deployed,omitempty"`
|
||||
Monitored string `json:"monitored,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
type NonReadyStatus struct {
|
||||
UID types.UID `json:"uid,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Summary summary.Summary `json:"summary,omitempty"`
|
||||
}
|
||||
|
||||
func (in NonReadyStatus) String() string {
|
||||
return name(in.APIVersion, in.Kind, in.Namespace, in.Name) + " " + in.Summary.String()
|
||||
}
|
||||
|
||||
func name(apiVersion, kind, namespace, name string) string {
|
||||
if apiVersion == "" {
|
||||
if namespace == "" {
|
||||
return fmt.Sprintf("%s %s", strings.ToLower(kind), name)
|
||||
}
|
||||
return fmt.Sprintf("%s %s/%s", strings.ToLower(kind), namespace, name)
|
||||
}
|
||||
if namespace == "" {
|
||||
return fmt.Sprintf("%s.%s %s", strings.ToLower(kind), strings.SplitN(apiVersion, "/", 2)[0], name)
|
||||
}
|
||||
return fmt.Sprintf("%s.%s %s/%s", strings.ToLower(kind), strings.SplitN(apiVersion, "/", 2)[0], namespace, name)
|
||||
}
|
||||
|
||||
type ModifiedStatus struct {
|
||||
Kind string `json:"kind,omitempty"`
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Create bool `json:"missing,omitempty"`
|
||||
Delete bool `json:"delete,omitempty"`
|
||||
Patch string `json:"patch,omitempty"`
|
||||
}
|
||||
|
||||
func (in ModifiedStatus) String() string {
|
||||
msg := name(in.APIVersion, in.Kind, in.Namespace, in.Name)
|
||||
if in.Create {
|
||||
return msg + " missing"
|
||||
} else if in.Delete {
|
||||
return msg + " extra"
|
||||
}
|
||||
return msg + " modified"
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type Content struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Content []byte `json:"content,omitempty"`
|
||||
}
|
||||
21
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/doc.go
generated
vendored
Normal file
21
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/doc.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright 2020 Rancher Labs, Inc.
|
||||
|
||||
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.
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +groupName=fleet.cattle.io
|
||||
package v1alpha1
|
||||
78
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/git.go
generated
vendored
Normal file
78
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/git.go
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"github.com/rancher/wrangler/pkg/genericcondition"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type GitRepo struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec GitRepoSpec `json:"spec,omitempty"`
|
||||
Status GitRepoStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type GitRepoSpec struct {
|
||||
// Repo is a URL to a git repo to clone and index
|
||||
Repo string `json:"repo,omitempty"`
|
||||
|
||||
// Branch The git branch to follow
|
||||
Branch string `json:"branch,omitempty"`
|
||||
|
||||
// Revision A specific commit or tag to operate on
|
||||
Revision string `json:"revision,omitempty"`
|
||||
|
||||
// ClientSecretName is the client secret to be used to connect to the repo
|
||||
// It is expected the secret be of type "kubernetes.io/basic-auth" or "kubernetes.io/ssh-auth".
|
||||
ClientSecretName string `json:"clientSecretName,omitempty"`
|
||||
|
||||
// BundleDirs is the directories relative to the git repo root that contain bundles to be applied.
|
||||
// Path globbing is support, for example ["bundles/*"] will match all folders as a subdirectory of bundles/
|
||||
// If empty, "/" is the default
|
||||
BundleDirs []string `json:"bundleDirs,omitempty"`
|
||||
|
||||
// ServiceAccount used in the downstream cluster for deployment
|
||||
ServiceAccount string `json:"serviceAccount,omitempty"`
|
||||
|
||||
// Targets is a list of target this repo will deploy to
|
||||
Targets []GitTarget `json:"targets,omitempty"`
|
||||
}
|
||||
|
||||
type GitTarget struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
ClusterSelector *metav1.LabelSelector `json:"clusterSelector,omitempty"`
|
||||
ClusterGroup string `json:"clusterGroup,omitempty"`
|
||||
ClusterGroupSelector *metav1.LabelSelector `json:"clusterGroupSelector,omitempty"`
|
||||
}
|
||||
|
||||
type GitRepoStatus struct {
|
||||
ObservedGeneration int64 `json:"observedGeneration"`
|
||||
Commit string `json:"commit,omitempty"`
|
||||
Summary BundleSummary `json:"summary,omitempty"`
|
||||
Display GitRepoDisplay `json:"display,omitempty"`
|
||||
Conditions []genericcondition.GenericCondition `json:"conditions,omitempty"`
|
||||
}
|
||||
|
||||
type GitRepoDisplay struct {
|
||||
ReadyBundleDeployments string `json:"readyBundleDeployments,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type GitRepoRestriction struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
DefaultServiceAccount string `json:"defaultServiceAccount,omitempty"`
|
||||
AllowedServiceAccounts []string `json:"allowedServiceAccounts,omitempty"`
|
||||
AllowedRepoPatterns []string `json:"allowedRepoPatterns,omitempty"`
|
||||
|
||||
DefaultClientSecretName string `json:"defaultClientSecretName,omitempty"`
|
||||
AllowedClientSecretNames []string `json:"allowedClientSecretNames,omitempty"`
|
||||
}
|
||||
136
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/target.go
generated
vendored
Normal file
136
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/target.go
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"github.com/rancher/wrangler/pkg/genericcondition"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
ClusterConditionReady = "Ready"
|
||||
ClusterGroupAnnotation = "fleet.cattle.io/cluster-group"
|
||||
ClusterGroupNamespaceAnnotation = "fleet.cattle.io/cluster-group-namespace"
|
||||
ClusterNamespaceAnnotation = "fleet.cattle.io/cluster-namespace"
|
||||
ClusterAnnotation = "fleet.cattle.io/cluster"
|
||||
TTLSecondsAnnotation = "fleet.cattle.io/ttl-seconds"
|
||||
ManagedAnnotation = "fleet.cattle.io/managed"
|
||||
AnnotationGroup = "fleet.cattle.io/"
|
||||
|
||||
BootstrapToken = "fleet.cattle.io/bootstrap-token"
|
||||
)
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type ClusterGroup struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ClusterGroupSpec `json:"spec"`
|
||||
Status ClusterGroupStatus `json:"status"`
|
||||
}
|
||||
|
||||
type ClusterGroupSpec struct {
|
||||
Selector *metav1.LabelSelector `json:"selector,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterGroupStatus struct {
|
||||
ClusterCount int `json:"clusterCount"`
|
||||
NonReadyClusterCount int `json:"nonReadyClusterCount"`
|
||||
NonReadyClusters []string `json:"nonReadyClusters,omitempty"`
|
||||
Conditions []genericcondition.GenericCondition `json:"conditions,omitempty"`
|
||||
Summary BundleSummary `json:"summary,omitempty"`
|
||||
Display ClusterGroupDisplay `json:"display,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterGroupDisplay struct {
|
||||
ReadyClusters string `json:"readyClusters,omitempty"`
|
||||
ReadyBundles string `json:"readyBundles,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type Cluster struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ClusterSpec `json:"spec,omitempty"`
|
||||
Status ClusterStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterSpec struct {
|
||||
Paused bool `json:"paused,omitempty"`
|
||||
ClientID string `json:"clientID,omitempty"`
|
||||
KubeConfigSecret string `json:"kubeConfigSecret,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterStatus struct {
|
||||
Conditions []genericcondition.GenericCondition `json:"conditions,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Summary BundleSummary `json:"summary,omitempty"`
|
||||
AgentDeployed *bool `json:"agentDeployed,omitempty"`
|
||||
|
||||
Display ClusterDisplay `json:"display,omitempty"`
|
||||
Agent AgentStatus `json:"agent,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterDisplay struct {
|
||||
ReadyBundles string `json:"readyBundles,omitempty"`
|
||||
ReadyNodes string `json:"readyNodes,omitempty"`
|
||||
SampleNode string `json:"sampleNode,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
type AgentStatus struct {
|
||||
LastSeen metav1.Time `json:"lastSeen,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
NonReadyNodes int `json:"nonReadyNodes,omitempty"`
|
||||
ReadyNodes int `json:"readyNodes,omitempty"`
|
||||
// At most 3 nodes
|
||||
NonReadyNodeNames []string `json:"nonReadyNodeNames,omitempty"`
|
||||
// At most 3 nodes
|
||||
ReadyNodeNames []string `json:"readyNodeNames,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type ClusterRegistration struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ClusterRegistrationSpec `json:"spec,omitempty"`
|
||||
Status ClusterRegistrationStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterRegistrationSpec struct {
|
||||
ClientID string `json:"clientID,omitempty"`
|
||||
ClientRandom string `json:"clientRandom,omitempty"`
|
||||
ClusterLabels map[string]string `json:"clusterLabels,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterRegistrationStatus struct {
|
||||
ClusterName string `json:"clusterName,omitempty"`
|
||||
Granted bool `json:"granted,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type ClusterRegistrationToken struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ClusterRegistrationTokenSpec `json:"spec,omitempty"`
|
||||
Status ClusterRegistrationTokenStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterRegistrationTokenSpec struct {
|
||||
TTLSeconds int `json:"ttlSeconds,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterRegistrationTokenStatus struct {
|
||||
Expires metav1.Time `json:"expires,omitempty"`
|
||||
SecretName string `json:"secretName,omitempty"`
|
||||
}
|
||||
26
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/values.go
generated
vendored
Normal file
26
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/values.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/rancher/wrangler/pkg/data/convert"
|
||||
)
|
||||
|
||||
type GenericMap struct {
|
||||
Data map[string]interface{} `json:"-"`
|
||||
}
|
||||
|
||||
func (in GenericMap) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(in.Data)
|
||||
}
|
||||
|
||||
func (in *GenericMap) UnmarshalJSON(data []byte) error {
|
||||
in.Data = map[string]interface{}{}
|
||||
return json.Unmarshal(data, &in.Data)
|
||||
}
|
||||
|
||||
func (in *GenericMap) DeepCopyInto(out *GenericMap) {
|
||||
if err := convert.ToObj(in.Data, &out.Data); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
1429
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/zz_generated_deepcopy.go
generated
vendored
Normal file
1429
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/zz_generated_deepcopy.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
195
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/zz_generated_list_types.go
generated
vendored
Normal file
195
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/zz_generated_list_types.go
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
Copyright 2020 Rancher Labs, Inc.
|
||||
|
||||
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.
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +groupName=fleet.cattle.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// BundleList is a list of Bundle resources
|
||||
type BundleList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []Bundle `json:"items"`
|
||||
}
|
||||
|
||||
func NewBundle(namespace, name string, obj Bundle) *Bundle {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("Bundle").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// BundleDeploymentList is a list of BundleDeployment resources
|
||||
type BundleDeploymentList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []BundleDeployment `json:"items"`
|
||||
}
|
||||
|
||||
func NewBundleDeployment(namespace, name string, obj BundleDeployment) *BundleDeployment {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("BundleDeployment").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// BundleNamespaceMappingList is a list of BundleNamespaceMapping resources
|
||||
type BundleNamespaceMappingList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []BundleNamespaceMapping `json:"items"`
|
||||
}
|
||||
|
||||
func NewBundleNamespaceMapping(namespace, name string, obj BundleNamespaceMapping) *BundleNamespaceMapping {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("BundleNamespaceMapping").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ClusterList is a list of Cluster resources
|
||||
type ClusterList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []Cluster `json:"items"`
|
||||
}
|
||||
|
||||
func NewCluster(namespace, name string, obj Cluster) *Cluster {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("Cluster").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ClusterGroupList is a list of ClusterGroup resources
|
||||
type ClusterGroupList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []ClusterGroup `json:"items"`
|
||||
}
|
||||
|
||||
func NewClusterGroup(namespace, name string, obj ClusterGroup) *ClusterGroup {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("ClusterGroup").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ClusterRegistrationList is a list of ClusterRegistration resources
|
||||
type ClusterRegistrationList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []ClusterRegistration `json:"items"`
|
||||
}
|
||||
|
||||
func NewClusterRegistration(namespace, name string, obj ClusterRegistration) *ClusterRegistration {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("ClusterRegistration").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ClusterRegistrationTokenList is a list of ClusterRegistrationToken resources
|
||||
type ClusterRegistrationTokenList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []ClusterRegistrationToken `json:"items"`
|
||||
}
|
||||
|
||||
func NewClusterRegistrationToken(namespace, name string, obj ClusterRegistrationToken) *ClusterRegistrationToken {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("ClusterRegistrationToken").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ContentList is a list of Content resources
|
||||
type ContentList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []Content `json:"items"`
|
||||
}
|
||||
|
||||
func NewContent(namespace, name string, obj Content) *Content {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("Content").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// GitRepoList is a list of GitRepo resources
|
||||
type GitRepoList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []GitRepo `json:"items"`
|
||||
}
|
||||
|
||||
func NewGitRepo(namespace, name string, obj GitRepo) *GitRepo {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("GitRepo").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// GitRepoRestrictionList is a list of GitRepoRestriction resources
|
||||
type GitRepoRestrictionList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []GitRepoRestriction `json:"items"`
|
||||
}
|
||||
|
||||
func NewGitRepoRestriction(namespace, name string, obj GitRepoRestriction) *GitRepoRestriction {
|
||||
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("GitRepoRestriction").ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
87
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/zz_generated_register.go
generated
vendored
Normal file
87
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1/zz_generated_register.go
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Copyright 2020 Rancher Labs, Inc.
|
||||
|
||||
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.
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +groupName=fleet.cattle.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
BundleResourceName = "bundles"
|
||||
BundleDeploymentResourceName = "bundledeployments"
|
||||
BundleNamespaceMappingResourceName = "bundlenamespacemappings"
|
||||
ClusterResourceName = "clusters"
|
||||
ClusterGroupResourceName = "clustergroups"
|
||||
ClusterRegistrationResourceName = "clusterregistrations"
|
||||
ClusterRegistrationTokenResourceName = "clusterregistrationtokens"
|
||||
ContentResourceName = "contents"
|
||||
GitRepoResourceName = "gitrepos"
|
||||
GitRepoRestrictionResourceName = "gitreporestrictions"
|
||||
)
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: fleet.GroupName, Version: "v1alpha1"}
|
||||
|
||||
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
|
||||
func Kind(kind string) schema.GroupKind {
|
||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||
}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
var (
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to Scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&Bundle{},
|
||||
&BundleList{},
|
||||
&BundleDeployment{},
|
||||
&BundleDeploymentList{},
|
||||
&BundleNamespaceMapping{},
|
||||
&BundleNamespaceMappingList{},
|
||||
&Cluster{},
|
||||
&ClusterList{},
|
||||
&ClusterGroup{},
|
||||
&ClusterGroupList{},
|
||||
&ClusterRegistration{},
|
||||
&ClusterRegistrationList{},
|
||||
&ClusterRegistrationToken{},
|
||||
&ClusterRegistrationTokenList{},
|
||||
&Content{},
|
||||
&ContentList{},
|
||||
&GitRepo{},
|
||||
&GitRepoList{},
|
||||
&GitRepoRestriction{},
|
||||
&GitRepoRestrictionList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
||||
24
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/zz_generated_register.go
generated
vendored
Normal file
24
vendor/github.com/rancher/fleet/pkg/apis/fleet.cattle.io/zz_generated_register.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2020 Rancher Labs, Inc.
|
||||
|
||||
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 fleet
|
||||
|
||||
const (
|
||||
// Package-wide consts from generator "zz_generated_register".
|
||||
GroupName = "fleet.cattle.io"
|
||||
)
|
||||
178
vendor/github.com/rancher/wrangler/LICENSE
generated
vendored
Normal file
178
vendor/github.com/rancher/wrangler/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
|
||||
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
|
||||
|
||||
302
vendor/github.com/rancher/wrangler/pkg/data/convert/convert.go
generated
vendored
Normal file
302
vendor/github.com/rancher/wrangler/pkg/data/convert/convert.go
generated
vendored
Normal file
@@ -0,0 +1,302 @@
|
||||
package convert
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func Singular(value interface{}) interface{} {
|
||||
if slice, ok := value.([]string); ok {
|
||||
if len(slice) == 0 {
|
||||
return nil
|
||||
}
|
||||
return slice[0]
|
||||
}
|
||||
if slice, ok := value.([]interface{}); ok {
|
||||
if len(slice) == 0 {
|
||||
return nil
|
||||
}
|
||||
return slice[0]
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func ToStringNoTrim(value interface{}) string {
|
||||
if t, ok := value.(time.Time); ok {
|
||||
return t.Format(time.RFC3339)
|
||||
}
|
||||
single := Singular(value)
|
||||
if single == nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprint(single)
|
||||
}
|
||||
|
||||
func ToString(value interface{}) string {
|
||||
return strings.TrimSpace(ToStringNoTrim(value))
|
||||
}
|
||||
|
||||
func ToTimestamp(value interface{}) (int64, error) {
|
||||
str := ToString(value)
|
||||
if str == "" {
|
||||
return 0, errors.New("invalid date")
|
||||
}
|
||||
t, err := time.Parse(time.RFC3339, str)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return t.UnixNano() / 1000000, nil
|
||||
}
|
||||
|
||||
func ToBool(value interface{}) bool {
|
||||
value = Singular(value)
|
||||
|
||||
b, ok := value.(bool)
|
||||
if ok {
|
||||
return b
|
||||
}
|
||||
|
||||
str := strings.ToLower(ToString(value))
|
||||
return str == "true" || str == "t" || str == "yes" || str == "y"
|
||||
}
|
||||
|
||||
func ToNumber(value interface{}) (int64, error) {
|
||||
value = Singular(value)
|
||||
|
||||
i, ok := value.(int64)
|
||||
if ok {
|
||||
return i, nil
|
||||
}
|
||||
f, ok := value.(float64)
|
||||
if ok {
|
||||
return int64(f), nil
|
||||
}
|
||||
if n, ok := value.(json.Number); ok {
|
||||
i, err := n.Int64()
|
||||
if err == nil {
|
||||
return i, nil
|
||||
}
|
||||
f, err := n.Float64()
|
||||
return int64(f), err
|
||||
}
|
||||
return strconv.ParseInt(ToString(value), 10, 64)
|
||||
}
|
||||
|
||||
func ToFloat(value interface{}) (float64, error) {
|
||||
value = Singular(value)
|
||||
|
||||
f64, ok := value.(float64)
|
||||
if ok {
|
||||
return f64, nil
|
||||
}
|
||||
|
||||
f32, ok := value.(float32)
|
||||
if ok {
|
||||
return float64(f32), nil
|
||||
}
|
||||
|
||||
if n, ok := value.(json.Number); ok {
|
||||
i, err := n.Int64()
|
||||
if err == nil {
|
||||
return float64(i), nil
|
||||
}
|
||||
f, err := n.Float64()
|
||||
return float64(f), err
|
||||
}
|
||||
return strconv.ParseFloat(ToString(value), 64)
|
||||
}
|
||||
|
||||
func Capitalize(s string) string {
|
||||
if len(s) <= 1 {
|
||||
return strings.ToUpper(s)
|
||||
}
|
||||
|
||||
return strings.ToUpper(s[:1]) + s[1:]
|
||||
}
|
||||
|
||||
func Uncapitalize(s string) string {
|
||||
if len(s) <= 1 {
|
||||
return strings.ToLower(s)
|
||||
}
|
||||
|
||||
return strings.ToLower(s[:1]) + s[1:]
|
||||
}
|
||||
|
||||
func LowerTitle(input string) string {
|
||||
runes := []rune(input)
|
||||
for i := 0; i < len(runes); i++ {
|
||||
if unicode.IsUpper(runes[i]) &&
|
||||
(i == 0 ||
|
||||
i == len(runes)-1 ||
|
||||
unicode.IsUpper(runes[i+1])) {
|
||||
runes[i] = unicode.ToLower(runes[i])
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return string(runes)
|
||||
}
|
||||
|
||||
func IsEmptyValue(v interface{}) bool {
|
||||
if v == nil || v == "" || v == 0 || v == false {
|
||||
return true
|
||||
}
|
||||
if m, ok := v.(map[string]interface{}); ok {
|
||||
return len(m) == 0
|
||||
}
|
||||
if s, ok := v.([]interface{}); ok {
|
||||
return len(s) == 0
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ToMapInterface(obj interface{}) map[string]interface{} {
|
||||
v, _ := obj.(map[string]interface{})
|
||||
return v
|
||||
}
|
||||
|
||||
func ToInterfaceSlice(obj interface{}) []interface{} {
|
||||
if v, ok := obj.([]interface{}); ok {
|
||||
return v
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ToMapSlice(obj interface{}) []map[string]interface{} {
|
||||
if v, ok := obj.([]map[string]interface{}); ok {
|
||||
return v
|
||||
}
|
||||
vs, _ := obj.([]interface{})
|
||||
var result []map[string]interface{}
|
||||
for _, item := range vs {
|
||||
if v, ok := item.(map[string]interface{}); ok {
|
||||
result = append(result, v)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func ToStringSlice(data interface{}) []string {
|
||||
if v, ok := data.([]string); ok {
|
||||
return v
|
||||
}
|
||||
if v, ok := data.([]interface{}); ok {
|
||||
var result []string
|
||||
for _, item := range v {
|
||||
result = append(result, ToString(item))
|
||||
}
|
||||
return result
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ToObj(data interface{}, into interface{}) error {
|
||||
bytes, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(bytes, into)
|
||||
}
|
||||
|
||||
func EncodeToMap(obj interface{}) (map[string]interface{}, error) {
|
||||
if m, ok := obj.(map[string]interface{}); ok {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
b, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := map[string]interface{}{}
|
||||
dec := json.NewDecoder(bytes.NewBuffer(b))
|
||||
dec.UseNumber()
|
||||
return result, dec.Decode(&result)
|
||||
}
|
||||
|
||||
func ToJSONKey(str string) string {
|
||||
parts := strings.Split(str, "_")
|
||||
for i := 1; i < len(parts); i++ {
|
||||
parts[i] = strings.Title(parts[i])
|
||||
}
|
||||
|
||||
return strings.Join(parts, "")
|
||||
}
|
||||
|
||||
func ToYAMLKey(str string) string {
|
||||
var result []rune
|
||||
cap := false
|
||||
|
||||
for i, r := range []rune(str) {
|
||||
if i == 0 {
|
||||
if unicode.IsUpper(r) {
|
||||
cap = true
|
||||
}
|
||||
result = append(result, unicode.ToLower(r))
|
||||
continue
|
||||
}
|
||||
|
||||
if unicode.IsUpper(r) {
|
||||
if cap {
|
||||
result = append(result, unicode.ToLower(r))
|
||||
} else {
|
||||
result = append(result, '_', unicode.ToLower(r))
|
||||
}
|
||||
} else {
|
||||
cap = false
|
||||
result = append(result, r)
|
||||
}
|
||||
}
|
||||
|
||||
return string(result)
|
||||
}
|
||||
|
||||
func ToArgKey(str string) string {
|
||||
var (
|
||||
result []rune
|
||||
input = []rune(str)
|
||||
)
|
||||
cap := false
|
||||
|
||||
for i := 0; i < len(input); i++ {
|
||||
r := input[i]
|
||||
if i == 0 {
|
||||
if unicode.IsUpper(r) {
|
||||
cap = true
|
||||
}
|
||||
result = append(result, unicode.ToLower(r))
|
||||
continue
|
||||
}
|
||||
|
||||
if unicode.IsUpper(r) {
|
||||
if cap {
|
||||
result = append(result, unicode.ToLower(r))
|
||||
} else if len(input) > i+2 &&
|
||||
unicode.IsUpper(input[i]) &&
|
||||
unicode.IsUpper(input[i+1]) &&
|
||||
unicode.IsUpper(input[i+2]) {
|
||||
result = append(result, '-',
|
||||
unicode.ToLower(input[i]),
|
||||
unicode.ToLower(input[i+1]),
|
||||
unicode.ToLower(input[i+2]))
|
||||
i += 2
|
||||
} else {
|
||||
result = append(result, '-', unicode.ToLower(r))
|
||||
}
|
||||
} else {
|
||||
cap = false
|
||||
result = append(result, r)
|
||||
}
|
||||
}
|
||||
|
||||
return "--" + string(result)
|
||||
}
|
||||
59
vendor/github.com/rancher/wrangler/pkg/data/data.go
generated
vendored
Normal file
59
vendor/github.com/rancher/wrangler/pkg/data/data.go
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"github.com/rancher/wrangler/pkg/data/convert"
|
||||
)
|
||||
|
||||
type List []map[string]interface{}
|
||||
|
||||
type Object map[string]interface{}
|
||||
|
||||
func New() Object {
|
||||
return map[string]interface{}{}
|
||||
}
|
||||
|
||||
func (o Object) Map(names ...string) Object {
|
||||
v := GetValueN(o, names...)
|
||||
m := convert.ToMapInterface(v)
|
||||
return m
|
||||
}
|
||||
|
||||
func (o Object) Slice(names ...string) (result []Object) {
|
||||
v := GetValueN(o, names...)
|
||||
for _, item := range convert.ToInterfaceSlice(v) {
|
||||
result = append(result, convert.ToMapInterface(item))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (o Object) Values() (result []Object) {
|
||||
for k := range o {
|
||||
result = append(result, o.Map(k))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (o Object) String(names ...string) string {
|
||||
v := GetValueN(o, names...)
|
||||
return convert.ToString(v)
|
||||
}
|
||||
|
||||
func (o Object) StringSlice(names ...string) []string {
|
||||
v := GetValueN(o, names...)
|
||||
return convert.ToStringSlice(v)
|
||||
}
|
||||
|
||||
func (o Object) Set(key string, obj interface{}) {
|
||||
if o == nil {
|
||||
return
|
||||
}
|
||||
o[key] = obj
|
||||
}
|
||||
|
||||
func (o Object) SetNested(obj interface{}, key ...string) {
|
||||
PutValue(o, obj, key...)
|
||||
}
|
||||
|
||||
func (o Object) Bool(key ...string) bool {
|
||||
return convert.ToBool(GetValueN(o, key...))
|
||||
}
|
||||
24
vendor/github.com/rancher/wrangler/pkg/data/merge.go
generated
vendored
Normal file
24
vendor/github.com/rancher/wrangler/pkg/data/merge.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package data
|
||||
|
||||
func MergeMaps(base, overlay map[string]interface{}) map[string]interface{} {
|
||||
result := map[string]interface{}{}
|
||||
for k, v := range base {
|
||||
result[k] = v
|
||||
}
|
||||
for k, v := range overlay {
|
||||
if baseMap, overlayMap, bothMaps := bothMaps(result[k], v); bothMaps {
|
||||
v = MergeMaps(baseMap, overlayMap)
|
||||
}
|
||||
result[k] = v
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func bothMaps(left, right interface{}) (map[string]interface{}, map[string]interface{}, bool) {
|
||||
leftMap, ok := left.(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, nil, false
|
||||
}
|
||||
rightMap, ok := right.(map[string]interface{})
|
||||
return leftMap, rightMap, ok
|
||||
}
|
||||
58
vendor/github.com/rancher/wrangler/pkg/data/values.go
generated
vendored
Normal file
58
vendor/github.com/rancher/wrangler/pkg/data/values.go
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
package data
|
||||
|
||||
func RemoveValue(data map[string]interface{}, keys ...string) (interface{}, bool) {
|
||||
for i, key := range keys {
|
||||
if i == len(keys)-1 {
|
||||
val, ok := data[key]
|
||||
delete(data, key)
|
||||
return val, ok
|
||||
}
|
||||
data, _ = data[key].(map[string]interface{})
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func GetValueN(data map[string]interface{}, keys ...string) interface{} {
|
||||
val, _ := GetValue(data, keys...)
|
||||
return val
|
||||
}
|
||||
|
||||
func GetValue(data map[string]interface{}, keys ...string) (interface{}, bool) {
|
||||
for i, key := range keys {
|
||||
if i == len(keys)-1 {
|
||||
val, ok := data[key]
|
||||
return val, ok
|
||||
}
|
||||
data, _ = data[key].(map[string]interface{})
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func PutValue(data map[string]interface{}, val interface{}, keys ...string) {
|
||||
if data == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// This is so ugly
|
||||
for i, key := range keys {
|
||||
if i == len(keys)-1 {
|
||||
data[key] = val
|
||||
} else {
|
||||
newData, ok := data[key]
|
||||
if ok {
|
||||
newMap, ok := newData.(map[string]interface{})
|
||||
if ok {
|
||||
data = newMap
|
||||
} else {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
newMap := map[string]interface{}{}
|
||||
data[key] = newMap
|
||||
data = newMap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
vendor/github.com/rancher/wrangler/pkg/genericcondition/condition.go
generated
vendored
Normal file
18
vendor/github.com/rancher/wrangler/pkg/genericcondition/condition.go
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
package genericcondition
|
||||
|
||||
import v1 "k8s.io/api/core/v1"
|
||||
|
||||
type GenericCondition struct {
|
||||
// Type of cluster condition.
|
||||
Type string `json:"type"`
|
||||
// Status of the condition, one of True, False, Unknown.
|
||||
Status v1.ConditionStatus `json:"status"`
|
||||
// The last time this condition was updated.
|
||||
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
|
||||
// Last time the condition transitioned from one status to another.
|
||||
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
|
||||
// The reason for the condition's last transition.
|
||||
Reason string `json:"reason,omitempty"`
|
||||
// Human-readable message indicating details about last transition
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
45
vendor/github.com/rancher/wrangler/pkg/kv/split.go
generated
vendored
Normal file
45
vendor/github.com/rancher/wrangler/pkg/kv/split.go
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
package kv
|
||||
|
||||
import "strings"
|
||||
|
||||
// Like split but if there is only one item return "", item
|
||||
func RSplit(s, sep string) (string, string) {
|
||||
parts := strings.SplitN(s, sep, 2)
|
||||
if len(parts) == 1 {
|
||||
return "", strings.TrimSpace(parts[0])
|
||||
}
|
||||
return strings.TrimSpace(parts[0]), strings.TrimSpace(safeIndex(parts, 1))
|
||||
}
|
||||
|
||||
func Split(s, sep string) (string, string) {
|
||||
parts := strings.SplitN(s, sep, 2)
|
||||
return strings.TrimSpace(parts[0]), strings.TrimSpace(safeIndex(parts, 1))
|
||||
}
|
||||
|
||||
func SplitLast(s, sep string) (string, string) {
|
||||
idx := strings.LastIndex(s, sep)
|
||||
if idx > -1 {
|
||||
return strings.TrimSpace(s[:idx]), strings.TrimSpace(s[idx+1:])
|
||||
}
|
||||
return s, ""
|
||||
}
|
||||
|
||||
func SplitMap(s, sep string) map[string]string {
|
||||
return SplitMapFromSlice(strings.Split(s, sep))
|
||||
}
|
||||
|
||||
func SplitMapFromSlice(parts []string) map[string]string {
|
||||
result := map[string]string{}
|
||||
for _, part := range parts {
|
||||
k, v := Split(part, "=")
|
||||
result[k] = v
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func safeIndex(parts []string, idx int) string {
|
||||
if len(parts) <= idx {
|
||||
return ""
|
||||
}
|
||||
return parts[idx]
|
||||
}
|
||||
27
vendor/github.com/rancher/wrangler/pkg/summary/cattletypes.go
generated
vendored
Normal file
27
vendor/github.com/rancher/wrangler/pkg/summary/cattletypes.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package summary
|
||||
|
||||
import (
|
||||
"github.com/rancher/wrangler/pkg/data"
|
||||
)
|
||||
|
||||
func checkCattleTypes(obj data.Object, condition []Condition, summary Summary) Summary {
|
||||
return checkRelease(obj, condition, summary)
|
||||
}
|
||||
|
||||
func checkRelease(obj data.Object, condition []Condition, summary Summary) Summary {
|
||||
if !isKind(obj, "Release", "catalog.cattle.io") {
|
||||
return summary
|
||||
}
|
||||
if obj.String("status", "summary", "state") != "deployed" {
|
||||
return summary
|
||||
}
|
||||
for _, resources := range obj.Slice("spec", "resources") {
|
||||
summary.Relationships = append(summary.Relationships, Relationship{
|
||||
Name: resources.String("name"),
|
||||
Kind: resources.String("kind"),
|
||||
APIVersion: resources.String("apiVersion"),
|
||||
Type: "manages",
|
||||
})
|
||||
}
|
||||
return summary
|
||||
}
|
||||
45
vendor/github.com/rancher/wrangler/pkg/summary/condition.go
generated
vendored
Normal file
45
vendor/github.com/rancher/wrangler/pkg/summary/condition.go
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
package summary
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/rancher/wrangler/pkg/data"
|
||||
)
|
||||
|
||||
func getRawConditions(obj data.Object) []data.Object {
|
||||
statusAnn := obj.String("metadata", "annotations", "cattle.io/status")
|
||||
if statusAnn != "" {
|
||||
status := data.Object{}
|
||||
if err := json.Unmarshal([]byte(statusAnn), &status); err == nil {
|
||||
return append(obj.Slice("status", "conditions"), status.Slice("conditions")...)
|
||||
}
|
||||
}
|
||||
return obj.Slice("status", "conditions")
|
||||
}
|
||||
|
||||
func getConditions(obj data.Object) (result []Condition) {
|
||||
for _, condition := range getRawConditions(obj) {
|
||||
result = append(result, Condition{d: condition})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type Condition struct {
|
||||
d data.Object
|
||||
}
|
||||
|
||||
func (c Condition) Type() string {
|
||||
return c.d.String("type")
|
||||
}
|
||||
|
||||
func (c Condition) Status() string {
|
||||
return c.d.String("status")
|
||||
}
|
||||
|
||||
func (c Condition) Reason() string {
|
||||
return c.d.String("reason")
|
||||
}
|
||||
|
||||
func (c Condition) Message() string {
|
||||
return c.d.String("message")
|
||||
}
|
||||
153
vendor/github.com/rancher/wrangler/pkg/summary/coretypes.go
generated
vendored
Normal file
153
vendor/github.com/rancher/wrangler/pkg/summary/coretypes.go
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
package summary
|
||||
|
||||
import (
|
||||
"github.com/rancher/wrangler/pkg/data"
|
||||
"github.com/rancher/wrangler/pkg/data/convert"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func checkPodSelector(obj data.Object, condition []Condition, summary Summary) Summary {
|
||||
selector := obj.Map("spec", "selector")
|
||||
if selector == nil {
|
||||
return summary
|
||||
}
|
||||
|
||||
if !isKind(obj, "ReplicaSet", "apps/", "extension/") &&
|
||||
!isKind(obj, "DaemonSet", "apps/", "extension/") &&
|
||||
!isKind(obj, "StatefulSet", "apps/", "extension/") &&
|
||||
!isKind(obj, "Deployment", "apps/", "extension/") &&
|
||||
!isKind(obj, "Job", "batch/") &&
|
||||
!isKind(obj, "Service") {
|
||||
return summary
|
||||
}
|
||||
|
||||
_, hasMatch := selector["matchLabels"]
|
||||
if !hasMatch {
|
||||
_, hasMatch = selector["matchExpressions"]
|
||||
}
|
||||
sel := metav1.LabelSelector{}
|
||||
if hasMatch {
|
||||
if err := convert.ToObj(selector, &sel); err != nil {
|
||||
return summary
|
||||
}
|
||||
} else {
|
||||
sel.MatchLabels = map[string]string{}
|
||||
for k, v := range selector {
|
||||
sel.MatchLabels[k] = convert.ToString(v)
|
||||
}
|
||||
}
|
||||
|
||||
t := "creates"
|
||||
if obj["kind"] == "Service" {
|
||||
t = "selects"
|
||||
}
|
||||
|
||||
summary.Relationships = append(summary.Relationships, Relationship{
|
||||
Kind: "Pod",
|
||||
APIVersion: "v1",
|
||||
Type: t,
|
||||
Selector: &sel,
|
||||
})
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkPod(obj data.Object, condition []Condition, summary Summary) Summary {
|
||||
if !isKind(obj, "Pod") {
|
||||
return summary
|
||||
}
|
||||
if obj.String("kind") != "Pod" || obj.String("apiVersion") != "v1" {
|
||||
return summary
|
||||
}
|
||||
summary = checkPodConfigMaps(obj, condition, summary)
|
||||
summary = checkPodSecrets(obj, condition, summary)
|
||||
summary = checkPodServiceAccount(obj, condition, summary)
|
||||
summary = checkPodProjectedVolume(obj, condition, summary)
|
||||
summary = checkPodPullSecret(obj, condition, summary)
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkPodPullSecret(obj data.Object, condition []Condition, summary Summary) Summary {
|
||||
for _, pullSecret := range obj.Slice("imagePullSecrets") {
|
||||
if name := pullSecret.String("name"); name != "" {
|
||||
summary.Relationships = append(summary.Relationships, Relationship{
|
||||
Name: name,
|
||||
Kind: "Secret",
|
||||
APIVersion: "v1",
|
||||
Type: "uses",
|
||||
})
|
||||
}
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkPodProjectedVolume(obj data.Object, condition []Condition, summary Summary) Summary {
|
||||
for _, vol := range obj.Slice("spec", "volumes") {
|
||||
for _, source := range vol.Slice("projected", "sources") {
|
||||
if secretName := source.String("secret", "name"); secretName != "" {
|
||||
summary.Relationships = append(summary.Relationships, Relationship{
|
||||
Name: secretName,
|
||||
Kind: "Secret",
|
||||
APIVersion: "v1",
|
||||
Type: "uses",
|
||||
})
|
||||
}
|
||||
if configMap := source.String("configMap", "name"); configMap != "" {
|
||||
summary.Relationships = append(summary.Relationships, Relationship{
|
||||
Name: configMap,
|
||||
Kind: "Secret",
|
||||
APIVersion: "v1",
|
||||
Type: "uses",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkPodConfigMaps(obj data.Object, condition []Condition, summary Summary) Summary {
|
||||
names := map[string]bool{}
|
||||
for _, vol := range obj.Slice("spec", "volumes") {
|
||||
name := vol.String("configMap", "name")
|
||||
if name == "" || names[name] {
|
||||
continue
|
||||
}
|
||||
names[name] = true
|
||||
summary.Relationships = append(summary.Relationships, Relationship{
|
||||
Name: name,
|
||||
Kind: "ConfigMap",
|
||||
APIVersion: "v1",
|
||||
Type: "uses",
|
||||
})
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkPodSecrets(obj data.Object, condition []Condition, summary Summary) Summary {
|
||||
names := map[string]bool{}
|
||||
for _, vol := range obj.Slice("spec", "volumes") {
|
||||
name := vol.String("secret", "secretName")
|
||||
if name == "" || names[name] {
|
||||
continue
|
||||
}
|
||||
names[name] = true
|
||||
summary.Relationships = append(summary.Relationships, Relationship{
|
||||
Name: name,
|
||||
Kind: "Secret",
|
||||
APIVersion: "v1",
|
||||
Type: "uses",
|
||||
})
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkPodServiceAccount(obj data.Object, condition []Condition, summary Summary) Summary {
|
||||
saName := obj.String("spec", "serviceAccountName")
|
||||
summary.Relationships = append(summary.Relationships, Relationship{
|
||||
Name: saName,
|
||||
Kind: "ServiceAccount",
|
||||
APIVersion: "v1",
|
||||
Type: "uses",
|
||||
})
|
||||
return summary
|
||||
|
||||
}
|
||||
98
vendor/github.com/rancher/wrangler/pkg/summary/summarized.go
generated
vendored
Normal file
98
vendor/github.com/rancher/wrangler/pkg/summary/summarized.go
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
package summary
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type SummarizedObject struct {
|
||||
metav1.PartialObjectMetadata
|
||||
Summary
|
||||
}
|
||||
|
||||
type SummarizedObjectList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||
Items []SummarizedObject `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||
}
|
||||
|
||||
func Summarized(u runtime.Object) *SummarizedObject {
|
||||
if s, ok := u.(*SummarizedObject); ok {
|
||||
return s
|
||||
}
|
||||
|
||||
s := &SummarizedObject{
|
||||
Summary: Summarize(u),
|
||||
}
|
||||
s.APIVersion, s.Kind = u.GetObjectKind().GroupVersionKind().ToAPIVersionAndKind()
|
||||
|
||||
meta, err := meta.Accessor(u)
|
||||
if err == nil {
|
||||
s.Name = meta.GetName()
|
||||
s.Namespace = meta.GetNamespace()
|
||||
s.Generation = meta.GetGeneration()
|
||||
s.UID = meta.GetUID()
|
||||
s.ResourceVersion = meta.GetResourceVersion()
|
||||
s.CreationTimestamp = meta.GetCreationTimestamp()
|
||||
s.DeletionTimestamp = meta.GetDeletionTimestamp()
|
||||
s.Labels = meta.GetLabels()
|
||||
s.Annotations = meta.GetAnnotations()
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (in *SummarizedObjectList) DeepCopyInto(out *SummarizedObjectList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]SummarizedObject, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (in *SummarizedObjectList) DeepCopy() *SummarizedObjectList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SummarizedObjectList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (in *SummarizedObjectList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (in *SummarizedObject) DeepCopyInto(out *SummarizedObject) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ObjectMeta = *in.ObjectMeta.DeepCopy()
|
||||
out.Summary = *in.Summary.DeepCopy()
|
||||
return
|
||||
}
|
||||
|
||||
func (in *SummarizedObject) DeepCopy() *SummarizedObject {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SummarizedObject)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (in *SummarizedObject) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
425
vendor/github.com/rancher/wrangler/pkg/summary/summarizers.go
generated
vendored
Normal file
425
vendor/github.com/rancher/wrangler/pkg/summary/summarizers.go
generated
vendored
Normal file
@@ -0,0 +1,425 @@
|
||||
package summary
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rancher/wrangler/pkg/data"
|
||||
"github.com/rancher/wrangler/pkg/data/convert"
|
||||
"github.com/rancher/wrangler/pkg/kv"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
kstatus "sigs.k8s.io/cli-utils/pkg/kstatus/status"
|
||||
)
|
||||
|
||||
const (
|
||||
kindSep = ", Kind="
|
||||
)
|
||||
|
||||
var (
|
||||
// True ==
|
||||
// False == error
|
||||
// Unknown == transitioning
|
||||
TransitioningUnknown = map[string]string{
|
||||
"Active": "activating",
|
||||
"AddonDeploy": "provisioning",
|
||||
"AgentDeployed": "provisioning",
|
||||
"BackingNamespaceCreated": "configuring",
|
||||
"Built": "building",
|
||||
"CertsGenerated": "provisioning",
|
||||
"ConfigOK": "configuring",
|
||||
"Created": "creating",
|
||||
"CreatorMadeOwner": "configuring",
|
||||
"DefaultNamespaceAssigned": "configuring",
|
||||
"DefaultNetworkPolicyCreated": "configuring",
|
||||
"DefaultProjectCreated": "configuring",
|
||||
"DockerProvisioned": "provisioning",
|
||||
"Deployed": "deploying",
|
||||
"Drained": "draining",
|
||||
"Downloaded": "downloading",
|
||||
"etcd": "provisioning",
|
||||
"Inactive": "deactivating",
|
||||
"Initialized": "initializing",
|
||||
"Installed": "installing",
|
||||
"NodesCreated": "provisioning",
|
||||
"Pending": "pending",
|
||||
"PodScheduled": "scheduling",
|
||||
"Provisioned": "provisioning",
|
||||
"Refreshed": "refreshed",
|
||||
"Registered": "registering",
|
||||
"Removed": "removing",
|
||||
"Saved": "saving",
|
||||
"Updated": "updating",
|
||||
"Updating": "updating",
|
||||
"Upgraded": "upgrading",
|
||||
"Waiting": "waiting",
|
||||
"InitialRolesPopulated": "activating",
|
||||
"ScalingActive": "pending",
|
||||
"AbleToScale": "pending",
|
||||
"RunCompleted": "running",
|
||||
"Processed": "processed",
|
||||
}
|
||||
|
||||
// True == error
|
||||
// False ==
|
||||
// Unknown ==
|
||||
ErrorTrue = map[string]bool{
|
||||
"OutOfDisk": true,
|
||||
"MemoryPressure": true,
|
||||
"DiskPressure": true,
|
||||
"NetworkUnavailable": true,
|
||||
"KernelHasNoDeadlock": true,
|
||||
"Unschedulable": true,
|
||||
"ReplicaFailure": true,
|
||||
}
|
||||
|
||||
// True ==
|
||||
// False == error
|
||||
// Unknown ==
|
||||
ErrorFalse = map[string]bool{
|
||||
"Failed": true,
|
||||
"Progressing": true,
|
||||
}
|
||||
|
||||
// True ==
|
||||
// False == transitioning
|
||||
// Unknown == error
|
||||
TransitioningFalse = map[string]string{
|
||||
"Completed": "activating",
|
||||
"Ready": "unavailable",
|
||||
"Available": "updating",
|
||||
"Progressing": "inactive",
|
||||
}
|
||||
|
||||
Summarizers []Summarizer
|
||||
)
|
||||
|
||||
type Summarizer func(obj data.Object, conditions []Condition, summary Summary) Summary
|
||||
|
||||
func init() {
|
||||
Summarizers = []Summarizer{
|
||||
checkStatusSummary,
|
||||
checkErrors,
|
||||
checkTransitioning,
|
||||
checkActive,
|
||||
checkPhase,
|
||||
checkInitializing,
|
||||
checkRemoving,
|
||||
checkStandard,
|
||||
checkLoadBalancer,
|
||||
checkPod,
|
||||
checkPodSelector,
|
||||
checkOwner,
|
||||
checkApplyOwned,
|
||||
checkCattleTypes,
|
||||
}
|
||||
}
|
||||
|
||||
func checkOwner(obj data.Object, conditions []Condition, summary Summary) Summary {
|
||||
ustr := &unstructured.Unstructured{
|
||||
Object: obj,
|
||||
}
|
||||
for _, ownerref := range ustr.GetOwnerReferences() {
|
||||
rel := Relationship{
|
||||
Name: ownerref.Name,
|
||||
Kind: ownerref.Kind,
|
||||
APIVersion: ownerref.APIVersion,
|
||||
Type: "owner",
|
||||
Inbound: true,
|
||||
}
|
||||
if ownerref.Controller != nil && *ownerref.Controller {
|
||||
rel.ControlledBy = true
|
||||
}
|
||||
|
||||
summary.Relationships = append(summary.Relationships, rel)
|
||||
}
|
||||
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkStatusSummary(obj data.Object, conditions []Condition, summary Summary) Summary {
|
||||
summaryObj := obj.Map("status", "display")
|
||||
if len(summaryObj) == 0 {
|
||||
summaryObj = obj.Map("status", "summary")
|
||||
if len(summaryObj) == 0 {
|
||||
return summary
|
||||
}
|
||||
}
|
||||
obj = summaryObj
|
||||
|
||||
if _, ok := obj["state"]; ok {
|
||||
summary.State = obj.String("state")
|
||||
}
|
||||
if _, ok := obj["transitioning"]; ok {
|
||||
summary.Transitioning = obj.Bool("transitioning")
|
||||
}
|
||||
if _, ok := obj["error"]; ok {
|
||||
summary.Error = obj.Bool("error")
|
||||
}
|
||||
if _, ok := obj["message"]; ok {
|
||||
summary.Message = append(summary.Message, obj.String("message"))
|
||||
}
|
||||
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkStandard(obj data.Object, conditions []Condition, summary Summary) Summary {
|
||||
if summary.State != "" {
|
||||
return summary
|
||||
}
|
||||
|
||||
// this is a hack to not call the standard summarizers on norman mapped objects
|
||||
if strings.HasPrefix(obj.String("type"), "/") {
|
||||
return summary
|
||||
}
|
||||
|
||||
result, err := kstatus.Compute(&unstructured.Unstructured{Object: obj})
|
||||
if err != nil {
|
||||
return summary
|
||||
}
|
||||
|
||||
switch result.Status {
|
||||
case kstatus.InProgressStatus:
|
||||
summary.State = "in-progress"
|
||||
summary.Message = append(summary.Message, result.Message)
|
||||
summary.Transitioning = true
|
||||
case kstatus.FailedStatus:
|
||||
summary.State = "failed"
|
||||
summary.Message = append(summary.Message, result.Message)
|
||||
summary.Error = true
|
||||
case kstatus.CurrentStatus:
|
||||
summary.State = "active"
|
||||
summary.Message = append(summary.Message, result.Message)
|
||||
case kstatus.TerminatingStatus:
|
||||
summary.State = "removing"
|
||||
summary.Message = append(summary.Message, result.Message)
|
||||
summary.Transitioning = true
|
||||
}
|
||||
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkErrors(_ data.Object, conditions []Condition, summary Summary) Summary {
|
||||
for _, c := range conditions {
|
||||
if (ErrorFalse[c.Type()] && c.Status() == "False") || c.Reason() == "Error" {
|
||||
summary.Error = true
|
||||
summary.Message = append(summary.Message, c.Message())
|
||||
if summary.State == "active" || summary.State == "" {
|
||||
summary.State = "error"
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if summary.Error {
|
||||
return summary
|
||||
}
|
||||
|
||||
for _, c := range conditions {
|
||||
if ErrorTrue[c.Type()] && c.Status() == "True" {
|
||||
summary.Error = true
|
||||
summary.Message = append(summary.Message, c.Message())
|
||||
}
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkTransitioning(_ data.Object, conditions []Condition, summary Summary) Summary {
|
||||
for _, c := range conditions {
|
||||
newState, ok := TransitioningUnknown[c.Type()]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if c.Status() == "False" {
|
||||
summary.Error = true
|
||||
summary.State = newState
|
||||
summary.Message = append(summary.Message, c.Message())
|
||||
} else if c.Status() == "Unknown" && summary.State == "" {
|
||||
summary.Transitioning = true
|
||||
summary.State = newState
|
||||
summary.Message = append(summary.Message, c.Message())
|
||||
}
|
||||
}
|
||||
|
||||
for _, c := range conditions {
|
||||
if summary.State != "" {
|
||||
break
|
||||
}
|
||||
newState, ok := TransitioningFalse[c.Type()]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if c.Status() == "False" {
|
||||
summary.Transitioning = true
|
||||
summary.State = newState
|
||||
summary.Message = append(summary.Message, c.Message())
|
||||
} else if c.Status() == "Unknown" {
|
||||
summary.Error = true
|
||||
summary.State = newState
|
||||
summary.Message = append(summary.Message, c.Message())
|
||||
}
|
||||
}
|
||||
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkActive(obj data.Object, _ []Condition, summary Summary) Summary {
|
||||
if summary.State != "" {
|
||||
return summary
|
||||
}
|
||||
|
||||
switch obj.String("spec", "active") {
|
||||
case "true":
|
||||
summary.State = "active"
|
||||
case "false":
|
||||
summary.State = "inactive"
|
||||
}
|
||||
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkPhase(obj data.Object, _ []Condition, summary Summary) Summary {
|
||||
phase := obj.String("status", "phase")
|
||||
if phase == "Succeeded" {
|
||||
summary.State = "succeeded"
|
||||
summary.Transitioning = false
|
||||
} else if phase != "" && summary.State == "" {
|
||||
summary.State = phase
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkInitializing(obj data.Object, conditions []Condition, summary Summary) Summary {
|
||||
apiVersion := obj.String("apiVersion")
|
||||
_, hasConditions := obj.Map("status")["conditions"]
|
||||
if summary.State == "" && hasConditions && len(conditions) == 0 && strings.Contains(apiVersion, "cattle.io") {
|
||||
val := obj.String("metadata", "created")
|
||||
if i, err := convert.ToTimestamp(val); err == nil {
|
||||
if time.Unix(i/1000, 0).Add(5 * time.Second).After(time.Now()) {
|
||||
summary.State = "initializing"
|
||||
summary.Transitioning = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkRemoving(obj data.Object, conditions []Condition, summary Summary) Summary {
|
||||
removed := obj.String("metadata", "removed")
|
||||
if removed == "" {
|
||||
return summary
|
||||
}
|
||||
|
||||
summary.State = "removing"
|
||||
summary.Transitioning = true
|
||||
|
||||
finalizers := obj.StringSlice("metadata", "finalizers")
|
||||
if len(finalizers) == 0 {
|
||||
finalizers = obj.StringSlice("spec", "finalizers")
|
||||
}
|
||||
|
||||
for _, cond := range conditions {
|
||||
if cond.Type() == "Removed" && (cond.Status() == "Unknown" || cond.Status() == "False") && cond.Message() != "" {
|
||||
summary.Message = append(summary.Message, cond.Message())
|
||||
}
|
||||
}
|
||||
|
||||
if len(finalizers) == 0 {
|
||||
return summary
|
||||
}
|
||||
|
||||
_, f := kv.RSplit(finalizers[0], "controller.cattle.io/")
|
||||
if f == "foregroundDeletion" {
|
||||
f = "object cleanup"
|
||||
}
|
||||
|
||||
summary.Message = append(summary.Message, "waiting on "+f)
|
||||
if i, err := convert.ToTimestamp(removed); err == nil {
|
||||
if time.Unix(i/1000, 0).Add(5 * time.Minute).Before(time.Now()) {
|
||||
summary.Error = true
|
||||
}
|
||||
}
|
||||
|
||||
return summary
|
||||
}
|
||||
|
||||
func checkLoadBalancer(obj data.Object, _ []Condition, summary Summary) Summary {
|
||||
if (summary.State == "active" || summary.State == "") &&
|
||||
obj.String("kind") == "Service" &&
|
||||
(obj.String("spec", "serviceKind") == "LoadBalancer" ||
|
||||
obj.String("spec", "type") == "LoadBalancer") {
|
||||
addresses := obj.Slice("status", "loadBalancer", "ingress")
|
||||
if len(addresses) == 0 {
|
||||
summary.State = "pending"
|
||||
summary.Transitioning = true
|
||||
summary.Message = append(summary.Message, "Load balancer is being provisioned")
|
||||
}
|
||||
}
|
||||
|
||||
return summary
|
||||
}
|
||||
|
||||
func isKind(obj data.Object, kind string, apiGroups ...string) bool {
|
||||
if obj.String("kind") != kind {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(apiGroups) == 0 {
|
||||
return obj.String("apiVersion") == "v1"
|
||||
}
|
||||
|
||||
if len(apiGroups) == 0 {
|
||||
apiGroups = []string{""}
|
||||
}
|
||||
|
||||
for _, group := range apiGroups {
|
||||
switch {
|
||||
case group == "":
|
||||
if obj.String("apiVersion") == "v1" {
|
||||
return true
|
||||
}
|
||||
case group[len(group)-1] == '/':
|
||||
if strings.HasPrefix(obj.String("apiVersion"), group) {
|
||||
return true
|
||||
}
|
||||
default:
|
||||
if obj.String("apiVersion") != group {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func checkApplyOwned(obj data.Object, conditions []Condition, summary Summary) Summary {
|
||||
if len(obj.Slice("metadata", "ownerReferences")) > 0 {
|
||||
return summary
|
||||
}
|
||||
|
||||
annotations := obj.Map("metadata", "annotations")
|
||||
gvkString := convert.ToString(annotations["objectset.rio.cattle.io/owner-gvk"])
|
||||
i := strings.Index(gvkString, kindSep)
|
||||
if i <= 0 {
|
||||
return summary
|
||||
}
|
||||
|
||||
name := convert.ToString(annotations["objectset.rio.cattle.io/owner-name"])
|
||||
namespace := convert.ToString(annotations["objectset.rio.cattle.io/owner-namespace"])
|
||||
|
||||
apiVersion := gvkString[:i]
|
||||
kind := gvkString[i+len(kindSep):]
|
||||
|
||||
rel := Relationship{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
Kind: kind,
|
||||
APIVersion: apiVersion,
|
||||
Type: "applies",
|
||||
Inbound: true,
|
||||
}
|
||||
|
||||
summary.Relationships = append(summary.Relationships, rel)
|
||||
|
||||
return summary
|
||||
}
|
||||
123
vendor/github.com/rancher/wrangler/pkg/summary/summary.go
generated
vendored
Normal file
123
vendor/github.com/rancher/wrangler/pkg/summary/summary.go
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
package summary
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/wrangler/pkg/data"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type Summary struct {
|
||||
State string
|
||||
Error bool
|
||||
Transitioning bool
|
||||
Message []string
|
||||
Attributes map[string]interface{}
|
||||
Relationships []Relationship
|
||||
}
|
||||
|
||||
type Relationship struct {
|
||||
Name string
|
||||
Namespace string
|
||||
ControlledBy bool
|
||||
Kind string
|
||||
APIVersion string
|
||||
Inbound bool
|
||||
Type string
|
||||
Selector *metav1.LabelSelector
|
||||
}
|
||||
|
||||
func (s Summary) String() string {
|
||||
if !s.Transitioning && !s.Error {
|
||||
return s.State
|
||||
}
|
||||
var msg string
|
||||
if s.Transitioning {
|
||||
msg = "[progressing"
|
||||
}
|
||||
if s.Error {
|
||||
if len(msg) > 0 {
|
||||
msg += ",error]"
|
||||
} else {
|
||||
msg = "error]"
|
||||
}
|
||||
} else {
|
||||
msg += "]"
|
||||
}
|
||||
if len(s.Message) > 0 {
|
||||
msg = msg + " " + s.Message[0]
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
func (s Summary) IsReady() bool {
|
||||
return !s.Error && !s.Transitioning
|
||||
}
|
||||
|
||||
func (s *Summary) DeepCopy() *Summary {
|
||||
v := *s
|
||||
return &v
|
||||
}
|
||||
|
||||
func (s *Summary) DeepCopyInto(v *Summary) {
|
||||
*v = *s
|
||||
}
|
||||
|
||||
func dedupMessage(messages []string) []string {
|
||||
if len(messages) <= 1 {
|
||||
return messages
|
||||
}
|
||||
|
||||
seen := map[string]bool{}
|
||||
var result []string
|
||||
|
||||
for _, message := range messages {
|
||||
message = strings.TrimSpace(message)
|
||||
if message == "" {
|
||||
continue
|
||||
}
|
||||
if seen[message] {
|
||||
continue
|
||||
}
|
||||
seen[message] = true
|
||||
result = append(result, message)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func Summarize(runtimeObj runtime.Object) Summary {
|
||||
var (
|
||||
obj data.Object
|
||||
summary Summary
|
||||
)
|
||||
|
||||
if s, ok := runtimeObj.(*SummarizedObject); ok {
|
||||
return s.Summary
|
||||
}
|
||||
|
||||
unstr, ok := runtimeObj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return summary
|
||||
}
|
||||
|
||||
if unstr != nil {
|
||||
obj = unstr.Object
|
||||
}
|
||||
|
||||
conditions := getConditions(obj)
|
||||
|
||||
for _, summarizer := range Summarizers {
|
||||
summary = summarizer(obj, conditions, summary)
|
||||
}
|
||||
|
||||
if summary.State == "" {
|
||||
summary.State = "active"
|
||||
}
|
||||
|
||||
summary.State = strings.ToLower(summary.State)
|
||||
summary.Message = dedupMessage(summary.Message)
|
||||
return summary
|
||||
}
|
||||
Reference in New Issue
Block a user