mirror of
https://github.com/ysoftdevs/gardener-extension-shoot-fleet-agent.git
synced 2026-04-25 09:49:11 +02:00
Initial v1.0.0 commit
This commit is contained in:
288
vendor/github.com/gardener/gardener-resource-manager/LICENSE.md
generated
vendored
Normal file
288
vendor/github.com/gardener/gardener-resource-manager/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,288 @@
|
||||
```
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
|
||||
## APIs
|
||||
|
||||
This project may include APIs to SAP or third party products or services. The use of these APIs, products and services may be subject to additional agreements. In no event shall the application of the Apache Software License, v.2 to this project grant any rights in or to these APIs, products or services that would alter, expand, be inconsistent with, or supersede any terms of these additional agreements. API means application programming interfaces, as well as their respective specifications and implementing code that allows other software products to communicate with or call on SAP or third party products or services (for example, SAP Enterprise Services, BAPIs, Idocs, RFCs and ABAP calls or other user exits) and may be made available through SAP or third party products, SDKs, documentation or other media.
|
||||
|
||||
## Subcomponents
|
||||
|
||||
This project includes the following subcomponents that are subject to separate license terms.
|
||||
Your use of these subcomponents is subject to the separate license terms applicable to
|
||||
each subcomponent.
|
||||
|
||||
Gardener.
|
||||
https://github.com/gardener/gardener.
|
||||
Copyright (c) 2019 SAP SE or an SAP affiliate company.
|
||||
Apache 2 license (https://github.com/gardener/gardener/blob/master/LICENSE.md).
|
||||
|
||||
controller-runtime.
|
||||
https://sigs.k8s.io/controller-runtime.
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Apache 2 license (https://sigs.k8s.io/controller-runtime/LICENSE).
|
||||
|
||||
API.
|
||||
https://git.k8s.io/api.
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Apache 2 license (https://git.k8s.io/api/LICENSE).
|
||||
|
||||
APIMachinery.
|
||||
https://git.k8s.io/apimachinery.
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Apache 2 license (https://git.k8s.io/apimachinery/LICENSE).
|
||||
|
||||
Client-Go.
|
||||
https://git.k8s.io/client-go.
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
Apache 2 license (https://git.k8s.io/client-go/LICENSE).
|
||||
|
||||
YAML marshaling and unmarshalling support for Go.
|
||||
gopkg.in/yaml.v2.
|
||||
Copyright 2011-2016 Canonical Ltd.
|
||||
Apache 2 license (https://github.com/go-yaml/yaml/blob/v2/LICENSE)
|
||||
|
||||
Packr.
|
||||
https://github.com/gobuffalo/packr
|
||||
Copyright (c) 2016 Mark Bates.
|
||||
MIT license (https://github.com/gobuffalo/packr/blob/master/LICENSE.txt)
|
||||
|
||||
Cobra.
|
||||
https://github.com/spf13/cobra
|
||||
Copyright 2019 Steve Francia.
|
||||
Apache 2 license (https://github.com/spf13/cobra/blob/master/LICENSE.txt)
|
||||
|
||||
Ginkgo.
|
||||
https://github.com/onsi/ginkgo.
|
||||
Copyright (c) 2013-2014 Onsi Fakhouri.
|
||||
MIT license (https://github.com/onsi/ginkgo/blob/master/LICENSE)
|
||||
|
||||
Gomega.
|
||||
github.com/onsi/gomega.
|
||||
Copyright (c) 2013-2014 Onsi Fakhouri.
|
||||
MIT license (https://github.com/onsi/gomega/blob/master/LICENSE)
|
||||
|
||||
------
|
||||
## MIT License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) <year> <owner>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
15
vendor/github.com/gardener/gardener-resource-manager/NOTICE.md
generated
vendored
Normal file
15
vendor/github.com/gardener/gardener-resource-manager/NOTICE.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
## Gardener Resource Manager
|
||||
Copyright (c) 2017-2019 SAP SE or an SAP affiliate company. All rights reserved.
|
||||
|
||||
## Seed Source
|
||||
|
||||
The source code of this component was seeded based on a copy of the following files from [github.com/kubernetes-sigs](github.com/kubernetes-sigs):
|
||||
|
||||
controller-runtime.
|
||||
https://sigs.k8s.io/controller-runtime.
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Apache 2 license (https://sigs.k8s.io/controller-runtime/LICENSE).
|
||||
|
||||
Version: 0.1.9.
|
||||
Commit-ID: f6f0bc9611363b43664d08fb097ab13243ef621d
|
||||
Commit-Message: Merge pull request #263 from DirectXMan12/release/v0.1.9
|
||||
18
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/register.go
generated
vendored
Normal file
18
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/register.go
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package resources
|
||||
|
||||
// GroupName is the group name use in this package
|
||||
const GroupName = "resources.gardener.cloud"
|
||||
24
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1/doc.go
generated
vendored
Normal file
24
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1/doc.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
|
||||
//
|
||||
// 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.
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:conversion-gen=github.com/gardener/gardener-resource-manager/pkg/apis/resources
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
|
||||
//go:generate ../../../../hack/update-codegen.sh
|
||||
|
||||
// Package v1alpha1 contains the configuration of the Gardener Resource Manager.
|
||||
// +groupName=resources.gardener.cloud
|
||||
package v1alpha1 // import "github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1"
|
||||
51
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1/register.go
generated
vendored
Normal file
51
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1/register.go
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
resources "github.com/gardener/gardener-resource-manager/pkg/apis/resources"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: resources.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,
|
||||
&ManagedResource{},
|
||||
&ManagedResourceList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
||||
170
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1/types.go
generated
vendored
Normal file
170
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1/types.go
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
// Ignore is an annotation that dictates whether a resources should be ignored during
|
||||
// reconciliation.
|
||||
Ignore = "resources.gardener.cloud/ignore"
|
||||
// DeleteOnInvalidUpdate is a constant for an annotation on a resource managed by a ManagedResource. If set to
|
||||
// true then the controller will delete the object in case it faces an "Invalid" response during an update operation.
|
||||
DeleteOnInvalidUpdate = "resources.gardener.cloud/delete-on-invalid-update"
|
||||
// KeepObject is a constant for an annotation on a resource managed by a ManagedResource. If set to
|
||||
// true then the controller will not delete the object in case it is removed from the ManagedResource or the
|
||||
// ManagedResource itself is deleted.
|
||||
KeepObject = "resources.gardener.cloud/keep-object"
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ManagedResource describes a list of managed resources.
|
||||
type ManagedResource struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard object metadata.
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
// Spec contains the specification of this managed resource.
|
||||
Spec ManagedResourceSpec `json:"spec,omitempty"`
|
||||
// Status contains the status of this managed resource.
|
||||
Status ManagedResourceStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ManagedResourceList is a list of ManagedResource resources.
|
||||
type ManagedResourceList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// +optional
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Items is the list of ManagedResource.
|
||||
Items []ManagedResource `json:"items"`
|
||||
}
|
||||
|
||||
type ManagedResourceSpec struct {
|
||||
// Class holds the resource class used to control the responsibility for multiple resource manager instances
|
||||
// +optional
|
||||
Class *string `json:"class,omitempty"`
|
||||
// SecretRefs is a list of secret references.
|
||||
SecretRefs []corev1.LocalObjectReference `json:"secretRefs"`
|
||||
// InjectLabels injects the provided labels into every resource that is part of the referenced secrets.
|
||||
// +optional
|
||||
InjectLabels map[string]string `json:"injectLabels,omitempty"`
|
||||
// ForceOverwriteLabels specifies that all existing labels should be overwritten. Defaults to false.
|
||||
// +optional
|
||||
ForceOverwriteLabels *bool `json:"forceOverwriteLabels,omitempty"`
|
||||
// ForceOverwriteAnnotations specifies that all existing annotations should be overwritten. Defaults to false.
|
||||
// +optional
|
||||
ForceOverwriteAnnotations *bool `json:"forceOverwriteAnnotations,omitempty"`
|
||||
// KeepObjects specifies whether the objects should be kept although the managed resource has already been deleted.
|
||||
// Defaults to false.
|
||||
// +optional
|
||||
KeepObjects *bool `json:"keepObjects,omitempty"`
|
||||
// Equivalences specifies possible group/kind equivalences for objects.
|
||||
// +optional
|
||||
Equivalences [][]metav1.GroupKind `json:"equivalences,omitempty"`
|
||||
// DeletePersistentVolumeClaims specifies if PersistentVolumeClaims created by StatefulSets, which are managed by this
|
||||
// resource, should also be deleted when the corresponding StatefulSet is deleted (defaults to false).
|
||||
// +optional
|
||||
DeletePersistentVolumeClaims *bool `json:"deletePersistentVolumeClaims,omitempty"`
|
||||
}
|
||||
|
||||
// ManagedResourceStatus is the status of a managed resource.
|
||||
type ManagedResourceStatus struct {
|
||||
Conditions []ManagedResourceCondition `json:"conditions,omitempty"`
|
||||
// ObservedGeneration is the most recent generation observed for this resource.
|
||||
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
|
||||
// Resources is a list of objects that have been created.
|
||||
// +optional
|
||||
Resources []ObjectReference `json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
type ObjectReference struct {
|
||||
corev1.ObjectReference `json:",inline"`
|
||||
// Labels is a map of labels that were used during last update of the resource.
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
// Annotations is a map of annotations that were used during last update of the resource.
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
}
|
||||
|
||||
// ConditionType is the type of a condition.
|
||||
type ConditionType string
|
||||
|
||||
const (
|
||||
// ResourcesApplied is a condition type that indicates whether all resources are applied to the target cluster.
|
||||
ResourcesApplied ConditionType = "ResourcesApplied"
|
||||
// ResourcesHealthy is a condition type that indicates whether all resources are present and healthy.
|
||||
ResourcesHealthy ConditionType = "ResourcesHealthy"
|
||||
)
|
||||
|
||||
// ConditionStatus is the status of a condition.
|
||||
type ConditionStatus string
|
||||
|
||||
// These are valid condition statuses.
|
||||
const (
|
||||
// ConditionTrue means a resource is in the condition.
|
||||
ConditionTrue ConditionStatus = "True"
|
||||
// ConditionFalse means a resource is not in the condition.
|
||||
ConditionFalse ConditionStatus = "False"
|
||||
// ConditionUnknown means that the controller can't decide if a resource is in the condition or not
|
||||
ConditionUnknown ConditionStatus = "Unknown"
|
||||
// ConditionProgressing means that the controller is currently acting on the resource and the condition is therefore progressing.
|
||||
ConditionProgressing ConditionStatus = "Progressing"
|
||||
)
|
||||
|
||||
// These are well-known reasons for ManagedResourceConditions.
|
||||
const (
|
||||
// ConditionApplySucceeded indicates that the `ResourcesApplied` condition is `True`,
|
||||
// because all resources have been applied successfully.
|
||||
ConditionApplySucceeded = "ApplySucceeded"
|
||||
// ConditionApplyFailed indicates that the `ResourcesApplied` condition is `False`,
|
||||
// because applying the resources failed.
|
||||
ConditionApplyFailed = "ApplyFailed"
|
||||
// ConditionDecodingFailed indicates that the `ResourcesApplied` condition is `False`,
|
||||
// because decoding the resources of the ManagedResource failed.
|
||||
ConditionDecodingFailed = "DecodingFailed"
|
||||
// ConditionApplyProgressing indicates that the `ResourcesApplied` condition is `Progressing`,
|
||||
// because the resources are currently being reconciled.
|
||||
ConditionApplyProgressing = "ApplyProgressing"
|
||||
// ConditionDeletionFailed indicates that the `ResourcesApplied` condition is `False`,
|
||||
// because deleting the resources failed.
|
||||
ConditionDeletionFailed = "DeletionFailed"
|
||||
// ConditionDeletionPending indicates that the `ResourcesApplied` condition is `Progressing`,
|
||||
// because the deletion of some resources are still pending.
|
||||
ConditionDeletionPending = "DeletionPending"
|
||||
// ConditionHealthChecksPending indicates that the `ResourcesHealthy` condition is `Unknown`,
|
||||
// because the health checks have not been completely executed yet for the current set of resources.
|
||||
ConditionHealthChecksPending = "HealthChecksPending"
|
||||
)
|
||||
|
||||
// ManagedResourceCondition describes the state of a deployment at a certain period.
|
||||
type ManagedResourceCondition struct {
|
||||
// Type of the ManagedResource condition.
|
||||
Type ConditionType `json:"type"`
|
||||
// Status of the ManagedResource condition.
|
||||
Status ConditionStatus `json:"status"`
|
||||
// Last time the condition was updated.
|
||||
LastUpdateTime metav1.Time `json:"lastUpdateTime"`
|
||||
// Last time the condition transitioned from one status to another.
|
||||
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
|
||||
// The reason for the condition's last transition.
|
||||
Reason string `json:"reason"`
|
||||
// A human readable message indicating details about the transition.
|
||||
Message string `json:"message"`
|
||||
}
|
||||
231
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
231
vendor/github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ManagedResource) DeepCopyInto(out *ManagedResource) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedResource.
|
||||
func (in *ManagedResource) DeepCopy() *ManagedResource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ManagedResource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ManagedResource) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ManagedResourceCondition) DeepCopyInto(out *ManagedResourceCondition) {
|
||||
*out = *in
|
||||
in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime)
|
||||
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedResourceCondition.
|
||||
func (in *ManagedResourceCondition) DeepCopy() *ManagedResourceCondition {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ManagedResourceCondition)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ManagedResourceList) DeepCopyInto(out *ManagedResourceList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]ManagedResource, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedResourceList.
|
||||
func (in *ManagedResourceList) DeepCopy() *ManagedResourceList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ManagedResourceList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ManagedResourceList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ManagedResourceSpec) DeepCopyInto(out *ManagedResourceSpec) {
|
||||
*out = *in
|
||||
if in.Class != nil {
|
||||
in, out := &in.Class, &out.Class
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.SecretRefs != nil {
|
||||
in, out := &in.SecretRefs, &out.SecretRefs
|
||||
*out = make([]v1.LocalObjectReference, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.InjectLabels != nil {
|
||||
in, out := &in.InjectLabels, &out.InjectLabels
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.ForceOverwriteLabels != nil {
|
||||
in, out := &in.ForceOverwriteLabels, &out.ForceOverwriteLabels
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.ForceOverwriteAnnotations != nil {
|
||||
in, out := &in.ForceOverwriteAnnotations, &out.ForceOverwriteAnnotations
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.KeepObjects != nil {
|
||||
in, out := &in.KeepObjects, &out.KeepObjects
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.Equivalences != nil {
|
||||
in, out := &in.Equivalences, &out.Equivalences
|
||||
*out = make([][]metav1.GroupKind, len(*in))
|
||||
for i := range *in {
|
||||
if (*in)[i] != nil {
|
||||
in, out := &(*in)[i], &(*out)[i]
|
||||
*out = make([]metav1.GroupKind, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
}
|
||||
if in.DeletePersistentVolumeClaims != nil {
|
||||
in, out := &in.DeletePersistentVolumeClaims, &out.DeletePersistentVolumeClaims
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedResourceSpec.
|
||||
func (in *ManagedResourceSpec) DeepCopy() *ManagedResourceSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ManagedResourceSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ManagedResourceStatus) DeepCopyInto(out *ManagedResourceStatus) {
|
||||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]ManagedResourceCondition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.Resources != nil {
|
||||
in, out := &in.Resources, &out.Resources
|
||||
*out = make([]ObjectReference, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedResourceStatus.
|
||||
func (in *ManagedResourceStatus) DeepCopy() *ManagedResourceStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ManagedResourceStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ObjectReference) DeepCopyInto(out *ObjectReference) {
|
||||
*out = *in
|
||||
out.ObjectReference = in.ObjectReference
|
||||
if in.Labels != nil {
|
||||
in, out := &in.Labels, &out.Labels
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.Annotations != nil {
|
||||
in, out := &in.Annotations, &out.Annotations
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectReference.
|
||||
func (in *ObjectReference) DeepCopy() *ObjectReference {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ObjectReference)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
120
vendor/github.com/gardener/gardener-resource-manager/pkg/manager/managedresources.go
generated
vendored
Normal file
120
vendor/github.com/gardener/gardener-resource-manager/pkg/manager/managedresources.go
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package manager
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
resourcesv1alpha1 "github.com/gardener/gardener-resource-manager/pkg/apis/resources/v1alpha1"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
)
|
||||
|
||||
type ManagedResource struct {
|
||||
client client.Client
|
||||
resource *resourcesv1alpha1.ManagedResource
|
||||
}
|
||||
|
||||
func NewManagedResource(client client.Client) *ManagedResource {
|
||||
return &ManagedResource{
|
||||
client: client,
|
||||
resource: &resourcesv1alpha1.ManagedResource{},
|
||||
}
|
||||
}
|
||||
|
||||
func (m *ManagedResource) WithNamespacedName(namespace, name string) *ManagedResource {
|
||||
m.resource.Namespace = namespace
|
||||
m.resource.Name = name
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) WithLabels(labels map[string]string) *ManagedResource {
|
||||
m.resource.Labels = labels
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) WithAnnotations(annotations map[string]string) *ManagedResource {
|
||||
m.resource.Annotations = annotations
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) WithClass(name string) *ManagedResource {
|
||||
if name == "" {
|
||||
m.resource.Spec.Class = nil
|
||||
} else {
|
||||
m.resource.Spec.Class = &name
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) WithSecretRef(secretRefName string) *ManagedResource {
|
||||
m.resource.Spec.SecretRefs = append(m.resource.Spec.SecretRefs, corev1.LocalObjectReference{Name: secretRefName})
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) WithSecretRefs(secretRefs []corev1.LocalObjectReference) *ManagedResource {
|
||||
m.resource.Spec.SecretRefs = append(m.resource.Spec.SecretRefs, secretRefs...)
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) WithInjectedLabels(labelsToInject map[string]string) *ManagedResource {
|
||||
m.resource.Spec.InjectLabels = labelsToInject
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) ForceOverwriteAnnotations(v bool) *ManagedResource {
|
||||
m.resource.Spec.ForceOverwriteAnnotations = &v
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) ForceOverwriteLabels(v bool) *ManagedResource {
|
||||
m.resource.Spec.ForceOverwriteLabels = &v
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) KeepObjects(v bool) *ManagedResource {
|
||||
m.resource.Spec.KeepObjects = &v
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) DeletePersistentVolumeClaims(v bool) *ManagedResource {
|
||||
m.resource.Spec.DeletePersistentVolumeClaims = &v
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *ManagedResource) Reconcile(ctx context.Context) error {
|
||||
resource := &resourcesv1alpha1.ManagedResource{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: m.resource.Name, Namespace: m.resource.Namespace},
|
||||
}
|
||||
|
||||
_, err := controllerutil.CreateOrUpdate(ctx, m.client, resource, func() error {
|
||||
resource.Labels = m.resource.Labels
|
||||
resource.Annotations = m.resource.Annotations
|
||||
resource.Spec = m.resource.Spec
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *ManagedResource) Delete(ctx context.Context) error {
|
||||
if err := m.client.Delete(ctx, m.resource); err != nil && !apierrors.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
124
vendor/github.com/gardener/gardener-resource-manager/pkg/manager/managedsecrets.go
generated
vendored
Normal file
124
vendor/github.com/gardener/gardener-resource-manager/pkg/manager/managedsecrets.go
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package manager
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
)
|
||||
|
||||
type Secret struct {
|
||||
client client.Client
|
||||
|
||||
keyValues map[string]string
|
||||
secret *corev1.Secret
|
||||
}
|
||||
|
||||
func NewSecret(client client.Client) *Secret {
|
||||
return &Secret{
|
||||
client: client,
|
||||
keyValues: make(map[string]string),
|
||||
secret: &corev1.Secret{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Secret) WithNamespacedName(namespace, name string) *Secret {
|
||||
s.secret.Namespace = namespace
|
||||
s.secret.Name = name
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Secret) WithLabels(labels map[string]string) *Secret {
|
||||
s.secret.Labels = labels
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Secret) WithAnnotations(annotations map[string]string) *Secret {
|
||||
s.secret.Annotations = annotations
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Secret) WithKeyValues(keyValues map[string][]byte) *Secret {
|
||||
s.secret.Data = keyValues
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Secret) Reconcile(ctx context.Context) error {
|
||||
secret := &corev1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: s.secret.Name, Namespace: s.secret.Namespace},
|
||||
}
|
||||
|
||||
_, err := controllerutil.CreateOrUpdate(ctx, s.client, secret, func() error {
|
||||
secret.Labels = s.secret.Labels
|
||||
secret.Annotations = s.secret.Annotations
|
||||
secret.Type = corev1.SecretTypeOpaque
|
||||
secret.Data = s.secret.Data
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Secret) Delete(ctx context.Context) error {
|
||||
if err := s.client.Delete(ctx, s.secret); err != nil && !apierrors.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Secrets struct {
|
||||
client client.Client
|
||||
|
||||
secrets []Secret
|
||||
}
|
||||
|
||||
func NewSecrets(client client.Client) *Secrets {
|
||||
return &Secrets{
|
||||
client: client,
|
||||
secrets: []Secret{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Secrets) WithSecretList(secrets []Secret) *Secrets {
|
||||
s.secrets = append(s.secrets, secrets...)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Secrets) WithSecret(secrets Secret) *Secrets {
|
||||
s.secrets = append(s.secrets, secrets)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Secrets) Reconcile(ctx context.Context) error {
|
||||
for _, secret := range s.secrets {
|
||||
if err := secret.Reconcile(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Secrets) Delete(ctx context.Context) error {
|
||||
for _, secret := range s.secrets {
|
||||
if err := secret.Delete(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user