This is a huge commit, it does following things: (#1942)
1. Remove ks-iam standalone binary, move it to ks-apiserver 2. Generate all devops apis inside kubesphere repository, no need to import s2ioperator. 3. Reorganize ldap code, make it more flexible to use.
This commit is contained in:
294
vendor/github.com/globalsign/mgo/bson/bson_corpus_spec_test_generator.go
generated
vendored
294
vendor/github.com/globalsign/mgo/bson/bson_corpus_spec_test_generator.go
generated
vendored
@@ -1,294 +0,0 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/globalsign/mgo/internal/json"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFlags(0)
|
||||
log.SetPrefix(name + ": ")
|
||||
|
||||
var g Generator
|
||||
|
||||
fmt.Fprintf(&g, "// Code generated by \"%s.go\"; DO NOT EDIT\n\n", name)
|
||||
|
||||
src := g.generate()
|
||||
|
||||
err := ioutil.WriteFile(fmt.Sprintf("%s.go", strings.TrimSuffix(name, "_generator")), src, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("writing output: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Generator holds the state of the analysis. Primarily used to buffer
|
||||
// the output for format.Source.
|
||||
type Generator struct {
|
||||
bytes.Buffer // Accumulated output.
|
||||
}
|
||||
|
||||
// format returns the gofmt-ed contents of the Generator's buffer.
|
||||
func (g *Generator) format() []byte {
|
||||
src, err := format.Source(g.Bytes())
|
||||
if err != nil {
|
||||
// Should never happen, but can arise when developing this code.
|
||||
// The user can compile the output to see the error.
|
||||
log.Printf("warning: internal error: invalid Go generated: %s", err)
|
||||
log.Printf("warning: compile the package to analyze the error")
|
||||
return g.Bytes()
|
||||
}
|
||||
return src
|
||||
}
|
||||
|
||||
// EVERYTHING ABOVE IS CONSTANT BETWEEN THE GENERATORS
|
||||
|
||||
const name = "bson_corpus_spec_test_generator"
|
||||
|
||||
func (g *Generator) generate() []byte {
|
||||
|
||||
testFiles, err := filepath.Glob("./specdata/specifications/source/bson-corpus/tests/*.json")
|
||||
if err != nil {
|
||||
log.Fatalf("error reading bson-corpus files: %s", err)
|
||||
}
|
||||
|
||||
tests, err := g.loadTests(testFiles)
|
||||
if err != nil {
|
||||
log.Fatalf("error loading tests: %s", err)
|
||||
}
|
||||
|
||||
tmpl, err := g.getTemplate()
|
||||
if err != nil {
|
||||
log.Fatalf("error loading template: %s", err)
|
||||
}
|
||||
|
||||
tmpl.Execute(&g.Buffer, tests)
|
||||
|
||||
return g.format()
|
||||
}
|
||||
|
||||
func (g *Generator) loadTests(filenames []string) ([]*testDef, error) {
|
||||
var tests []*testDef
|
||||
for _, filename := range filenames {
|
||||
test, err := g.loadTest(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tests = append(tests, test)
|
||||
}
|
||||
|
||||
return tests, nil
|
||||
}
|
||||
|
||||
func (g *Generator) loadTest(filename string) (*testDef, error) {
|
||||
content, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var testDef testDef
|
||||
err = json.Unmarshal(content, &testDef)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
names := make(map[string]struct{})
|
||||
|
||||
for i := len(testDef.Valid) - 1; i >= 0; i-- {
|
||||
if testDef.BsonType == "0x05" && testDef.Valid[i].Description == "subtype 0x02" {
|
||||
testDef.Valid = append(testDef.Valid[:i], testDef.Valid[i+1:]...)
|
||||
continue
|
||||
}
|
||||
|
||||
name := cleanupFuncName(testDef.Description + "_" + testDef.Valid[i].Description)
|
||||
nameIdx := name
|
||||
j := 1
|
||||
for {
|
||||
if _, ok := names[nameIdx]; !ok {
|
||||
break
|
||||
}
|
||||
|
||||
nameIdx = fmt.Sprintf("%s_%d", name, j)
|
||||
}
|
||||
|
||||
names[nameIdx] = struct{}{}
|
||||
|
||||
testDef.Valid[i].TestDef = &testDef
|
||||
testDef.Valid[i].Name = nameIdx
|
||||
testDef.Valid[i].StructTest = testDef.TestKey != "" &&
|
||||
(testDef.BsonType != "0x05" || strings.Contains(testDef.Valid[i].Description, "0x00")) &&
|
||||
!testDef.Deprecated
|
||||
}
|
||||
|
||||
for i := len(testDef.DecodeErrors) - 1; i >= 0; i-- {
|
||||
if strings.Contains(testDef.DecodeErrors[i].Description, "UTF-8") {
|
||||
testDef.DecodeErrors = append(testDef.DecodeErrors[:i], testDef.DecodeErrors[i+1:]...)
|
||||
continue
|
||||
}
|
||||
|
||||
name := cleanupFuncName(testDef.Description + "_" + testDef.DecodeErrors[i].Description)
|
||||
nameIdx := name
|
||||
j := 1
|
||||
for {
|
||||
if _, ok := names[nameIdx]; !ok {
|
||||
break
|
||||
}
|
||||
|
||||
nameIdx = fmt.Sprintf("%s_%d", name, j)
|
||||
}
|
||||
names[nameIdx] = struct{}{}
|
||||
|
||||
testDef.DecodeErrors[i].Name = nameIdx
|
||||
}
|
||||
|
||||
return &testDef, nil
|
||||
}
|
||||
|
||||
func (g *Generator) getTemplate() (*template.Template, error) {
|
||||
content := `package bson_test
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"time"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
"github.com/globalsign/mgo/bson"
|
||||
)
|
||||
|
||||
func testValid(c *C, in []byte, expected []byte, result interface{}) {
|
||||
err := bson.Unmarshal(in, result)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
out, err := bson.Marshal(result)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
c.Assert(string(expected), Equals, string(out), Commentf("roundtrip failed for %T, expected '%x' but got '%x'", result, expected, out))
|
||||
}
|
||||
|
||||
func testDecodeSkip(c *C, in []byte) {
|
||||
err := bson.Unmarshal(in, &struct{}{})
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
func testDecodeError(c *C, in []byte, result interface{}) {
|
||||
err := bson.Unmarshal(in, result)
|
||||
c.Assert(err, Not(IsNil))
|
||||
}
|
||||
|
||||
{{range .}}
|
||||
{{range .Valid}}
|
||||
func (s *S) Test{{.Name}}(c *C) {
|
||||
b, err := hex.DecodeString("{{.Bson}}")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
{{if .CanonicalBson}}
|
||||
cb, err := hex.DecodeString("{{.CanonicalBson}}")
|
||||
c.Assert(err, IsNil)
|
||||
{{else}}
|
||||
cb := b
|
||||
{{end}}
|
||||
|
||||
var resultD bson.D
|
||||
testValid(c, b, cb, &resultD)
|
||||
{{if .StructTest}}var resultS struct {
|
||||
Element {{.TestDef.GoType}} ` + "`bson:\"{{.TestDef.TestKey}}\"`" + `
|
||||
}
|
||||
testValid(c, b, cb, &resultS){{end}}
|
||||
|
||||
testDecodeSkip(c, b)
|
||||
}
|
||||
{{end}}
|
||||
|
||||
{{range .DecodeErrors}}
|
||||
func (s *S) Test{{.Name}}(c *C) {
|
||||
b, err := hex.DecodeString("{{.Bson}}")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
var resultD bson.D
|
||||
testDecodeError(c, b, &resultD)
|
||||
}
|
||||
{{end}}
|
||||
{{end}}
|
||||
`
|
||||
tmpl, err := template.New("").Parse(content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tmpl, nil
|
||||
}
|
||||
|
||||
func cleanupFuncName(name string) string {
|
||||
return strings.Map(func(r rune) rune {
|
||||
if (r >= 48 && r <= 57) || (r >= 65 && r <= 90) || (r >= 97 && r <= 122) {
|
||||
return r
|
||||
}
|
||||
return '_'
|
||||
}, name)
|
||||
}
|
||||
|
||||
type testDef struct {
|
||||
Description string `json:"description"`
|
||||
BsonType string `json:"bson_type"`
|
||||
TestKey string `json:"test_key"`
|
||||
Valid []*valid `json:"valid"`
|
||||
DecodeErrors []*decodeError `json:"decodeErrors"`
|
||||
Deprecated bool `json:"deprecated"`
|
||||
}
|
||||
|
||||
func (t *testDef) GoType() string {
|
||||
switch t.BsonType {
|
||||
case "0x01":
|
||||
return "float64"
|
||||
case "0x02":
|
||||
return "string"
|
||||
case "0x03":
|
||||
return "bson.D"
|
||||
case "0x04":
|
||||
return "[]interface{}"
|
||||
case "0x05":
|
||||
return "[]byte"
|
||||
case "0x07":
|
||||
return "bson.ObjectId"
|
||||
case "0x08":
|
||||
return "bool"
|
||||
case "0x09":
|
||||
return "time.Time"
|
||||
case "0x0E":
|
||||
return "string"
|
||||
case "0x10":
|
||||
return "int32"
|
||||
case "0x12":
|
||||
return "int64"
|
||||
case "0x13":
|
||||
return "bson.Decimal"
|
||||
default:
|
||||
return "interface{}"
|
||||
}
|
||||
}
|
||||
|
||||
type valid struct {
|
||||
Description string `json:"description"`
|
||||
Bson string `json:"bson"`
|
||||
CanonicalBson string `json:"canonical_bson"`
|
||||
|
||||
Name string
|
||||
StructTest bool
|
||||
TestDef *testDef
|
||||
}
|
||||
|
||||
type decodeError struct {
|
||||
Description string `json:"description"`
|
||||
Bson string `json:"bson"`
|
||||
|
||||
Name string
|
||||
}
|
||||
3
vendor/github.com/go-logr/zapr/.gitignore
generated
vendored
3
vendor/github.com/go-logr/zapr/.gitignore
generated
vendored
@@ -1,3 +0,0 @@
|
||||
*~
|
||||
*.swp
|
||||
/vendor
|
||||
52
vendor/github.com/go-logr/zapr/Gopkg.lock
generated
vendored
52
vendor/github.com/go-logr/zapr/Gopkg.lock
generated
vendored
@@ -1,52 +0,0 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
digest = "1:edd2fa4578eb086265db78a9201d15e76b298dfd0d5c379da83e9c61712cf6df"
|
||||
name = "github.com/go-logr/logr"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "9fb12b3b21c5415d16ac18dc5cd42c1cfdd40c4e"
|
||||
version = "v0.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:3c1a69cdae3501bf75e76d0d86dc6f2b0a7421bc205c0cb7b96b19eed464a34d"
|
||||
name = "go.uber.org/atomic"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "1ea20fb1cbb1cc08cbd0d913a96dead89aa18289"
|
||||
version = "v1.3.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:60bf2a5e347af463c42ed31a493d817f8a72f102543060ed992754e689805d1a"
|
||||
name = "go.uber.org/multierr"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "3c4937480c32f4c13a875a1829af76c98ca3d40a"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:9580b1b079114140ade8cec957685344d14f00119e0241f6b369633cb346eeb3"
|
||||
name = "go.uber.org/zap"
|
||||
packages = [
|
||||
".",
|
||||
"buffer",
|
||||
"internal/bufferpool",
|
||||
"internal/color",
|
||||
"internal/exit",
|
||||
"zapcore",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "eeedf312bc6c57391d84767a4cd413f02a917974"
|
||||
version = "v1.8.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
input-imports = [
|
||||
"github.com/go-logr/logr",
|
||||
"go.uber.org/zap",
|
||||
"go.uber.org/zap/zapcore",
|
||||
]
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
38
vendor/github.com/go-logr/zapr/Gopkg.toml
generated
vendored
38
vendor/github.com/go-logr/zapr/Gopkg.toml
generated
vendored
@@ -1,38 +0,0 @@
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project2"
|
||||
# branch = "dev"
|
||||
# source = "github.com/myfork/project2"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
#
|
||||
# [prune]
|
||||
# non-go = false
|
||||
# go-tests = true
|
||||
# unused-packages = true
|
||||
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/go-logr/logr"
|
||||
version = "0.1.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "go.uber.org/zap"
|
||||
version = "1.8.0"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
201
vendor/github.com/go-logr/zapr/LICENSE
generated
vendored
201
vendor/github.com/go-logr/zapr/LICENSE
generated
vendored
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
45
vendor/github.com/go-logr/zapr/README.md
generated
vendored
45
vendor/github.com/go-logr/zapr/README.md
generated
vendored
@@ -1,45 +0,0 @@
|
||||
Zapr :zap:
|
||||
==========
|
||||
|
||||
A [logr](https://github.com/go-logr/logr) implementation using
|
||||
[Zap](go.uber.org/zap).
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
```go
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/directxman12/zapr"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var log logr.Logger
|
||||
|
||||
zapLog, err := zap.NewDevelopment()
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("who watches the watchmen (%v)?", err))
|
||||
}
|
||||
log = zapr.NewLogger(zapLog)
|
||||
|
||||
log.Info("Logr in action!", "the answer", 42)
|
||||
}
|
||||
```
|
||||
|
||||
Implementation Details
|
||||
----------------------
|
||||
|
||||
For the most part, concepts in Zap correspond directly with those in logr.
|
||||
|
||||
Unlike Zap, all fields *must* be in the form of suggared fields --
|
||||
it's illegal to pass a strongly-typed Zap field in a key position to any
|
||||
of the logging methods (`Log`, `Error`).
|
||||
|
||||
Levels in logr correspond to custom debug levels in Zap. Any given level
|
||||
in logr is represents by its inverse in Zap (`zapLevel = -1*logrLevel`).
|
||||
|
||||
For example `V(2)` is equivalent to log level -2 in Zap, while `V(1)` is
|
||||
equivalent to Zap's `DebugLevel`.
|
||||
163
vendor/github.com/go-logr/zapr/zapr.go
generated
vendored
163
vendor/github.com/go-logr/zapr/zapr.go
generated
vendored
@@ -1,163 +0,0 @@
|
||||
// Copyright 2018 Solly Ross
|
||||
//
|
||||
// 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 zapr defines an implementation of the github.com/go-logr/logr
|
||||
// interfaces built on top of Zap (go.uber.org/zap).
|
||||
//
|
||||
// Usage
|
||||
//
|
||||
// A new logr.Logger can be constructed from an existing zap.Logger using
|
||||
// the NewLogger function:
|
||||
//
|
||||
// log := zapr.NewLogger(someZapLogger)
|
||||
//
|
||||
// Implementation Details
|
||||
//
|
||||
// For the most part, concepts in Zap correspond directly with those in
|
||||
// logr.
|
||||
//
|
||||
// Unlike Zap, all fields *must* be in the form of suggared fields --
|
||||
// it's illegal to pass a strongly-typed Zap field in a key position
|
||||
// to any of the log methods.
|
||||
//
|
||||
// Levels in logr correspond to custom debug levels in Zap. Any given level
|
||||
// in logr is represents by its inverse in zap (`zapLevel = -1*logrLevel`).
|
||||
// For example V(2) is equivalent to log level -2 in Zap, while V(1) is
|
||||
// equivalent to Zap's DebugLevel.
|
||||
package zapr
|
||||
|
||||
import (
|
||||
"github.com/go-logr/logr"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
// noopInfoLogger is a logr.InfoLogger that's always disabled, and does nothing.
|
||||
type noopInfoLogger struct{}
|
||||
|
||||
func (l *noopInfoLogger) Enabled() bool { return false }
|
||||
func (l *noopInfoLogger) Info(_ string, _ ...interface{}) {}
|
||||
|
||||
var disabledInfoLogger = &noopInfoLogger{}
|
||||
|
||||
// NB: right now, we always use the equivalent of sugared logging.
|
||||
// This is necessary, since logr doesn't define non-suggared types,
|
||||
// and using zap-specific non-suggared types would make uses tied
|
||||
// directly to Zap.
|
||||
|
||||
// infoLogger is a logr.InfoLogger that uses Zap to log at a particular
|
||||
// level. The level has already been converted to a Zap level, which
|
||||
// is to say that `logrLevel = -1*zapLevel`.
|
||||
type infoLogger struct {
|
||||
lvl zapcore.Level
|
||||
l *zap.Logger
|
||||
}
|
||||
|
||||
func (l *infoLogger) Enabled() bool { return true }
|
||||
func (l *infoLogger) Info(msg string, keysAndVals ...interface{}) {
|
||||
if checkedEntry := l.l.Check(l.lvl, msg); checkedEntry != nil {
|
||||
checkedEntry.Write(handleFields(l.l, keysAndVals)...)
|
||||
}
|
||||
}
|
||||
|
||||
// zapLogger is a logr.Logger that uses Zap to log.
|
||||
type zapLogger struct {
|
||||
// NB: this looks very similar to zap.SugaredLogger, but
|
||||
// deals with our desire to have multiple verbosity levels.
|
||||
l *zap.Logger
|
||||
infoLogger
|
||||
}
|
||||
|
||||
// handleFields converts a bunch of arbitrary key-value pairs into Zap fields. It takes
|
||||
// additional pre-converted Zap fields, for use with automatically attached fields, like
|
||||
// `error`.
|
||||
func handleFields(l *zap.Logger, args []interface{}, additional ...zap.Field) []zap.Field {
|
||||
// a slightly modified version of zap.SugaredLogger.sweetenFields
|
||||
if len(args) == 0 {
|
||||
// fast-return if we have no suggared fields.
|
||||
return additional
|
||||
}
|
||||
|
||||
// unlike Zap, we can be pretty sure users aren't passing structured
|
||||
// fields (since logr has no concept of that), so guess that we need a
|
||||
// little less space.
|
||||
fields := make([]zap.Field, 0, len(args)/2+len(additional))
|
||||
for i := 0; i < len(args); {
|
||||
// check just in case for strongly-typed Zap fields, which is illegal (since
|
||||
// it breaks implementation agnosticism), so we can give a better error message.
|
||||
if _, ok := args[i].(zap.Field); ok {
|
||||
l.DPanic("strongly-typed Zap Field passed to logr", zap.Any("zap field", args[i]))
|
||||
break
|
||||
}
|
||||
|
||||
// make sure this isn't a mismatched key
|
||||
if i == len(args)-1 {
|
||||
l.DPanic("odd number of arguments passed as key-value pairs for logging", zap.Any("ignored key", args[i]))
|
||||
break
|
||||
}
|
||||
|
||||
// process a key-value pair,
|
||||
// ensuring that the key is a string
|
||||
key, val := args[i], args[i+1]
|
||||
keyStr, isString := key.(string)
|
||||
if !isString {
|
||||
// if the key isn't a string, DPanic and stop logging
|
||||
l.DPanic("non-string key argument passed to logging, ignoring all later arguments", zap.Any("invalid key", key))
|
||||
break
|
||||
}
|
||||
|
||||
fields = append(fields, zap.Any(keyStr, val))
|
||||
i += 2
|
||||
}
|
||||
|
||||
return append(fields, additional...)
|
||||
}
|
||||
|
||||
func (l *zapLogger) Error(err error, msg string, keysAndVals ...interface{}) {
|
||||
if checkedEntry := l.l.Check(zap.ErrorLevel, msg); checkedEntry != nil {
|
||||
checkedEntry.Write(handleFields(l.l, keysAndVals, zap.Error(err))...)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *zapLogger) V(level int) logr.InfoLogger {
|
||||
lvl := zapcore.Level(-1 * level)
|
||||
if l.l.Core().Enabled(lvl) {
|
||||
return &infoLogger{
|
||||
lvl: lvl,
|
||||
l: l.l,
|
||||
}
|
||||
}
|
||||
return disabledInfoLogger
|
||||
}
|
||||
|
||||
func (l *zapLogger) WithValues(keysAndValues ...interface{}) logr.Logger {
|
||||
newLogger := l.l.With(handleFields(l.l, keysAndValues)...)
|
||||
return NewLogger(newLogger)
|
||||
}
|
||||
|
||||
func (l *zapLogger) WithName(name string) logr.Logger {
|
||||
newLogger := l.l.Named(name)
|
||||
return NewLogger(newLogger)
|
||||
}
|
||||
|
||||
// NewLogger creates a new logr.Logger using the given Zap Logger to log.
|
||||
func NewLogger(l *zap.Logger) logr.Logger {
|
||||
return &zapLogger{
|
||||
l: l,
|
||||
infoLogger: infoLogger{
|
||||
l: l,
|
||||
lvl: zap.InfoLevel,
|
||||
},
|
||||
}
|
||||
}
|
||||
476
vendor/github.com/klauspost/cpuid/private-gen.go
generated
vendored
476
vendor/github.com/klauspost/cpuid/private-gen.go
generated
vendored
@@ -1,476 +0,0 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/printer"
|
||||
"go/token"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
var inFiles = []string{"cpuid.go", "cpuid_test.go"}
|
||||
var copyFiles = []string{"cpuid_amd64.s", "cpuid_386.s", "detect_ref.go", "detect_intel.go"}
|
||||
var fileSet = token.NewFileSet()
|
||||
var reWrites = []rewrite{
|
||||
initRewrite("CPUInfo -> cpuInfo"),
|
||||
initRewrite("Vendor -> vendor"),
|
||||
initRewrite("Flags -> flags"),
|
||||
initRewrite("Detect -> detect"),
|
||||
initRewrite("CPU -> cpu"),
|
||||
}
|
||||
var excludeNames = map[string]bool{"string": true, "join": true, "trim": true,
|
||||
// cpuid_test.go
|
||||
"t": true, "println": true, "logf": true, "log": true, "fatalf": true, "fatal": true,
|
||||
}
|
||||
|
||||
var excludePrefixes = []string{"test", "benchmark"}
|
||||
|
||||
func main() {
|
||||
Package := "private"
|
||||
parserMode := parser.ParseComments
|
||||
exported := make(map[string]rewrite)
|
||||
for _, file := range inFiles {
|
||||
in, err := os.Open(file)
|
||||
if err != nil {
|
||||
log.Fatalf("opening input", err)
|
||||
}
|
||||
|
||||
src, err := ioutil.ReadAll(in)
|
||||
if err != nil {
|
||||
log.Fatalf("reading input", err)
|
||||
}
|
||||
|
||||
astfile, err := parser.ParseFile(fileSet, file, src, parserMode)
|
||||
if err != nil {
|
||||
log.Fatalf("parsing input", err)
|
||||
}
|
||||
|
||||
for _, rw := range reWrites {
|
||||
astfile = rw(astfile)
|
||||
}
|
||||
|
||||
// Inspect the AST and print all identifiers and literals.
|
||||
var startDecl token.Pos
|
||||
var endDecl token.Pos
|
||||
ast.Inspect(astfile, func(n ast.Node) bool {
|
||||
var s string
|
||||
switch x := n.(type) {
|
||||
case *ast.Ident:
|
||||
if x.IsExported() {
|
||||
t := strings.ToLower(x.Name)
|
||||
for _, pre := range excludePrefixes {
|
||||
if strings.HasPrefix(t, pre) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if excludeNames[t] != true {
|
||||
//if x.Pos() > startDecl && x.Pos() < endDecl {
|
||||
exported[x.Name] = initRewrite(x.Name + " -> " + t)
|
||||
}
|
||||
}
|
||||
|
||||
case *ast.GenDecl:
|
||||
if x.Tok == token.CONST && x.Lparen > 0 {
|
||||
startDecl = x.Lparen
|
||||
endDecl = x.Rparen
|
||||
// fmt.Printf("Decl:%s -> %s\n", fileSet.Position(startDecl), fileSet.Position(endDecl))
|
||||
}
|
||||
}
|
||||
if s != "" {
|
||||
fmt.Printf("%s:\t%s\n", fileSet.Position(n.Pos()), s)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
for _, rw := range exported {
|
||||
astfile = rw(astfile)
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
||||
printer.Fprint(&buf, fileSet, astfile)
|
||||
|
||||
// Remove package documentation and insert information
|
||||
s := buf.String()
|
||||
ind := strings.Index(buf.String(), "\npackage cpuid")
|
||||
s = s[ind:]
|
||||
s = "// Generated, DO NOT EDIT,\n" +
|
||||
"// but copy it to your own project and rename the package.\n" +
|
||||
"// See more at http://github.com/klauspost/cpuid\n" +
|
||||
s
|
||||
|
||||
outputName := Package + string(os.PathSeparator) + file
|
||||
|
||||
err = ioutil.WriteFile(outputName, []byte(s), 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("writing output: %s", err)
|
||||
}
|
||||
log.Println("Generated", outputName)
|
||||
}
|
||||
|
||||
for _, file := range copyFiles {
|
||||
dst := ""
|
||||
if strings.HasPrefix(file, "cpuid") {
|
||||
dst = Package + string(os.PathSeparator) + file
|
||||
} else {
|
||||
dst = Package + string(os.PathSeparator) + "cpuid_" + file
|
||||
}
|
||||
err := copyFile(file, dst)
|
||||
if err != nil {
|
||||
log.Fatalf("copying file: %s", err)
|
||||
}
|
||||
log.Println("Copied", dst)
|
||||
}
|
||||
}
|
||||
|
||||
// CopyFile copies a file from src to dst. If src and dst files exist, and are
|
||||
// the same, then return success. Copy the file contents from src to dst.
|
||||
func copyFile(src, dst string) (err error) {
|
||||
sfi, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !sfi.Mode().IsRegular() {
|
||||
// cannot copy non-regular files (e.g., directories,
|
||||
// symlinks, devices, etc.)
|
||||
return fmt.Errorf("CopyFile: non-regular source file %s (%q)", sfi.Name(), sfi.Mode().String())
|
||||
}
|
||||
dfi, err := os.Stat(dst)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if !(dfi.Mode().IsRegular()) {
|
||||
return fmt.Errorf("CopyFile: non-regular destination file %s (%q)", dfi.Name(), dfi.Mode().String())
|
||||
}
|
||||
if os.SameFile(sfi, dfi) {
|
||||
return
|
||||
}
|
||||
}
|
||||
err = copyFileContents(src, dst)
|
||||
return
|
||||
}
|
||||
|
||||
// copyFileContents copies the contents of the file named src to the file named
|
||||
// by dst. The file will be created if it does not already exist. If the
|
||||
// destination file exists, all it's contents will be replaced by the contents
|
||||
// of the source file.
|
||||
func copyFileContents(src, dst string) (err error) {
|
||||
in, err := os.Open(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer in.Close()
|
||||
out, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
cerr := out.Close()
|
||||
if err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
if _, err = io.Copy(out, in); err != nil {
|
||||
return
|
||||
}
|
||||
err = out.Sync()
|
||||
return
|
||||
}
|
||||
|
||||
type rewrite func(*ast.File) *ast.File
|
||||
|
||||
// Mostly copied from gofmt
|
||||
func initRewrite(rewriteRule string) rewrite {
|
||||
f := strings.Split(rewriteRule, "->")
|
||||
if len(f) != 2 {
|
||||
fmt.Fprintf(os.Stderr, "rewrite rule must be of the form 'pattern -> replacement'\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
pattern := parseExpr(f[0], "pattern")
|
||||
replace := parseExpr(f[1], "replacement")
|
||||
return func(p *ast.File) *ast.File { return rewriteFile(pattern, replace, p) }
|
||||
}
|
||||
|
||||
// parseExpr parses s as an expression.
|
||||
// It might make sense to expand this to allow statement patterns,
|
||||
// but there are problems with preserving formatting and also
|
||||
// with what a wildcard for a statement looks like.
|
||||
func parseExpr(s, what string) ast.Expr {
|
||||
x, err := parser.ParseExpr(s)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "parsing %s %s at %s\n", what, s, err)
|
||||
os.Exit(2)
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
// Keep this function for debugging.
|
||||
/*
|
||||
func dump(msg string, val reflect.Value) {
|
||||
fmt.Printf("%s:\n", msg)
|
||||
ast.Print(fileSet, val.Interface())
|
||||
fmt.Println()
|
||||
}
|
||||
*/
|
||||
|
||||
// rewriteFile applies the rewrite rule 'pattern -> replace' to an entire file.
|
||||
func rewriteFile(pattern, replace ast.Expr, p *ast.File) *ast.File {
|
||||
cmap := ast.NewCommentMap(fileSet, p, p.Comments)
|
||||
m := make(map[string]reflect.Value)
|
||||
pat := reflect.ValueOf(pattern)
|
||||
repl := reflect.ValueOf(replace)
|
||||
|
||||
var rewriteVal func(val reflect.Value) reflect.Value
|
||||
rewriteVal = func(val reflect.Value) reflect.Value {
|
||||
// don't bother if val is invalid to start with
|
||||
if !val.IsValid() {
|
||||
return reflect.Value{}
|
||||
}
|
||||
for k := range m {
|
||||
delete(m, k)
|
||||
}
|
||||
val = apply(rewriteVal, val)
|
||||
if match(m, pat, val) {
|
||||
val = subst(m, repl, reflect.ValueOf(val.Interface().(ast.Node).Pos()))
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
r := apply(rewriteVal, reflect.ValueOf(p)).Interface().(*ast.File)
|
||||
r.Comments = cmap.Filter(r).Comments() // recreate comments list
|
||||
return r
|
||||
}
|
||||
|
||||
// set is a wrapper for x.Set(y); it protects the caller from panics if x cannot be changed to y.
|
||||
func set(x, y reflect.Value) {
|
||||
// don't bother if x cannot be set or y is invalid
|
||||
if !x.CanSet() || !y.IsValid() {
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if x := recover(); x != nil {
|
||||
if s, ok := x.(string); ok &&
|
||||
(strings.Contains(s, "type mismatch") || strings.Contains(s, "not assignable")) {
|
||||
// x cannot be set to y - ignore this rewrite
|
||||
return
|
||||
}
|
||||
panic(x)
|
||||
}
|
||||
}()
|
||||
x.Set(y)
|
||||
}
|
||||
|
||||
// Values/types for special cases.
|
||||
var (
|
||||
objectPtrNil = reflect.ValueOf((*ast.Object)(nil))
|
||||
scopePtrNil = reflect.ValueOf((*ast.Scope)(nil))
|
||||
|
||||
identType = reflect.TypeOf((*ast.Ident)(nil))
|
||||
objectPtrType = reflect.TypeOf((*ast.Object)(nil))
|
||||
positionType = reflect.TypeOf(token.NoPos)
|
||||
callExprType = reflect.TypeOf((*ast.CallExpr)(nil))
|
||||
scopePtrType = reflect.TypeOf((*ast.Scope)(nil))
|
||||
)
|
||||
|
||||
// apply replaces each AST field x in val with f(x), returning val.
|
||||
// To avoid extra conversions, f operates on the reflect.Value form.
|
||||
func apply(f func(reflect.Value) reflect.Value, val reflect.Value) reflect.Value {
|
||||
if !val.IsValid() {
|
||||
return reflect.Value{}
|
||||
}
|
||||
|
||||
// *ast.Objects introduce cycles and are likely incorrect after
|
||||
// rewrite; don't follow them but replace with nil instead
|
||||
if val.Type() == objectPtrType {
|
||||
return objectPtrNil
|
||||
}
|
||||
|
||||
// similarly for scopes: they are likely incorrect after a rewrite;
|
||||
// replace them with nil
|
||||
if val.Type() == scopePtrType {
|
||||
return scopePtrNil
|
||||
}
|
||||
|
||||
switch v := reflect.Indirect(val); v.Kind() {
|
||||
case reflect.Slice:
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
e := v.Index(i)
|
||||
set(e, f(e))
|
||||
}
|
||||
case reflect.Struct:
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
e := v.Field(i)
|
||||
set(e, f(e))
|
||||
}
|
||||
case reflect.Interface:
|
||||
e := v.Elem()
|
||||
set(v, f(e))
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func isWildcard(s string) bool {
|
||||
rune, size := utf8.DecodeRuneInString(s)
|
||||
return size == len(s) && unicode.IsLower(rune)
|
||||
}
|
||||
|
||||
// match returns true if pattern matches val,
|
||||
// recording wildcard submatches in m.
|
||||
// If m == nil, match checks whether pattern == val.
|
||||
func match(m map[string]reflect.Value, pattern, val reflect.Value) bool {
|
||||
// Wildcard matches any expression. If it appears multiple
|
||||
// times in the pattern, it must match the same expression
|
||||
// each time.
|
||||
if m != nil && pattern.IsValid() && pattern.Type() == identType {
|
||||
name := pattern.Interface().(*ast.Ident).Name
|
||||
if isWildcard(name) && val.IsValid() {
|
||||
// wildcards only match valid (non-nil) expressions.
|
||||
if _, ok := val.Interface().(ast.Expr); ok && !val.IsNil() {
|
||||
if old, ok := m[name]; ok {
|
||||
return match(nil, old, val)
|
||||
}
|
||||
m[name] = val
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, pattern and val must match recursively.
|
||||
if !pattern.IsValid() || !val.IsValid() {
|
||||
return !pattern.IsValid() && !val.IsValid()
|
||||
}
|
||||
if pattern.Type() != val.Type() {
|
||||
return false
|
||||
}
|
||||
|
||||
// Special cases.
|
||||
switch pattern.Type() {
|
||||
case identType:
|
||||
// For identifiers, only the names need to match
|
||||
// (and none of the other *ast.Object information).
|
||||
// This is a common case, handle it all here instead
|
||||
// of recursing down any further via reflection.
|
||||
p := pattern.Interface().(*ast.Ident)
|
||||
v := val.Interface().(*ast.Ident)
|
||||
return p == nil && v == nil || p != nil && v != nil && p.Name == v.Name
|
||||
case objectPtrType, positionType:
|
||||
// object pointers and token positions always match
|
||||
return true
|
||||
case callExprType:
|
||||
// For calls, the Ellipsis fields (token.Position) must
|
||||
// match since that is how f(x) and f(x...) are different.
|
||||
// Check them here but fall through for the remaining fields.
|
||||
p := pattern.Interface().(*ast.CallExpr)
|
||||
v := val.Interface().(*ast.CallExpr)
|
||||
if p.Ellipsis.IsValid() != v.Ellipsis.IsValid() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
p := reflect.Indirect(pattern)
|
||||
v := reflect.Indirect(val)
|
||||
if !p.IsValid() || !v.IsValid() {
|
||||
return !p.IsValid() && !v.IsValid()
|
||||
}
|
||||
|
||||
switch p.Kind() {
|
||||
case reflect.Slice:
|
||||
if p.Len() != v.Len() {
|
||||
return false
|
||||
}
|
||||
for i := 0; i < p.Len(); i++ {
|
||||
if !match(m, p.Index(i), v.Index(i)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
case reflect.Struct:
|
||||
for i := 0; i < p.NumField(); i++ {
|
||||
if !match(m, p.Field(i), v.Field(i)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
case reflect.Interface:
|
||||
return match(m, p.Elem(), v.Elem())
|
||||
}
|
||||
|
||||
// Handle token integers, etc.
|
||||
return p.Interface() == v.Interface()
|
||||
}
|
||||
|
||||
// subst returns a copy of pattern with values from m substituted in place
|
||||
// of wildcards and pos used as the position of tokens from the pattern.
|
||||
// if m == nil, subst returns a copy of pattern and doesn't change the line
|
||||
// number information.
|
||||
func subst(m map[string]reflect.Value, pattern reflect.Value, pos reflect.Value) reflect.Value {
|
||||
if !pattern.IsValid() {
|
||||
return reflect.Value{}
|
||||
}
|
||||
|
||||
// Wildcard gets replaced with map value.
|
||||
if m != nil && pattern.Type() == identType {
|
||||
name := pattern.Interface().(*ast.Ident).Name
|
||||
if isWildcard(name) {
|
||||
if old, ok := m[name]; ok {
|
||||
return subst(nil, old, reflect.Value{})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if pos.IsValid() && pattern.Type() == positionType {
|
||||
// use new position only if old position was valid in the first place
|
||||
if old := pattern.Interface().(token.Pos); !old.IsValid() {
|
||||
return pattern
|
||||
}
|
||||
return pos
|
||||
}
|
||||
|
||||
// Otherwise copy.
|
||||
switch p := pattern; p.Kind() {
|
||||
case reflect.Slice:
|
||||
v := reflect.MakeSlice(p.Type(), p.Len(), p.Len())
|
||||
for i := 0; i < p.Len(); i++ {
|
||||
v.Index(i).Set(subst(m, p.Index(i), pos))
|
||||
}
|
||||
return v
|
||||
|
||||
case reflect.Struct:
|
||||
v := reflect.New(p.Type()).Elem()
|
||||
for i := 0; i < p.NumField(); i++ {
|
||||
v.Field(i).Set(subst(m, p.Field(i), pos))
|
||||
}
|
||||
return v
|
||||
|
||||
case reflect.Ptr:
|
||||
v := reflect.New(p.Type()).Elem()
|
||||
if elem := p.Elem(); elem.IsValid() {
|
||||
v.Set(subst(m, elem, pos).Addr())
|
||||
}
|
||||
return v
|
||||
|
||||
case reflect.Interface:
|
||||
v := reflect.New(p.Type()).Elem()
|
||||
if elem := p.Elem(); elem.IsValid() {
|
||||
v.Set(subst(m, elem, pos))
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
return pattern
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package application
|
||||
|
||||
import (
|
||||
appv1beta1 "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
|
||||
reconciler "github.com/kubernetes-sigs/application/pkg/genericreconciler"
|
||||
kbc "github.com/kubernetes-sigs/application/pkg/kbcontroller"
|
||||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
)
|
||||
|
||||
// Constants
|
||||
const (
|
||||
NameLabelKey = "app.kubernetes.io/name"
|
||||
VersionLabelKey = "app.kubernetes.io/version"
|
||||
InstanceLabelKey = "app.kubernetes.io/instance"
|
||||
PartOfLabelKey = "app.kubernetes.io/part-of"
|
||||
ComponentLabelKey = "app.kubernetes.io/component"
|
||||
ManagedByLabelKey = "app.kubernetes.io/managed-by"
|
||||
)
|
||||
|
||||
// Add creates a new Application Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
|
||||
// and Start it when the Manager is Started.
|
||||
func Add(mgr manager.Manager) error {
|
||||
return kbc.CreateController("application", mgr, &appv1beta1.Application{}, newReconciler(mgr))
|
||||
}
|
||||
|
||||
// newReconciler returns a new reconcile.Reconciler
|
||||
func newReconciler(mgr manager.Manager) reconcile.Reconciler {
|
||||
r := &reconciler.Reconciler{
|
||||
Manager: mgr, // why do we need manager ?
|
||||
Handle: &appv1beta1.Application{},
|
||||
}
|
||||
r.Init()
|
||||
return r
|
||||
}
|
||||
18
vendor/github.com/kubernetes-sigs/application/pkg/genericreconciler/doc.go
generated
vendored
18
vendor/github.com/kubernetes-sigs/application/pkg/genericreconciler/doc.go
generated
vendored
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package genericreconciler contains generic reconciler loop
|
||||
package genericreconciler
|
||||
335
vendor/github.com/kubernetes-sigs/application/pkg/genericreconciler/genericreconciler.go
generated
vendored
335
vendor/github.com/kubernetes-sigs/application/pkg/genericreconciler/genericreconciler.go
generated
vendored
@@ -1,335 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package genericreconciler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/kubernetes-sigs/application/pkg/component"
|
||||
cr "github.com/kubernetes-sigs/application/pkg/customresource"
|
||||
"github.com/kubernetes-sigs/application/pkg/resource"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
urt "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"log"
|
||||
"reflect"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
)
|
||||
|
||||
func handleErrorArr(info string, name string, e error, errs []error) []error {
|
||||
HandleError(info, name, e)
|
||||
return append(errs, e)
|
||||
}
|
||||
|
||||
// HandleError common error handling routine
|
||||
func HandleError(info string, name string, e error) error {
|
||||
urt.HandleError(fmt.Errorf("Failed: [%s] %s. %s", name, info, e.Error()))
|
||||
return e
|
||||
}
|
||||
|
||||
func (gr *Reconciler) observe(observables ...resource.Observable) (*resource.ObjectBag, error) {
|
||||
var returnval = new(resource.ObjectBag)
|
||||
var err error
|
||||
for _, obs := range observables {
|
||||
var resources []resource.Object
|
||||
if obs.Labels != nil {
|
||||
opts := client.ListOptions{
|
||||
LabelSelector: labels.SelectorFromSet(obs.Labels),
|
||||
}
|
||||
opts.Raw = &metav1.ListOptions{TypeMeta: obs.Type}
|
||||
err = gr.List(context.TODO(), obs.ObjList.(runtime.Object), &opts)
|
||||
if err == nil {
|
||||
items, err := meta.ExtractList(obs.ObjList.(runtime.Object))
|
||||
if err == nil {
|
||||
for _, item := range items {
|
||||
resources = append(resources, resource.Object{Obj: item.(metav1.Object)})
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var obj = obs.Obj.(metav1.Object)
|
||||
name := obj.GetName()
|
||||
namespace := obj.GetNamespace()
|
||||
otype := reflect.TypeOf(obj).String()
|
||||
err = gr.Get(context.TODO(),
|
||||
types.NamespacedName{Name: name, Namespace: namespace},
|
||||
obs.Obj.(runtime.Object))
|
||||
if err == nil {
|
||||
resources = append(resources, resource.Object{Obj: obs.Obj})
|
||||
} else {
|
||||
log.Printf(" >>>ERR get: %s", otype+"/"+namespace+"/"+name)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, resource := range resources {
|
||||
returnval.Add(resource)
|
||||
}
|
||||
}
|
||||
return returnval, nil
|
||||
}
|
||||
|
||||
func specDiffers(o1, o2 metav1.Object) bool {
|
||||
// Not all k8s objects have Spec
|
||||
// example ConfigMap
|
||||
// TODO strategic merge patch diff in generic controller loop
|
||||
e := reflect.Indirect(reflect.ValueOf(o1)).FieldByName("Spec")
|
||||
o := reflect.Indirect(reflect.ValueOf(o2)).FieldByName("Spec")
|
||||
if !e.IsValid() {
|
||||
// handling ConfigMap
|
||||
e = reflect.Indirect(reflect.ValueOf(o1)).FieldByName("Data")
|
||||
o = reflect.Indirect(reflect.ValueOf(o2)).FieldByName("Data")
|
||||
}
|
||||
|
||||
if e.IsValid() && o.IsValid() {
|
||||
if reflect.DeepEqual(e.Interface(), o.Interface()) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// If both ownerRefs have the same group/kind/name but different uid, that means at least one of them doesn't exist anymore.
|
||||
// If we compare `uid` in this function, we'd set both as owners which is not what we want
|
||||
// Because in the case that the original owner is already gone, we want its dependent to be garbage collected with it.
|
||||
func isReferringSameObject(a, b metav1.OwnerReference) bool {
|
||||
aGV, err := schema.ParseGroupVersion(a.APIVersion)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
bGV, err := schema.ParseGroupVersion(b.APIVersion)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return aGV == bGV && a.Kind == b.Kind && a.Name == b.Name
|
||||
}
|
||||
|
||||
func injectOwnerRefs(o metav1.Object, ref *metav1.OwnerReference) bool {
|
||||
if ref == nil {
|
||||
return false
|
||||
}
|
||||
objRefs := o.GetOwnerReferences()
|
||||
for _, r := range objRefs {
|
||||
if isReferringSameObject(*ref, r) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
objRefs = append(objRefs, *ref)
|
||||
o.SetOwnerReferences(objRefs)
|
||||
return true
|
||||
}
|
||||
|
||||
// ReconcileCR is a generic function that reconciles expected and observed resources
|
||||
func (gr *Reconciler) ReconcileCR(namespacedname types.NamespacedName, handle cr.Handle) error {
|
||||
var status interface{}
|
||||
expected := &resource.ObjectBag{}
|
||||
update := false
|
||||
rsrc := handle.NewRsrc()
|
||||
name := reflect.TypeOf(rsrc).String() + "/" + namespacedname.String()
|
||||
err := gr.Get(context.TODO(), namespacedname, rsrc.(runtime.Object))
|
||||
if err == nil {
|
||||
o := rsrc.(metav1.Object)
|
||||
err = rsrc.Validate()
|
||||
status = rsrc.NewStatus()
|
||||
if err == nil {
|
||||
rsrc.ApplyDefaults()
|
||||
components := rsrc.Components()
|
||||
for _, component := range components {
|
||||
if o.GetDeletionTimestamp() == nil {
|
||||
err = gr.ReconcileComponent(name, component, status, expected)
|
||||
} else {
|
||||
err = gr.FinalizeComponent(name, component, status, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if errors.IsNotFound(err) {
|
||||
urt.HandleError(fmt.Errorf("not found %s. %s", name, err.Error()))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
update = rsrc.UpdateRsrcStatus(status, err)
|
||||
|
||||
if update {
|
||||
err = gr.Update(context.TODO(), rsrc.(runtime.Object))
|
||||
}
|
||||
if err != nil {
|
||||
urt.HandleError(fmt.Errorf("error updating %s. %s", name, err.Error()))
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// ObserveAndMutate is a function that is called to observe and mutate expected resources
|
||||
func (gr *Reconciler) ObserveAndMutate(crname string, c component.Component, status interface{}, mutate bool, aggregated *resource.ObjectBag) (*resource.ObjectBag, *resource.ObjectBag, error) {
|
||||
var err error
|
||||
var expected, observed, dependent *resource.ObjectBag
|
||||
emptybag := &resource.ObjectBag{}
|
||||
|
||||
// Get dependenta objects
|
||||
dependent, err = gr.observe(resource.ObservablesFromObjects(gr.Scheme, c.DependentResources(c.CR), c.Labels())...)
|
||||
if err != nil {
|
||||
return emptybag, emptybag, fmt.Errorf("Failed getting dependent resources: %s", err.Error())
|
||||
}
|
||||
|
||||
// Get Expected resources
|
||||
expected, err = c.ExpectedResources(c.CR, c.Labels(), dependent, aggregated)
|
||||
if err != nil {
|
||||
return emptybag, emptybag, fmt.Errorf("Failed gathering expected resources: %s", err.Error())
|
||||
}
|
||||
|
||||
// Get observables
|
||||
observables := c.Observables(gr.Scheme, c.CR, c.Labels(), expected)
|
||||
|
||||
// Observe observables
|
||||
observed, err = gr.observe(observables...)
|
||||
if err != nil {
|
||||
return emptybag, emptybag, fmt.Errorf("Failed observing resources: %s", err.Error())
|
||||
}
|
||||
|
||||
// Mutate expected objects
|
||||
if mutate {
|
||||
expected, err = c.Mutate(c.CR, c.Labels(), status, expected, dependent, observed)
|
||||
if err != nil {
|
||||
return emptybag, emptybag, fmt.Errorf("Failed mutating resources: %s", err.Error())
|
||||
}
|
||||
|
||||
// Get observables
|
||||
observables := c.Observables(gr.Scheme, c.CR, c.Labels(), expected)
|
||||
|
||||
// Observe observables
|
||||
observed, err = gr.observe(observables...)
|
||||
if err != nil {
|
||||
return emptybag, emptybag, fmt.Errorf("Failed observing resources after mutation: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return expected, observed, err
|
||||
}
|
||||
|
||||
// FinalizeComponent is a function that finalizes component
|
||||
func (gr *Reconciler) FinalizeComponent(crname string, c component.Component, status interface{}, aggregated *resource.ObjectBag) error {
|
||||
cname := crname + "(cmpnt:" + c.Name + ")"
|
||||
log.Printf("%s finalizing component\n", cname)
|
||||
defer log.Printf("%s finalizing component completed", cname)
|
||||
|
||||
expected, observed, err := gr.ObserveAndMutate(crname, c, status, false, aggregated)
|
||||
|
||||
if err != nil {
|
||||
HandleError("", crname, err)
|
||||
}
|
||||
aggregated.Add(expected.Items()...)
|
||||
err = c.Finalize(c.CR, status, observed)
|
||||
return err
|
||||
}
|
||||
|
||||
// ReconcileComponent is a generic function that reconciles expected and observed resources
|
||||
func (gr *Reconciler) ReconcileComponent(crname string, c component.Component, status interface{}, aggregated *resource.ObjectBag) error {
|
||||
errs := []error{}
|
||||
var reconciled *resource.ObjectBag = new(resource.ObjectBag)
|
||||
|
||||
cname := crname + "(cmpnt:" + c.Name + ")"
|
||||
log.Printf("%s reconciling component\n", cname)
|
||||
defer log.Printf("%s reconciling component completed\n", cname)
|
||||
|
||||
expected, observed, err := gr.ObserveAndMutate(crname, c, status, true, aggregated)
|
||||
|
||||
// Reconciliation logic is straight-forward:
|
||||
// This method gets the list of expected resources and observed resources
|
||||
// We compare the 2 lists and:
|
||||
// create(rsrc) where rsrc is in expected but not in observed
|
||||
// delete(rsrc) where rsrc is in observed but not in expected
|
||||
// update(rsrc) where rsrc is in observed and expected
|
||||
//
|
||||
// We have a notion of Managed and Referred resources
|
||||
// Only Managed resources are CRUD'd
|
||||
// Missing Reffered resources are treated as errors and surfaced as such in the status field
|
||||
//
|
||||
|
||||
if err != nil {
|
||||
errs = handleErrorArr("", crname, err, errs)
|
||||
} else {
|
||||
aggregated.Add(expected.Items()...)
|
||||
}
|
||||
|
||||
for _, e := range expected.Items() {
|
||||
seen := false
|
||||
eNamespace := e.Obj.GetNamespace()
|
||||
eName := e.Obj.GetName()
|
||||
eKind := reflect.TypeOf(e.Obj).String()
|
||||
eRsrcInfo := eNamespace + "/" + eKind + "/" + eName
|
||||
for _, o := range observed.Items() {
|
||||
if (eName != o.Obj.GetName()) || (eNamespace != o.Obj.GetNamespace()) ||
|
||||
(eKind != reflect.TypeOf(o.Obj).String()) {
|
||||
continue
|
||||
}
|
||||
// rsrc is seen in both expected and observed, update it if needed
|
||||
e.Obj.SetResourceVersion(o.Obj.GetResourceVersion())
|
||||
e.Obj.SetOwnerReferences(o.Obj.GetOwnerReferences())
|
||||
if e.Lifecycle == resource.LifecycleManaged && (specDiffers(e.Obj, o.Obj) && c.Differs(e.Obj, o.Obj) || injectOwnerRefs(e.Obj, c.OwnerRef)) {
|
||||
if err := gr.Update(context.TODO(), e.Obj.(runtime.Object).DeepCopyObject()); err != nil {
|
||||
errs = handleErrorArr("update", eRsrcInfo, err, errs)
|
||||
}
|
||||
}
|
||||
reconciled.Add(o)
|
||||
seen = true
|
||||
break
|
||||
}
|
||||
// rsrc is in expected but not in observed - create
|
||||
if !seen {
|
||||
if e.Lifecycle == resource.LifecycleManaged {
|
||||
injectOwnerRefs(e.Obj, c.OwnerRef)
|
||||
if err := gr.Create(context.TODO(), e.Obj.(runtime.Object)); err != nil {
|
||||
errs = handleErrorArr("Create", cname, err, errs)
|
||||
} else {
|
||||
reconciled.Add(e)
|
||||
}
|
||||
} else {
|
||||
err := fmt.Errorf("missing resource not managed by %s: %s", cname, eRsrcInfo)
|
||||
errs = handleErrorArr("missing resource", cname, err, errs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = utilerrors.NewAggregate(errs)
|
||||
c.UpdateComponentStatus(c.CR, status, reconciled, err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Reconcile expected by kubebuilder
|
||||
func (gr *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, error) {
|
||||
err := gr.ReconcileCR(request.NamespacedName, gr.Handle)
|
||||
if err != nil {
|
||||
fmt.Printf("err: %s", err.Error())
|
||||
}
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
|
||||
// AddToSchemes for adding Application to scheme
|
||||
var AddToSchemes runtime.SchemeBuilder
|
||||
|
||||
// Init sets up Reconciler
|
||||
func (gr *Reconciler) Init() {
|
||||
gr.Client = gr.Manager.GetClient()
|
||||
gr.Scheme = gr.Manager.GetScheme()
|
||||
AddToSchemes.AddToScheme(gr.Scheme)
|
||||
}
|
||||
41
vendor/github.com/kubernetes-sigs/application/pkg/genericreconciler/types.go
generated
vendored
41
vendor/github.com/kubernetes-sigs/application/pkg/genericreconciler/types.go
generated
vendored
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package genericreconciler
|
||||
|
||||
import (
|
||||
cr "github.com/kubernetes-sigs/application/pkg/customresource"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
)
|
||||
|
||||
var _ reconcile.Reconciler = &Reconciler{}
|
||||
|
||||
// Reconciler defines fields needed for all airflow controllers
|
||||
// +k8s:deepcopy-gen=false
|
||||
type Reconciler struct {
|
||||
client.Client
|
||||
Scheme *runtime.Scheme
|
||||
Handle cr.Handle
|
||||
Manager manager.Manager
|
||||
}
|
||||
|
||||
// ReconcilerConfig config defines reconciler parameters
|
||||
// +k8s:deepcopy-gen=false
|
||||
type ReconcilerConfig struct {
|
||||
}
|
||||
|
||||
// KVmap is a map[string]string
|
||||
type KVmap map[string]string
|
||||
23
vendor/github.com/kubernetes-sigs/application/pkg/genericreconciler/utils.go
generated
vendored
23
vendor/github.com/kubernetes-sigs/application/pkg/genericreconciler/utils.go
generated
vendored
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package genericreconciler
|
||||
|
||||
// Merge is used to merge multiple maps into the target map
|
||||
func (out KVmap) Merge(kvmaps ...KVmap) {
|
||||
for _, kvmap := range kvmaps {
|
||||
for k, v := range kvmap {
|
||||
out[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
18
vendor/github.com/kubernetes-sigs/application/pkg/kbcontroller/doc.go
generated
vendored
18
vendor/github.com/kubernetes-sigs/application/pkg/kbcontroller/doc.go
generated
vendored
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package kbcontroller contains methods to integrate with kube-builder manager
|
||||
package kbcontroller
|
||||
42
vendor/github.com/kubernetes-sigs/application/pkg/kbcontroller/kbcontroller.go
generated
vendored
42
vendor/github.com/kubernetes-sigs/application/pkg/kbcontroller/kbcontroller.go
generated
vendored
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package kbcontroller
|
||||
|
||||
import (
|
||||
cr "github.com/kubernetes-sigs/application/pkg/customresource"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller"
|
||||
"sigs.k8s.io/controller-runtime/pkg/handler"
|
||||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
"sigs.k8s.io/controller-runtime/pkg/source"
|
||||
)
|
||||
|
||||
// CreateController creates a new Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller and Start it when the Manager is Started.
|
||||
func CreateController(name string, mgr manager.Manager, handle cr.Handle, r reconcile.Reconciler) error {
|
||||
// Create a new controller
|
||||
c, err := controller.New(name+"-ctrl", mgr, controller.Options{Reconciler: r})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Watch for changes to Base resource
|
||||
err = c.Watch(&source.Kind{Type: handle.NewRsrc().(runtime.Object)},
|
||||
&handler.EnqueueRequestForObject{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
201
vendor/github.com/kubesphere/s2ioperator/LICENSE
generated
vendored
201
vendor/github.com/kubesphere/s2ioperator/LICENSE
generated
vendored
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
12
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/code_framework.go
generated
vendored
12
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/code_framework.go
generated
vendored
@@ -1,12 +0,0 @@
|
||||
package v1alpha1
|
||||
|
||||
type CodeFramework string
|
||||
|
||||
const (
|
||||
Ruby CodeFramework = "ruby"
|
||||
Go CodeFramework = "go"
|
||||
Java CodeFramework = "Java"
|
||||
JavaTomcat CodeFramework = "JavaTomcat"
|
||||
Nodejs CodeFramework = "Nodejs"
|
||||
Python CodeFramework = "python"
|
||||
)
|
||||
23
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/doc.go
generated
vendored
23
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/doc.go
generated
vendored
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package v1alpha1 contains API Schema definitions for the devops v1alpha1 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=github.com/kubesphere/s2ioperator/pkg/apis/devops
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=devops.kubesphere.io
|
||||
package v1alpha1
|
||||
15134
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/openapi_generated.go
generated
vendored
15134
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/openapi_generated.go
generated
vendored
File diff suppressed because it is too large
Load Diff
46
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/register.go
generated
vendored
46
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/register.go
generated
vendored
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// NOTE: Boilerplate only. Ignore this file.
|
||||
|
||||
// Package v1alpha1 contains API Schema definitions for the devops v1alpha1 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=github.com/kubesphere/s2ioperator/pkg/apis/devops
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=devops.kubesphere.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: "devops.kubesphere.io", Version: "v1alpha1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
|
||||
|
||||
// AddToScheme is required by pkg/client/...
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Resource is required by pkg/client/listers/...
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
510
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/s2ibuilder_types.go
generated
vendored
510
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/s2ibuilder_types.go
generated
vendored
@@ -1,510 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||
|
||||
type RunState string
|
||||
|
||||
const (
|
||||
ResourceKindS2iBuilder = "S2iBuilder"
|
||||
ResourceSingularS2iBuilder = "s2ibuilder"
|
||||
ResourcePluralS2iBuilder = "s2ibuilders"
|
||||
)
|
||||
|
||||
const (
|
||||
NotRunning RunState = "Not Running Yet"
|
||||
Running RunState = "Running"
|
||||
Successful = "Successful"
|
||||
Failed = "Failed"
|
||||
Unknown = "Unknown"
|
||||
)
|
||||
const (
|
||||
AutoScaleAnnotations = "devops.kubesphere.io/autoscale"
|
||||
S2iRunLabel = "devops.kubesphere.io/s2ir"
|
||||
S2irCompletedScaleAnnotations = "devops.kubesphere.io/completedscale"
|
||||
WorkLoadCompletedInitAnnotations = "devops.kubesphere.io/inithasbeencomplted"
|
||||
S2iRunDoNotAutoScaleAnnotations = "devops.kubesphere.io/donotautoscale"
|
||||
DescriptionAnnotations = "desc"
|
||||
)
|
||||
const (
|
||||
KindDeployment = "Deployment"
|
||||
KindStatefulSet = "StatefulSet"
|
||||
)
|
||||
|
||||
// EnvironmentSpec specifies a single environment variable.
|
||||
type EnvironmentSpec struct {
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// ProxyConfig holds proxy configuration.
|
||||
type ProxyConfig struct {
|
||||
HTTPProxy string `json:"httpProxy,omitempty"`
|
||||
HTTPSProxy string `json:"httpsProxy,omitempty"`
|
||||
}
|
||||
|
||||
// CGroupLimits holds limits used to constrain container resources.
|
||||
type CGroupLimits struct {
|
||||
MemoryLimitBytes int64 `json:"memoryLimitBytes"`
|
||||
CPUShares int64 `json:"cpuShares"`
|
||||
CPUPeriod int64 `json:"cpuPeriod"`
|
||||
CPUQuota int64 `json:"cpuQuota"`
|
||||
MemorySwap int64 `json:"memorySwap"`
|
||||
Parent string `json:"parent"`
|
||||
}
|
||||
|
||||
// VolumeSpec represents a single volume mount point.
|
||||
type VolumeSpec struct {
|
||||
// Source is a reference to the volume source.
|
||||
Source string `json:"source,omitempty"`
|
||||
// Destination is the path to mount the volume to - absolute or relative.
|
||||
Destination string `json:"destination,omitempty"`
|
||||
// Keep indicates if the mounted data should be kept in the final image.
|
||||
Keep bool `json:"keep,omitempty"`
|
||||
}
|
||||
|
||||
// DockerConfig contains the configuration for a Docker connection.
|
||||
type DockerConfig struct {
|
||||
// Endpoint is the docker network endpoint or socket
|
||||
Endpoint string `json:"endPoint"`
|
||||
|
||||
// CertFile is the certificate file path for a TLS connection
|
||||
CertFile string `json:"certFile"`
|
||||
|
||||
// KeyFile is the key file path for a TLS connection
|
||||
KeyFile string `json:"keyFile"`
|
||||
|
||||
// CAFile is the certificate authority file path for a TLS connection
|
||||
CAFile string `json:"caFile"`
|
||||
|
||||
// UseTLS indicates if TLS must be used
|
||||
UseTLS bool `json:"useTLS"`
|
||||
|
||||
// TLSVerify indicates if TLS peer must be verified
|
||||
TLSVerify bool `json:"tlsVerify"`
|
||||
}
|
||||
|
||||
// AuthConfig is our abstraction of the Registry authorization information for whatever
|
||||
// docker client we happen to be based on
|
||||
type AuthConfig struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
ServerAddress string `json:"serverAddress,omitempty"`
|
||||
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"`
|
||||
}
|
||||
|
||||
// ContainerConfig is the abstraction of the docker client provider (formerly go-dockerclient, now either
|
||||
// engine-api or kube docker client) container.Config type that is leveraged by s2i or origin
|
||||
type ContainerConfig struct {
|
||||
Labels map[string]string
|
||||
Env []string
|
||||
}
|
||||
|
||||
type PullPolicy string
|
||||
|
||||
const (
|
||||
// PullAlways means that we always attempt to pull the latest image.
|
||||
PullAlways PullPolicy = "always"
|
||||
|
||||
// PullNever means that we never pull an image, but only use a local image.
|
||||
PullNever PullPolicy = "never"
|
||||
|
||||
// PullIfNotPresent means that we pull if the image isn't present on disk.
|
||||
PullIfNotPresent PullPolicy = "if-not-present"
|
||||
|
||||
// DefaultBuilderPullPolicy specifies the default pull policy to use
|
||||
DefaultBuilderPullPolicy = PullIfNotPresent
|
||||
|
||||
// DefaultRuntimeImagePullPolicy specifies the default pull policy to use.
|
||||
DefaultRuntimeImagePullPolicy = PullIfNotPresent
|
||||
|
||||
// DefaultPreviousImagePullPolicy specifies policy for pulling the previously
|
||||
// build Docker image when doing incremental build
|
||||
DefaultPreviousImagePullPolicy = PullIfNotPresent
|
||||
)
|
||||
|
||||
// DockerNetworkMode specifies the network mode setting for the docker container
|
||||
type DockerNetworkMode string
|
||||
|
||||
const (
|
||||
// DockerNetworkModeHost places the container in the default (host) network namespace.
|
||||
DockerNetworkModeHost DockerNetworkMode = "host"
|
||||
// DockerNetworkModeBridge instructs docker to create a network namespace for this container connected to the docker0 bridge via a veth-pair.
|
||||
DockerNetworkModeBridge DockerNetworkMode = "bridge"
|
||||
// DockerNetworkModeContainerPrefix is the string prefix used by NewDockerNetworkModeContainer.
|
||||
DockerNetworkModeContainerPrefix string = "container:"
|
||||
// DockerNetworkModeNetworkNamespacePrefix is the string prefix used when sharing a namespace from a CRI-O container.
|
||||
DockerNetworkModeNetworkNamespacePrefix string = "netns:"
|
||||
)
|
||||
|
||||
type TriggerSource string
|
||||
|
||||
const (
|
||||
Default TriggerSource = "Manual"
|
||||
Github TriggerSource = "Github"
|
||||
Gitlab TriggerSource = "Gitlab"
|
||||
SVN TriggerSource = "SVN"
|
||||
Others TriggerSource = "Others"
|
||||
)
|
||||
|
||||
// NewDockerNetworkModeContainer creates a DockerNetworkMode value which instructs docker to place the container in the network namespace of an existing container.
|
||||
// It can be used, for instance, to place the s2i container in the network namespace of the infrastructure container of a k8s pod.
|
||||
func NewDockerNetworkModeContainer(id string) DockerNetworkMode {
|
||||
return DockerNetworkMode(DockerNetworkModeContainerPrefix + id)
|
||||
}
|
||||
|
||||
// String implements the String() function of pflags.Value so this can be used as
|
||||
// command line parameter.
|
||||
// This method is really used just to show the default value when printing help.
|
||||
// It will not default the configuration.
|
||||
func (p *PullPolicy) String() string {
|
||||
if len(string(*p)) == 0 {
|
||||
return string(DefaultBuilderPullPolicy)
|
||||
}
|
||||
return string(*p)
|
||||
}
|
||||
|
||||
// Type implements the Type() function of pflags.Value interface
|
||||
func (p *PullPolicy) Type() string {
|
||||
return "string"
|
||||
}
|
||||
|
||||
// Set implements the Set() function of pflags.Value interface
|
||||
// The valid options are "always", "never" or "if-not-present"
|
||||
func (p *PullPolicy) Set(v string) error {
|
||||
switch v {
|
||||
case "always":
|
||||
*p = PullAlways
|
||||
case "never":
|
||||
*p = PullNever
|
||||
case "if-not-present":
|
||||
*p = PullIfNotPresent
|
||||
default:
|
||||
return fmt.Errorf("invalid value %q, valid values are: always, never or if-not-present", v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type S2iConfig struct {
|
||||
// DisplayName is a result image display-name label. This defaults to the
|
||||
// output image name.
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
|
||||
// Description is a result image description label. The default is no
|
||||
// description.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// BuilderImage describes which image is used for building the result images.
|
||||
BuilderImage string `json:"builderImage,omitempty"`
|
||||
|
||||
// BuilderImageVersion provides optional version information about the builder image.
|
||||
BuilderImageVersion string `json:"builderImageVersion,omitempty"`
|
||||
|
||||
// BuilderBaseImageVersion provides optional version information about the builder base image.
|
||||
BuilderBaseImageVersion string `json:"builderBaseImageVersion,omitempty"`
|
||||
|
||||
// RuntimeImage specifies the image that will be a base for resulting image
|
||||
// and will be used for running an application. By default, BuilderImage is
|
||||
// used for building and running, but the latter may be overridden.
|
||||
RuntimeImage string `json:"runtimeImage,omitempty"`
|
||||
|
||||
//OutputImageName is a result image name without tag, default is latest. tag will append to ImageName in the end
|
||||
OutputImageName string `json:"outputImageName,omitempty"`
|
||||
// RuntimeImagePullPolicy specifies when to pull a runtime image.
|
||||
RuntimeImagePullPolicy PullPolicy `json:"runtimeImagePullPolicy,omitempty"`
|
||||
|
||||
// RuntimeAuthentication holds the authentication information for pulling the
|
||||
// runtime Docker images from private repositories.
|
||||
RuntimeAuthentication *AuthConfig `json:"runtimeAuthentication,omitempty"`
|
||||
|
||||
// RuntimeArtifacts specifies a list of source/destination pairs that will
|
||||
// be copied from builder to a runtime image. Source can be a file or
|
||||
// directory. Destination must be a directory. Regardless whether it
|
||||
// is an absolute or relative path, it will be placed into image's WORKDIR.
|
||||
// Destination also can be empty or equals to ".", in this case it just
|
||||
// refers to a root of WORKDIR.
|
||||
// In case it's empty, S2I will try to get this list from
|
||||
// io.openshift.s2i.assemble-input-files label on a RuntimeImage.
|
||||
RuntimeArtifacts []VolumeSpec `json:"runtimeArtifacts,omitempty"`
|
||||
|
||||
// DockerConfig describes how to access host docker daemon.
|
||||
DockerConfig *DockerConfig `json:"dockerConfig,omitempty"`
|
||||
|
||||
// PullAuthentication holds the authentication information for pulling the
|
||||
// Docker images from private repositories
|
||||
PullAuthentication *AuthConfig `json:"pullAuthentication,omitempty"`
|
||||
|
||||
// PullAuthentication holds the authentication information for pulling the
|
||||
// Docker images from private repositories
|
||||
PushAuthentication *AuthConfig `json:"pushAuthentication,omitempty"`
|
||||
|
||||
// IncrementalAuthentication holds the authentication information for pulling the
|
||||
// previous image from private repositories
|
||||
IncrementalAuthentication *AuthConfig `json:"incrementalAuthentication,omitempty"`
|
||||
|
||||
// DockerNetworkMode is used to set the docker network setting to --net=container:<id>
|
||||
// when the builder is invoked from a container.
|
||||
DockerNetworkMode DockerNetworkMode `json:"dockerNetworkMode,omitempty"`
|
||||
|
||||
// PreserveWorkingDir describes if working directory should be left after processing.
|
||||
PreserveWorkingDir bool `json:"preserveWorkingDir,omitempty"`
|
||||
|
||||
//ImageName Contains the registry address and reponame, tag should set by field tag alone
|
||||
ImageName string `json:"imageName"`
|
||||
// Tag is a result image tag name.
|
||||
Tag string `json:"tag,omitempty"`
|
||||
|
||||
// BuilderPullPolicy specifies when to pull the builder image
|
||||
BuilderPullPolicy PullPolicy `json:"builderPullPolicy,omitempty"`
|
||||
|
||||
// PreviousImagePullPolicy specifies when to pull the previously build image
|
||||
// when doing incremental build
|
||||
PreviousImagePullPolicy PullPolicy `json:"previousImagePullPolicy,omitempty"`
|
||||
|
||||
// Incremental describes whether to try to perform incremental build.
|
||||
Incremental bool `json:"incremental,omitempty"`
|
||||
|
||||
// IncrementalFromTag sets an alternative image tag to look for existing
|
||||
// artifacts. Tag is used by default if this is not set.
|
||||
IncrementalFromTag string `json:"incrementalFromTag,omitempty"`
|
||||
|
||||
// RemovePreviousImage describes if previous image should be removed after successful build.
|
||||
// This applies only to incremental builds.
|
||||
RemovePreviousImage bool `json:"removePreviousImage,omitempty"`
|
||||
|
||||
// Environment is a map of environment variables to be passed to the image.
|
||||
Environment []EnvironmentSpec `json:"environment,omitempty"`
|
||||
|
||||
// LabelNamespace provides the namespace under which the labels will be generated.
|
||||
LabelNamespace string `json:"labelNamespace,omitempty"`
|
||||
|
||||
// CallbackURL is a URL which is called upon successful build to inform about that fact.
|
||||
CallbackURL string `json:"callbackUrl,omitempty"`
|
||||
|
||||
// ScriptsURL is a URL describing where to fetch the S2I scripts from during build process.
|
||||
// This url can be a reference within the builder image if the scheme is specified as image://
|
||||
ScriptsURL string `json:"scriptsUrl,omitempty"`
|
||||
|
||||
// Destination specifies a location where the untar operation will place its artifacts.
|
||||
Destination string `json:"destination,omitempty"`
|
||||
|
||||
// WorkingDir describes temporary directory used for downloading sources, scripts and tar operations.
|
||||
WorkingDir string `json:"workingDir,omitempty"`
|
||||
|
||||
// WorkingSourceDir describes the subdirectory off of WorkingDir set up during the repo download
|
||||
// that is later used as the root for ignore processing
|
||||
WorkingSourceDir string `json:"workingSourceDir,omitempty"`
|
||||
|
||||
// LayeredBuild describes if this is build which layered scripts and sources on top of BuilderImage.
|
||||
LayeredBuild bool `json:"layeredBuild,omitempty"`
|
||||
|
||||
// Specify a relative directory inside the application repository that should
|
||||
// be used as a root directory for the application.
|
||||
ContextDir string `json:"contextDir,omitempty"`
|
||||
|
||||
// AssembleUser specifies the user to run the assemble script in container
|
||||
AssembleUser string `json:"assembleUser,omitempty"`
|
||||
|
||||
// RunImage will trigger a "docker run ..." invocation of the produced image so the user
|
||||
// can see if it operates as he would expect
|
||||
RunImage bool `json:"runImage,omitempty"`
|
||||
|
||||
// Usage allows for properly shortcircuiting s2i logic when `s2i usage` is invoked
|
||||
Usage bool `json:"usage,omitempty"`
|
||||
|
||||
// Injections specifies a list source/destination folders that are injected to
|
||||
// the container that runs assemble.
|
||||
// All files we inject will be truncated after the assemble script finishes.
|
||||
Injections []VolumeSpec `json:"injections,omitempty"`
|
||||
|
||||
// CGroupLimits describes the cgroups limits that will be applied to any containers
|
||||
// run by s2i.
|
||||
CGroupLimits *CGroupLimits `json:"cgroupLimits,omitempty"`
|
||||
|
||||
// DropCapabilities contains a list of capabilities to drop when executing containers
|
||||
DropCapabilities []string `json:"dropCapabilities,omitempty"`
|
||||
|
||||
// ScriptDownloadProxyConfig optionally specifies the http and https proxy
|
||||
// to use when downloading scripts
|
||||
ScriptDownloadProxyConfig *ProxyConfig `json:"scriptDownloadProxyConfig,omitempty"`
|
||||
|
||||
// ExcludeRegExp contains a string representation of the regular expression desired for
|
||||
// deciding which files to exclude from the tar stream
|
||||
ExcludeRegExp string `json:"excludeRegExp,omitempty"`
|
||||
|
||||
// BlockOnBuild prevents s2i from performing a docker build operation
|
||||
// if one is necessary to execute ONBUILD commands, or to layer source code into
|
||||
// the container for images that don't have a tar binary available, if the
|
||||
// image contains ONBUILD commands that would be executed.
|
||||
BlockOnBuild bool `json:"blockOnBuild,omitempty"`
|
||||
|
||||
// HasOnBuild will be set to true if the builder image contains ONBUILD instructions
|
||||
HasOnBuild bool `json:"hasOnBuild,omitempty"`
|
||||
|
||||
// BuildVolumes specifies a list of volumes to mount to container running the
|
||||
// build.
|
||||
BuildVolumes []string `json:"buildVolumes,omitempty"`
|
||||
|
||||
// Labels specify labels and their values to be applied to the resulting image. Label keys
|
||||
// must have non-zero length. The labels defined here override generated labels in case
|
||||
// they have the same name.
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
|
||||
// SecurityOpt are passed as options to the docker containers launched by s2i.
|
||||
SecurityOpt []string `json:"securityOpt,omitempty"`
|
||||
|
||||
// KeepSymlinks indicates to copy symlinks as symlinks. Default behavior is to follow
|
||||
// symlinks and copy files by content.
|
||||
KeepSymlinks bool `json:"keepSymlinks,omitempty"`
|
||||
|
||||
// AsDockerfile indicates the path where the Dockerfile should be written instead of building
|
||||
// a new image.
|
||||
AsDockerfile string `json:"asDockerfile,omitempty"`
|
||||
|
||||
// ImageWorkDir is the default working directory for the builder image.
|
||||
ImageWorkDir string `json:"imageWorkDir,omitempty"`
|
||||
|
||||
// ImageScriptsURL is the default location to find the assemble/run scripts for a builder image.
|
||||
// This url can be a reference within the builder image if the scheme is specified as image://
|
||||
ImageScriptsURL string `json:"imageScriptsUrl,omitempty"`
|
||||
|
||||
// AddHost Add a line to /etc/hosts for test purpose or private use in LAN. Its format is host:IP,muliple hosts can be added by using multiple --add-host
|
||||
AddHost []string `json:"addHost,omitempty"`
|
||||
|
||||
// Export Push the result image to specify image registry in tag
|
||||
Export bool `json:"export,omitempty"`
|
||||
|
||||
// SourceURL is url of the codes such as https://github.com/a/b.git
|
||||
SourceURL string `json:"sourceUrl"`
|
||||
|
||||
// IsBinaryURL explain the type of SourceURL.
|
||||
// If it is IsBinaryURL, it will download the file directly without using git.
|
||||
IsBinaryURL bool `json:"isBinaryURL,omitempty"`
|
||||
|
||||
// GitSecretRef is the BasicAuth Secret of Git Clone
|
||||
GitSecretRef *corev1.LocalObjectReference `json:"gitSecretRef,omitempty"`
|
||||
|
||||
// The RevisionId is a branch name or a SHA-1 hash of every important thing about the commit
|
||||
RevisionId string `json:"revisionId,omitempty"`
|
||||
|
||||
// The name of taint.
|
||||
TaintKey string `json:"taintKey,omitempty"`
|
||||
|
||||
// The key of Node Affinity.
|
||||
NodeAffinityKey string `json:"nodeAffinityKey,omitempty"`
|
||||
|
||||
// The values of Node Affinity.
|
||||
NodeAffinityValues []string `json:"nodeAffinityValues,omitempty"`
|
||||
|
||||
// Whether output build result to status.
|
||||
OutputBuildResult bool `json:"outputBuildResult,omitempty"`
|
||||
}
|
||||
|
||||
type UserDefineTemplate struct {
|
||||
//Name specify a template to use, so many fields in Config can left empty
|
||||
Name string `json:"name,omitempty"`
|
||||
//Parameters must use with `template`, fill some parameters which template will use
|
||||
Parameters []Parameter `json:"parameters,omitempty"`
|
||||
//BaseImage specify which version of this template to use
|
||||
BuilderImage string `json:"builderImage,omitempty"`
|
||||
}
|
||||
|
||||
// S2iBuilderSpec defines the desired state of S2iBuilder
|
||||
type S2iBuilderSpec struct {
|
||||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
Config *S2iConfig `json:"config,omitempty"`
|
||||
//FromTemplate define some inputs from user
|
||||
FromTemplate *UserDefineTemplate `json:"fromTemplate,omitempty"`
|
||||
}
|
||||
|
||||
// S2iBuilderStatus defines the observed state of S2iBuilder
|
||||
type S2iBuilderStatus struct {
|
||||
//RunCount represent the sum of s2irun of this builder
|
||||
RunCount int `json:"runCount"`
|
||||
//LastRunState return the state of the newest run of this builder
|
||||
LastRunState RunState `json:"lastRunState,omitempty"`
|
||||
//LastRunState return the name of the newest run of this builder
|
||||
LastRunName *string `json:"lastRunName,omitempty"`
|
||||
//LastRunStartTime return the startTime of the newest run of this builder
|
||||
LastRunStartTime *metav1.Time `json:"lastRunStartTime,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// S2iBuilder is the Schema for the s2ibuilders API
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="RunCount",type="integer",JSONPath=".status.runCount"
|
||||
// +kubebuilder:printcolumn:name="LastRunState",type="string",JSONPath=".status.lastRunState"
|
||||
// +kubebuilder:printcolumn:name="LastRunName",type="string",JSONPath=".status.lastRunName"
|
||||
// +kubebuilder:printcolumn:name="LastRunStartTime",type="date",JSONPath=".status.lastRunStartTime"
|
||||
// +kubebuilder:resource:shortName=s2ib
|
||||
type S2iBuilder struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec S2iBuilderSpec `json:"spec,omitempty"`
|
||||
Status S2iBuilderStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// S2iBuilderList contains a list of S2iBuilder
|
||||
type S2iBuilderList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []S2iBuilder `json:"items"`
|
||||
}
|
||||
|
||||
type S2iAutoScale struct {
|
||||
Kind string `json:"kind"`
|
||||
Name string `json:"name"`
|
||||
InitReplicas *int32 `json:"initReplicas,omitempty"`
|
||||
Containers []string `json:"containers,omitempty"`
|
||||
}
|
||||
|
||||
type DockerConfigJson struct {
|
||||
Auths DockerConfigMap `json:"auths"`
|
||||
}
|
||||
|
||||
// DockerConfig represents the config file used by the docker CLI.
|
||||
// This config that represents the credentials that should be used
|
||||
// when pulling images from specific image repositories.
|
||||
type DockerConfigMap map[string]DockerConfigEntry
|
||||
|
||||
type DockerConfigEntry struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Email string `json:"email"`
|
||||
ServerAddress string `json:"serverAddress,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&S2iBuilder{}, &S2iBuilderList{})
|
||||
}
|
||||
284
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/s2ibuilder_webhook.go
generated
vendored
284
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/s2ibuilder_webhook.go
generated
vendored
@@ -1,284 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/kubesphere/s2ioperator/pkg/errors"
|
||||
"github.com/kubesphere/s2ioperator/pkg/util/reflectutils"
|
||||
k8serror "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
errorutil "k8s.io/apimachinery/pkg/util/errors"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultRevisionId = "master"
|
||||
DefaultTag = "latest"
|
||||
)
|
||||
|
||||
// log is for logging in this package.
|
||||
var s2ibuilderlog = logf.Log.WithName("s2ibuilder-resource")
|
||||
|
||||
func (r *S2iBuilder) SetupWebhookWithManager(mgr ctrl.Manager) error {
|
||||
kclient = mgr.GetClient()
|
||||
return ctrl.NewWebhookManagedBy(mgr).
|
||||
For(r).
|
||||
Complete()
|
||||
}
|
||||
|
||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||
|
||||
// +kubebuilder:webhook:path=/mutate-devops-kubesphere-io-v1alpha1-s2ibuilder,mutating=true,failurePolicy=fail,groups=devops.kubesphere.io,resources=s2ibuilders,verbs=create;update,versions=v1alpha1,name=s2ibuilder.kb.io
|
||||
|
||||
var _ webhook.Defaulter = &S2iBuilder{}
|
||||
|
||||
// Default implements webhook.Defaulter so a webhook will be registered for the type
|
||||
func (r *S2iBuilder) Default() {
|
||||
s2ibuilderlog.Info("default", "name", r.Name)
|
||||
|
||||
if r.Spec.Config.RevisionId == "" {
|
||||
r.Spec.Config.RevisionId = DefaultRevisionId
|
||||
}
|
||||
|
||||
if r.Spec.Config.Tag == "" {
|
||||
r.Spec.Config.Tag = DefaultTag
|
||||
}
|
||||
|
||||
// TODO(user): fill in your defaulting logic.
|
||||
}
|
||||
|
||||
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
|
||||
// +kubebuilder:webhook:verbs=create;update,path=/validate-devops-kubesphere-io-v1alpha1-s2ibuilder,mutating=false,failurePolicy=fail,groups=devops.kubesphere.io,resources=s2ibuilders,versions=v1alpha1,name=vs2ibuilder.kb.io
|
||||
|
||||
var _ webhook.Validator = &S2iBuilder{}
|
||||
|
||||
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *S2iBuilder) ValidateCreate() error {
|
||||
s2ibuilderlog.Info("validate create", "name", r.Name)
|
||||
|
||||
fromTemplate := false
|
||||
if r.Spec.FromTemplate != nil {
|
||||
t := &S2iBuilderTemplate{}
|
||||
err := kclient.Get(context.TODO(), types.NamespacedName{Name: r.Spec.FromTemplate.Name}, t)
|
||||
if err != nil {
|
||||
if k8serror.IsNotFound(err) {
|
||||
return fmt.Errorf("Template not found, pls check the template name [%s] or create a template", r.Spec.FromTemplate.Name)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
errs := validateParameter(r.Spec.FromTemplate.Parameters, t.Spec.Parameters)
|
||||
if len(errs) != 0 {
|
||||
return errorutil.NewAggregate(errs)
|
||||
}
|
||||
var BaseImages []string
|
||||
for _, ImageInfo := range t.Spec.ContainerInfo {
|
||||
BaseImages = append(BaseImages, ImageInfo.BuilderImage)
|
||||
}
|
||||
if r.Spec.FromTemplate.BuilderImage != "" {
|
||||
if !reflectutils.Contains(r.Spec.FromTemplate.BuilderImage, BaseImages) {
|
||||
return fmt.Errorf("builder's baseImage [%s] not in builder baseImages [%v]",
|
||||
r.Spec.FromTemplate.BuilderImage, BaseImages)
|
||||
}
|
||||
}
|
||||
fromTemplate = true
|
||||
}
|
||||
if anno, ok := r.Annotations[AutoScaleAnnotations]; ok {
|
||||
if err := validatingS2iBuilderAutoScale(anno); err != nil {
|
||||
return errors.NewFieldInvalidValueWithReason(AutoScaleAnnotations, err.Error())
|
||||
}
|
||||
}
|
||||
if errs := validateConfig(r.Spec.Config, fromTemplate); len(errs) == 0 {
|
||||
return nil
|
||||
} else {
|
||||
return errorutil.NewAggregate(errs)
|
||||
}
|
||||
}
|
||||
|
||||
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *S2iBuilder) ValidateUpdate(old runtime.Object) error {
|
||||
s2ibuilderlog.Info("validate update", "name", r.Name)
|
||||
|
||||
s2ibuilderlog.Info("validate create", "name", r.Name)
|
||||
|
||||
fromTemplate := false
|
||||
if r.Spec.FromTemplate != nil {
|
||||
t := &S2iBuilderTemplate{}
|
||||
err := kclient.Get(context.TODO(), types.NamespacedName{Name: r.Spec.FromTemplate.Name}, t)
|
||||
if err != nil {
|
||||
if k8serror.IsNotFound(err) {
|
||||
return fmt.Errorf("Template not found, pls check the template name [%s] or create a template", r.Spec.FromTemplate.Name)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
errs := validateParameter(r.Spec.FromTemplate.Parameters, t.Spec.Parameters)
|
||||
if len(errs) != 0 {
|
||||
return errorutil.NewAggregate(errs)
|
||||
}
|
||||
var BaseImages []string
|
||||
for _, ImageInfo := range t.Spec.ContainerInfo {
|
||||
BaseImages = append(BaseImages, ImageInfo.BuilderImage)
|
||||
}
|
||||
if r.Spec.FromTemplate.BuilderImage != "" {
|
||||
if !reflectutils.Contains(r.Spec.FromTemplate.BuilderImage, BaseImages) {
|
||||
return fmt.Errorf("builder's baseImage [%s] not in builder baseImages [%v]",
|
||||
r.Spec.FromTemplate.BuilderImage, BaseImages)
|
||||
}
|
||||
}
|
||||
fromTemplate = true
|
||||
}
|
||||
if anno, ok := r.Annotations[AutoScaleAnnotations]; ok {
|
||||
if err := validatingS2iBuilderAutoScale(anno); err != nil {
|
||||
return errors.NewFieldInvalidValueWithReason(AutoScaleAnnotations, err.Error())
|
||||
}
|
||||
}
|
||||
if errs := validateConfig(r.Spec.Config, fromTemplate); len(errs) == 0 {
|
||||
return nil
|
||||
} else {
|
||||
return errorutil.NewAggregate(errs)
|
||||
}
|
||||
}
|
||||
|
||||
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *S2iBuilder) ValidateDelete() error {
|
||||
s2ibuilderlog.Info("validate delete", "name", r.Name)
|
||||
|
||||
// TODO(user): fill in your validation logic upon object deletion.
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateConfig returns a list of error from validation.
|
||||
func validateConfig(config *S2iConfig, fromTemplate bool) []error {
|
||||
allErrs := make([]error, 0)
|
||||
if !config.IsBinaryURL && len(config.SourceURL) == 0 {
|
||||
allErrs = append(allErrs, errors.NewFieldRequired("sourceUrl"))
|
||||
}
|
||||
if !fromTemplate && len(config.BuilderImage) == 0 {
|
||||
allErrs = append(allErrs, errors.NewFieldRequired("builderImage"))
|
||||
}
|
||||
switch config.BuilderPullPolicy {
|
||||
case PullNever, PullAlways, PullIfNotPresent:
|
||||
default:
|
||||
allErrs = append(allErrs, errors.NewFieldInvalidValue("builderPullPolicy"))
|
||||
}
|
||||
if config.DockerNetworkMode != "" && !validateDockerNetworkMode(config.DockerNetworkMode) {
|
||||
allErrs = append(allErrs, errors.NewFieldInvalidValue("dockerNetworkMode"))
|
||||
}
|
||||
if config.Labels != nil {
|
||||
for k := range config.Labels {
|
||||
if len(k) == 0 {
|
||||
allErrs = append(allErrs, errors.NewFieldInvalidValue("labels"))
|
||||
}
|
||||
}
|
||||
}
|
||||
if config.BuilderImage != "" {
|
||||
if err := validateDockerReference(config.BuilderImage); err != nil {
|
||||
allErrs = append(allErrs, errors.NewFieldInvalidValueWithReason("builderImage", err.Error()))
|
||||
}
|
||||
}
|
||||
if config.RuntimeAuthentication != nil {
|
||||
if config.RuntimeAuthentication.SecretRef == nil {
|
||||
if config.RuntimeAuthentication.Username == "" && config.RuntimeAuthentication.Password == "" {
|
||||
allErrs = append(allErrs, errors.NewFieldRequired("RuntimeAuthentication username|password / secretRef"))
|
||||
}
|
||||
}
|
||||
}
|
||||
if config.IncrementalAuthentication != nil {
|
||||
if config.IncrementalAuthentication.SecretRef == nil {
|
||||
if config.IncrementalAuthentication.Username == "" && config.IncrementalAuthentication.Password == "" {
|
||||
allErrs = append(allErrs, errors.NewFieldRequired("IncrementalAuthentication username|password / secretRef"))
|
||||
}
|
||||
}
|
||||
}
|
||||
if config.PullAuthentication != nil {
|
||||
if config.PullAuthentication.SecretRef == nil {
|
||||
if config.PullAuthentication.Username == "" && config.PullAuthentication.Password == "" {
|
||||
allErrs = append(allErrs, errors.NewFieldRequired("PullAuthentication username|password / secretRef"))
|
||||
}
|
||||
}
|
||||
}
|
||||
if config.PushAuthentication != nil {
|
||||
if config.PushAuthentication.SecretRef == nil {
|
||||
if config.PushAuthentication.Username == "" && config.PushAuthentication.Password == "" {
|
||||
allErrs = append(allErrs, errors.NewFieldRequired("PushAuthentication username|password / secretRef"))
|
||||
}
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validateDockerNetworkMode checks wether the network mode conforms to the docker remote API specification (v1.19)
|
||||
// Supported values are: bridge, host, container:<name|id>, and netns:/proc/<pid>/ns/net
|
||||
func validateDockerNetworkMode(mode DockerNetworkMode) bool {
|
||||
switch mode {
|
||||
case DockerNetworkModeBridge, DockerNetworkModeHost:
|
||||
return true
|
||||
}
|
||||
if strings.HasPrefix(string(mode), DockerNetworkModeContainerPrefix) {
|
||||
return true
|
||||
}
|
||||
if strings.HasPrefix(string(mode), DockerNetworkModeNetworkNamespacePrefix) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func validateParameter(user, tmpt []Parameter) []error {
|
||||
findParameter := func(name string, ps []Parameter) int {
|
||||
for index, v := range ps {
|
||||
if v.Key == name {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
allErrs := make([]error, 0)
|
||||
for _, v := range tmpt {
|
||||
index := findParameter(v.Key, user)
|
||||
if v.Required && (index == -1 || user[index].Value == "") {
|
||||
allErrs = append(allErrs, errors.NewFieldRequired("Parameter:"+v.Key))
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validatingS2iBuilderAutoScale(anno string) error {
|
||||
|
||||
s2iAutoScale := make([]S2iAutoScale, 0)
|
||||
if err := json.Unmarshal([]byte(anno), &s2iAutoScale); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, scale := range s2iAutoScale {
|
||||
switch scale.Kind {
|
||||
case KindStatefulSet:
|
||||
return nil
|
||||
case KindDeployment:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("unsupport workload type [%s], name [%s]", scale.Kind, scale.Name)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindS2iBuilderTemplate = "S2iBuilderTemplate"
|
||||
ResourceSingularS2iBuilderTemplate = "s2ibuildertemplate"
|
||||
ResourcePluralS2iBuilderTemplate = "s2ibuildertemplates"
|
||||
)
|
||||
|
||||
type Parameter struct {
|
||||
Description string `json:"description,omitempty"`
|
||||
Key string `json:"key,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
OptValues []string `json:"optValues,omitempty"`
|
||||
Required bool `json:"required,omitempty"`
|
||||
DefaultValue string `json:"defaultValue,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
func (p *Parameter) ToEnvonment() *EnvironmentSpec {
|
||||
var v string
|
||||
if p.Value == "" && p.DefaultValue != "" {
|
||||
v = p.DefaultValue
|
||||
} else if p.Value != "" {
|
||||
v = p.Value
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return &EnvironmentSpec{
|
||||
Name: p.Key,
|
||||
Value: v,
|
||||
}
|
||||
}
|
||||
|
||||
// S2iBuilderTemplateSpec defines the desired state of S2iBuilderTemplate
|
||||
type S2iBuilderTemplateSpec struct {
|
||||
//DefaultBaseImage is the image that will be used by default
|
||||
DefaultBaseImage string `json:"defaultBaseImage,omitempty"`
|
||||
//Images are the images this template will use.
|
||||
ContainerInfo []ContainerInfo `json:"containerInfo,omitempty"`
|
||||
//CodeFramework means which language this template is designed for and which framework is using if has framework. Like Java, NodeJS etc
|
||||
CodeFramework CodeFramework `json:"codeFramework,omitempty"`
|
||||
// Parameters is a set of environment variables to be passed to the image.
|
||||
Parameters []Parameter `json:"environment,omitempty"`
|
||||
// Version of template
|
||||
Version string `json:"version,omitempty"`
|
||||
// Description illustrate the purpose of this template
|
||||
Description string `json:"description,omitempty"`
|
||||
// IconPath is used for frontend display
|
||||
IconPath string `json:"iconPath,omitempty"`
|
||||
}
|
||||
|
||||
type ContainerInfo struct {
|
||||
//BaseImage are the images this template will use.
|
||||
BuilderImage string `json:"builderImage,omitempty"`
|
||||
RuntimeImage string `json:"runtimeImage,omitempty"`
|
||||
RuntimeArtifacts []VolumeSpec `json:"runtimeArtifacts,omitempty"`
|
||||
// BuildVolumes specifies a list of volumes to mount to container running the
|
||||
// build.
|
||||
BuildVolumes []string `json:"buildVolumes,omitempty"`
|
||||
}
|
||||
|
||||
// S2iBuilderTemplateStatus defines the observed state of S2iBuilderTemplate
|
||||
type S2iBuilderTemplateStatus struct {
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// S2iBuilderTemplate is the Schema for the s2ibuildertemplates API
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:printcolumn:name="Framework",type="string",JSONPath=".spec.codeFramework"
|
||||
// +kubebuilder:printcolumn:name="DefaultBaseImage",type="string",JSONPath=".spec.defaultBaseImage"
|
||||
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version"
|
||||
// +kubebuilder:resource:categories="devops",scope="Cluster",shortName="s2ibt"
|
||||
type S2iBuilderTemplate struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec S2iBuilderTemplateSpec `json:"spec,omitempty"`
|
||||
Status S2iBuilderTemplateStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// S2iBuilderTemplateList contains a list of S2iBuilderTemplate
|
||||
type S2iBuilderTemplateList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []S2iBuilderTemplate `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&S2iBuilderTemplate{}, &S2iBuilderTemplateList{})
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/kubesphere/s2ioperator/pkg/errors"
|
||||
"github.com/kubesphere/s2ioperator/pkg/util/reflectutils"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||
)
|
||||
|
||||
// log is for logging in this package.
|
||||
var s2ibuildertemplatelog = logf.Log.WithName("s2ibuildertemplate-resource")
|
||||
|
||||
func (r *S2iBuilderTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
|
||||
kclient = mgr.GetClient()
|
||||
return ctrl.NewWebhookManagedBy(mgr).
|
||||
For(r).
|
||||
Complete()
|
||||
}
|
||||
|
||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||
|
||||
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
|
||||
// +kubebuilder:webhook:verbs=create;update,path=/validate-devops-kubesphere-io-v1alpha1-s2ibuildertemplate,mutating=false,failurePolicy=fail,groups=devops.kubesphere.io,resources=s2ibuildertemplates,versions=v1alpha1,name=s2ibuildertemplate.kb.io
|
||||
|
||||
var _ webhook.Validator = &S2iBuilderTemplate{}
|
||||
|
||||
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *S2iBuilderTemplate) ValidateCreate() error {
|
||||
s2ibuildertemplatelog.Info("validate create", "name", r.Name)
|
||||
|
||||
if len(r.Spec.ContainerInfo) == 0 {
|
||||
return errors.NewFieldRequired("baseImages")
|
||||
}
|
||||
|
||||
if r.Spec.DefaultBaseImage == "" {
|
||||
return errors.NewFieldRequired("defaultBaseImage")
|
||||
}
|
||||
var builderImages []string
|
||||
for _, ImageInfo := range r.Spec.ContainerInfo {
|
||||
builderImages = append(builderImages, ImageInfo.BuilderImage)
|
||||
}
|
||||
if !reflectutils.Contains(r.Spec.DefaultBaseImage, builderImages) {
|
||||
return errors.NewFieldInvalidValueWithReason("defaultBaseImage",
|
||||
fmt.Sprintf("defaultBaseImage [%s] should in [%v]", r.Spec.DefaultBaseImage, builderImages))
|
||||
}
|
||||
|
||||
for _, ImageInfo := range r.Spec.ContainerInfo {
|
||||
if err := validateDockerReference(ImageInfo.BuilderImage); err != nil {
|
||||
return errors.NewFieldInvalidValueWithReason("builderImage", err.Error())
|
||||
}
|
||||
}
|
||||
if err := validateDockerReference(r.Spec.DefaultBaseImage); err != nil {
|
||||
return errors.NewFieldInvalidValueWithReason("defaultBaseImage", err.Error())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *S2iBuilderTemplate) ValidateUpdate(old runtime.Object) error {
|
||||
s2ibuildertemplatelog.Info("validate update", "name", r.Name)
|
||||
|
||||
if len(r.Spec.ContainerInfo) == 0 {
|
||||
return errors.NewFieldRequired("baseImages")
|
||||
}
|
||||
|
||||
if r.Spec.DefaultBaseImage == "" {
|
||||
return errors.NewFieldRequired("defaultBaseImage")
|
||||
}
|
||||
var builderImages []string
|
||||
for _, ImageInfo := range r.Spec.ContainerInfo {
|
||||
builderImages = append(builderImages, ImageInfo.BuilderImage)
|
||||
}
|
||||
if !reflectutils.Contains(r.Spec.DefaultBaseImage, builderImages) {
|
||||
return errors.NewFieldInvalidValueWithReason("defaultBaseImage",
|
||||
fmt.Sprintf("defaultBaseImage [%s] should in [%v]", r.Spec.DefaultBaseImage, builderImages))
|
||||
}
|
||||
|
||||
for _, ImageInfo := range r.Spec.ContainerInfo {
|
||||
if err := validateDockerReference(ImageInfo.BuilderImage); err != nil {
|
||||
return errors.NewFieldInvalidValueWithReason("builderImage", err.Error())
|
||||
}
|
||||
}
|
||||
if err := validateDockerReference(r.Spec.DefaultBaseImage); err != nil {
|
||||
return errors.NewFieldInvalidValueWithReason("defaultBaseImage", err.Error())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *S2iBuilderTemplate) ValidateDelete() error {
|
||||
s2ibuildertemplatelog.Info("validate delete", "name", r.Name)
|
||||
|
||||
// TODO(user): fill in your validation logic upon object deletion.
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateDockerReference(ref string) error {
|
||||
_, err := reference.Parse(ref)
|
||||
return err
|
||||
}
|
||||
141
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/s2irun_types.go
generated
vendored
141
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/s2irun_types.go
generated
vendored
@@ -1,141 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||
|
||||
const (
|
||||
ResourceKindS2iRun = "S2iRun"
|
||||
ResourceSingularS2iRun = "s2irun"
|
||||
ResourcePluralS2iRun = "s2iruns"
|
||||
)
|
||||
|
||||
// S2iRunSpec defines the desired state of S2iRun
|
||||
type S2iRunSpec struct {
|
||||
//BuilderName specify the name of s2ibuilder, required
|
||||
BuilderName string `json:"builderName"`
|
||||
//BackoffLimit limits the restart count of each s2irun. Default is 0
|
||||
BackoffLimit int32 `json:"backoffLimit,omitempty"`
|
||||
//SecondsAfterFinished if is set and greater than zero, and the job created by s2irun become successful or failed , the job will be auto deleted after SecondsAfterFinished
|
||||
SecondsAfterFinished int32 `json:"secondsAfterFinished,omitempty"`
|
||||
//NewTag override the default tag in its s2ibuilder, image name cannot be changed.
|
||||
NewTag string `json:"newTag,omitempty"`
|
||||
//NewRevisionId override the default NewRevisionId in its s2ibuilder.
|
||||
NewRevisionId string `json:"newRevisionId,omitempty"`
|
||||
//NewSourceURL is used to download new binary artifacts
|
||||
NewSourceURL string `json:"newSourceURL,omitempty"`
|
||||
}
|
||||
|
||||
// S2iRunStatus defines the observed state of S2iRun
|
||||
type S2iRunStatus struct {
|
||||
// StartTime represent when this run began
|
||||
StartTime *metav1.Time `json:"startTime,omitempty" protobuf:"bytes,2,opt,name=startTime"`
|
||||
|
||||
// Represents time when the job was completed. It is not guaranteed to
|
||||
// be set in happens-before order across separate operations.
|
||||
// It is represented in RFC3339 form and is in UTC.
|
||||
// +optional
|
||||
CompletionTime *metav1.Time `json:"completionTime,omitempty" protobuf:"bytes,3,opt,name=completionTime"`
|
||||
// RunState indicates whether this job is done or failed
|
||||
RunState RunState `json:"runState,omitempty"`
|
||||
//LogURL is uesd for external log handler to let user know where is log located in
|
||||
LogURL string `json:"logURL,omitempty"`
|
||||
//KubernetesJobName is the job name in k8s
|
||||
KubernetesJobName string `json:"kubernetesJobName,omitempty"`
|
||||
|
||||
// S2i build result info.
|
||||
S2iBuildResult *S2iBuildResult `json:"s2iBuildResult,omitempty"`
|
||||
// S2i build source info.
|
||||
S2iBuildSource *S2iBuildSource `json:"s2iBuildSource,omitempty"`
|
||||
}
|
||||
|
||||
type S2iBuildResult struct {
|
||||
//ImageName is the name of artifact
|
||||
ImageName string `json:"imageName,omitempty"`
|
||||
//The size in bytes of the image
|
||||
ImageSize int64 `json:"imageSize,omitempty"`
|
||||
// Image ID.
|
||||
ImageID string `json:"imageID,omitempty"`
|
||||
// Image created time.
|
||||
ImageCreated string `json:"imageCreated,omitempty"`
|
||||
// image tags.
|
||||
ImageRepoTags []string `json:"imageRepoTags,omitempty"`
|
||||
// Command for pull image.
|
||||
CommandPull string `json:"commandPull,omitempty"`
|
||||
}
|
||||
|
||||
type S2iBuildSource struct {
|
||||
// SourceURL is url of the codes such as https://github.com/a/b.git
|
||||
SourceUrl string `json:"sourceUrl,omitempty"`
|
||||
// The RevisionId is a branch name or a SHA-1 hash of every important thing about the commit
|
||||
RevisionId string `json:"revisionId,omitempty"`
|
||||
// Binary file Name
|
||||
BinaryName string `json:"binaryName,omitempty"`
|
||||
// Binary file Size
|
||||
BinarySize uint64 `json:"binarySize,omitempty"`
|
||||
|
||||
// // BuilderImage describes which image is used for building the result images.
|
||||
BuilderImage string `json:"builderImage,omitempty"`
|
||||
// Description is a result image description label. The default is no
|
||||
// description.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// CommitID represents an arbitrary extended object reference in Git as SHA-1
|
||||
CommitID string `json:"commitID,omitempty"`
|
||||
// CommitterName contains the name of the committer
|
||||
CommitterName string `json:"committerName,omitempty"`
|
||||
// CommitterEmail contains the e-mail of the committer
|
||||
CommitterEmail string `json:"committerEmail,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// S2iRun is the Schema for the s2iruns API
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:resource:shortName=s2ir
|
||||
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.runState"
|
||||
// +kubebuilder:printcolumn:name="K8sJobName",type="string",JSONPath=".status.kubernetesJobName"
|
||||
// +kubebuilder:printcolumn:name="StartTime",type="date",JSONPath=".status.startTime"
|
||||
// +kubebuilder:printcolumn:name="CompletionTime",type="date",JSONPath=".status.completionTime"
|
||||
// +kubebuilder:printcolumn:name="ImageName",type="string",JSONPath=".status.s2iBuildResult.imageName"
|
||||
type S2iRun struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec S2iRunSpec `json:"spec,omitempty"`
|
||||
Status S2iRunStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// S2iRunList contains a list of S2iRun
|
||||
type S2iRunList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []S2iRun `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&S2iRun{}, &S2iRunList{})
|
||||
}
|
||||
125
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/s2irun_webhook.go
generated
vendored
125
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/s2irun_webhook.go
generated
vendored
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/kubesphere/s2ioperator/pkg/errors"
|
||||
k8serror "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"reflect"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||
)
|
||||
|
||||
// log is for logging in this package.
|
||||
var (
|
||||
s2irunlog = logf.Log.WithName("s2irun-resource")
|
||||
kclient client.Client
|
||||
)
|
||||
|
||||
func (r *S2iRun) SetupWebhookWithManager(mgr ctrl.Manager) error {
|
||||
kclient = mgr.GetClient()
|
||||
return ctrl.NewWebhookManagedBy(mgr).
|
||||
For(r).
|
||||
Complete()
|
||||
}
|
||||
|
||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||
|
||||
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
|
||||
// +kubebuilder:webhook:verbs=create;update,path=/validate-devops-kubesphere-io-v1alpha1-s2irun,mutating=false,failurePolicy=fail,groups=devops.kubesphere.io,resources=s2iruns,versions=v1alpha1,name=vs2irun.kb.io
|
||||
|
||||
var _ webhook.Validator = &S2iRun{}
|
||||
|
||||
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *S2iRun) ValidateCreate() error {
|
||||
s2irunlog.Info("validate create", "name", r.Name)
|
||||
|
||||
origin := &S2iRun{}
|
||||
|
||||
builder := &S2iBuilder{}
|
||||
|
||||
err := kclient.Get(context.TODO(), types.NamespacedName{Namespace: r.Namespace, Name: r.Spec.BuilderName}, builder)
|
||||
if err != nil && !k8serror.IsNotFound(err) {
|
||||
return errors.NewFieldInvalidValueWithReason("no", "could not call k8s api")
|
||||
}
|
||||
if !k8serror.IsNotFound(err) {
|
||||
if r.Spec.NewSourceURL != "" && !builder.Spec.Config.IsBinaryURL {
|
||||
return errors.NewFieldInvalidValueWithReason("newSourceURL", "only b2i could set newSourceURL")
|
||||
}
|
||||
}
|
||||
|
||||
err = kclient.Get(context.TODO(), types.NamespacedName{Namespace: r.Namespace, Name: r.Name}, origin)
|
||||
if !k8serror.IsNotFound(err) && origin.Status.RunState != "" && !reflect.DeepEqual(origin.Spec, r.Spec) {
|
||||
return errors.NewFieldInvalidValueWithReason("spec", "should not change s2i run spec when job started")
|
||||
}
|
||||
|
||||
if r.Spec.NewTag != "" {
|
||||
validateImageName := fmt.Sprintf("validate:%s", r.Spec.NewTag)
|
||||
if err := validateDockerReference(validateImageName); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *S2iRun) ValidateUpdate(old runtime.Object) error {
|
||||
s2irunlog.Info("validate update", "name", r.Name)
|
||||
|
||||
origin := &S2iRun{}
|
||||
|
||||
builder := &S2iBuilder{}
|
||||
|
||||
err := kclient.Get(context.TODO(), types.NamespacedName{Namespace: r.Namespace, Name: r.Spec.BuilderName}, builder)
|
||||
if err != nil && !k8serror.IsNotFound(err) {
|
||||
return errors.NewFieldInvalidValueWithReason("no", "could not call k8s api")
|
||||
}
|
||||
if !k8serror.IsNotFound(err) {
|
||||
if r.Spec.NewSourceURL != "" && !builder.Spec.Config.IsBinaryURL {
|
||||
return errors.NewFieldInvalidValueWithReason("newSourceURL", "only b2i could set newSourceURL")
|
||||
}
|
||||
}
|
||||
|
||||
err = kclient.Get(context.TODO(), types.NamespacedName{Namespace: r.Namespace, Name: r.Name}, origin)
|
||||
if !k8serror.IsNotFound(err) && origin.Status.RunState != "" && !reflect.DeepEqual(origin.Spec, r.Spec) {
|
||||
return errors.NewFieldInvalidValueWithReason("spec", "should not change s2i run spec when job started")
|
||||
}
|
||||
|
||||
if r.Spec.NewTag != "" {
|
||||
validateImageName := fmt.Sprintf("validate:%s", r.Spec.NewTag)
|
||||
if err := validateDockerReference(validateImageName); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *S2iRun) ValidateDelete() error {
|
||||
s2irunlog.Info("validate delete", "name", r.Name)
|
||||
|
||||
// TODO(user): fill in your validation logic upon object deletion.
|
||||
return nil
|
||||
}
|
||||
753
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/zz_generated.deepcopy.go
generated
vendored
753
vendor/github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1/zz_generated.deepcopy.go
generated
vendored
@@ -1,753 +0,0 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AuthConfig) DeepCopyInto(out *AuthConfig) {
|
||||
*out = *in
|
||||
if in.SecretRef != nil {
|
||||
in, out := &in.SecretRef, &out.SecretRef
|
||||
*out = new(v1.LocalObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthConfig.
|
||||
func (in *AuthConfig) DeepCopy() *AuthConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(AuthConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *CGroupLimits) DeepCopyInto(out *CGroupLimits) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CGroupLimits.
|
||||
func (in *CGroupLimits) DeepCopy() *CGroupLimits {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(CGroupLimits)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ContainerConfig) DeepCopyInto(out *ContainerConfig) {
|
||||
*out = *in
|
||||
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.Env != nil {
|
||||
in, out := &in.Env, &out.Env
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerConfig.
|
||||
func (in *ContainerConfig) DeepCopy() *ContainerConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ContainerConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ContainerInfo) DeepCopyInto(out *ContainerInfo) {
|
||||
*out = *in
|
||||
if in.RuntimeArtifacts != nil {
|
||||
in, out := &in.RuntimeArtifacts, &out.RuntimeArtifacts
|
||||
*out = make([]VolumeSpec, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.BuildVolumes != nil {
|
||||
in, out := &in.BuildVolumes, &out.BuildVolumes
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerInfo.
|
||||
func (in *ContainerInfo) DeepCopy() *ContainerInfo {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ContainerInfo)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DockerConfig) DeepCopyInto(out *DockerConfig) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DockerConfig.
|
||||
func (in *DockerConfig) DeepCopy() *DockerConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DockerConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DockerConfigEntry) DeepCopyInto(out *DockerConfigEntry) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DockerConfigEntry.
|
||||
func (in *DockerConfigEntry) DeepCopy() *DockerConfigEntry {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DockerConfigEntry)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DockerConfigJson) DeepCopyInto(out *DockerConfigJson) {
|
||||
*out = *in
|
||||
if in.Auths != nil {
|
||||
in, out := &in.Auths, &out.Auths
|
||||
*out = make(DockerConfigMap, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DockerConfigJson.
|
||||
func (in *DockerConfigJson) DeepCopy() *DockerConfigJson {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DockerConfigJson)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in DockerConfigMap) DeepCopyInto(out *DockerConfigMap) {
|
||||
{
|
||||
in := &in
|
||||
*out = make(DockerConfigMap, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DockerConfigMap.
|
||||
func (in DockerConfigMap) DeepCopy() DockerConfigMap {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DockerConfigMap)
|
||||
in.DeepCopyInto(out)
|
||||
return *out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *EnvironmentSpec) DeepCopyInto(out *EnvironmentSpec) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvironmentSpec.
|
||||
func (in *EnvironmentSpec) DeepCopy() *EnvironmentSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(EnvironmentSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Parameter) DeepCopyInto(out *Parameter) {
|
||||
*out = *in
|
||||
if in.OptValues != nil {
|
||||
in, out := &in.OptValues, &out.OptValues
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Parameter.
|
||||
func (in *Parameter) DeepCopy() *Parameter {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Parameter)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ProxyConfig) DeepCopyInto(out *ProxyConfig) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProxyConfig.
|
||||
func (in *ProxyConfig) DeepCopy() *ProxyConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ProxyConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iAutoScale) DeepCopyInto(out *S2iAutoScale) {
|
||||
*out = *in
|
||||
if in.InitReplicas != nil {
|
||||
in, out := &in.InitReplicas, &out.InitReplicas
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
if in.Containers != nil {
|
||||
in, out := &in.Containers, &out.Containers
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iAutoScale.
|
||||
func (in *S2iAutoScale) DeepCopy() *S2iAutoScale {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iAutoScale)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iBuildResult) DeepCopyInto(out *S2iBuildResult) {
|
||||
*out = *in
|
||||
if in.ImageRepoTags != nil {
|
||||
in, out := &in.ImageRepoTags, &out.ImageRepoTags
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuildResult.
|
||||
func (in *S2iBuildResult) DeepCopy() *S2iBuildResult {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuildResult)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iBuildSource) DeepCopyInto(out *S2iBuildSource) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuildSource.
|
||||
func (in *S2iBuildSource) DeepCopy() *S2iBuildSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuildSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iBuilder) DeepCopyInto(out *S2iBuilder) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuilder.
|
||||
func (in *S2iBuilder) DeepCopy() *S2iBuilder {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuilder)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *S2iBuilder) 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 *S2iBuilderList) DeepCopyInto(out *S2iBuilderList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]S2iBuilder, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuilderList.
|
||||
func (in *S2iBuilderList) DeepCopy() *S2iBuilderList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuilderList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *S2iBuilderList) 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 *S2iBuilderSpec) DeepCopyInto(out *S2iBuilderSpec) {
|
||||
*out = *in
|
||||
if in.Config != nil {
|
||||
in, out := &in.Config, &out.Config
|
||||
*out = new(S2iConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.FromTemplate != nil {
|
||||
in, out := &in.FromTemplate, &out.FromTemplate
|
||||
*out = new(UserDefineTemplate)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuilderSpec.
|
||||
func (in *S2iBuilderSpec) DeepCopy() *S2iBuilderSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuilderSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iBuilderStatus) DeepCopyInto(out *S2iBuilderStatus) {
|
||||
*out = *in
|
||||
if in.LastRunName != nil {
|
||||
in, out := &in.LastRunName, &out.LastRunName
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.LastRunStartTime != nil {
|
||||
in, out := &in.LastRunStartTime, &out.LastRunStartTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuilderStatus.
|
||||
func (in *S2iBuilderStatus) DeepCopy() *S2iBuilderStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuilderStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iBuilderTemplate) DeepCopyInto(out *S2iBuilderTemplate) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuilderTemplate.
|
||||
func (in *S2iBuilderTemplate) DeepCopy() *S2iBuilderTemplate {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuilderTemplate)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *S2iBuilderTemplate) 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 *S2iBuilderTemplateList) DeepCopyInto(out *S2iBuilderTemplateList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]S2iBuilderTemplate, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuilderTemplateList.
|
||||
func (in *S2iBuilderTemplateList) DeepCopy() *S2iBuilderTemplateList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuilderTemplateList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *S2iBuilderTemplateList) 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 *S2iBuilderTemplateSpec) DeepCopyInto(out *S2iBuilderTemplateSpec) {
|
||||
*out = *in
|
||||
if in.ContainerInfo != nil {
|
||||
in, out := &in.ContainerInfo, &out.ContainerInfo
|
||||
*out = make([]ContainerInfo, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.Parameters != nil {
|
||||
in, out := &in.Parameters, &out.Parameters
|
||||
*out = make([]Parameter, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuilderTemplateSpec.
|
||||
func (in *S2iBuilderTemplateSpec) DeepCopy() *S2iBuilderTemplateSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuilderTemplateSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iBuilderTemplateStatus) DeepCopyInto(out *S2iBuilderTemplateStatus) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuilderTemplateStatus.
|
||||
func (in *S2iBuilderTemplateStatus) DeepCopy() *S2iBuilderTemplateStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBuilderTemplateStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iConfig) DeepCopyInto(out *S2iConfig) {
|
||||
*out = *in
|
||||
if in.RuntimeAuthentication != nil {
|
||||
in, out := &in.RuntimeAuthentication, &out.RuntimeAuthentication
|
||||
*out = new(AuthConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.RuntimeArtifacts != nil {
|
||||
in, out := &in.RuntimeArtifacts, &out.RuntimeArtifacts
|
||||
*out = make([]VolumeSpec, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.DockerConfig != nil {
|
||||
in, out := &in.DockerConfig, &out.DockerConfig
|
||||
*out = new(DockerConfig)
|
||||
**out = **in
|
||||
}
|
||||
if in.PullAuthentication != nil {
|
||||
in, out := &in.PullAuthentication, &out.PullAuthentication
|
||||
*out = new(AuthConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.PushAuthentication != nil {
|
||||
in, out := &in.PushAuthentication, &out.PushAuthentication
|
||||
*out = new(AuthConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.IncrementalAuthentication != nil {
|
||||
in, out := &in.IncrementalAuthentication, &out.IncrementalAuthentication
|
||||
*out = new(AuthConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Environment != nil {
|
||||
in, out := &in.Environment, &out.Environment
|
||||
*out = make([]EnvironmentSpec, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Injections != nil {
|
||||
in, out := &in.Injections, &out.Injections
|
||||
*out = make([]VolumeSpec, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.CGroupLimits != nil {
|
||||
in, out := &in.CGroupLimits, &out.CGroupLimits
|
||||
*out = new(CGroupLimits)
|
||||
**out = **in
|
||||
}
|
||||
if in.DropCapabilities != nil {
|
||||
in, out := &in.DropCapabilities, &out.DropCapabilities
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.ScriptDownloadProxyConfig != nil {
|
||||
in, out := &in.ScriptDownloadProxyConfig, &out.ScriptDownloadProxyConfig
|
||||
*out = new(ProxyConfig)
|
||||
**out = **in
|
||||
}
|
||||
if in.BuildVolumes != nil {
|
||||
in, out := &in.BuildVolumes, &out.BuildVolumes
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
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.SecurityOpt != nil {
|
||||
in, out := &in.SecurityOpt, &out.SecurityOpt
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.AddHost != nil {
|
||||
in, out := &in.AddHost, &out.AddHost
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.GitSecretRef != nil {
|
||||
in, out := &in.GitSecretRef, &out.GitSecretRef
|
||||
*out = new(v1.LocalObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
if in.NodeAffinityValues != nil {
|
||||
in, out := &in.NodeAffinityValues, &out.NodeAffinityValues
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iConfig.
|
||||
func (in *S2iConfig) DeepCopy() *S2iConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iRun) DeepCopyInto(out *S2iRun) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iRun.
|
||||
func (in *S2iRun) DeepCopy() *S2iRun {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iRun)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *S2iRun) 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 *S2iRunList) DeepCopyInto(out *S2iRunList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]S2iRun, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iRunList.
|
||||
func (in *S2iRunList) DeepCopy() *S2iRunList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iRunList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *S2iRunList) 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 *S2iRunSpec) DeepCopyInto(out *S2iRunSpec) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iRunSpec.
|
||||
func (in *S2iRunSpec) DeepCopy() *S2iRunSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iRunSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iRunStatus) DeepCopyInto(out *S2iRunStatus) {
|
||||
*out = *in
|
||||
if in.StartTime != nil {
|
||||
in, out := &in.StartTime, &out.StartTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
if in.CompletionTime != nil {
|
||||
in, out := &in.CompletionTime, &out.CompletionTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
if in.S2iBuildResult != nil {
|
||||
in, out := &in.S2iBuildResult, &out.S2iBuildResult
|
||||
*out = new(S2iBuildResult)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.S2iBuildSource != nil {
|
||||
in, out := &in.S2iBuildSource, &out.S2iBuildSource
|
||||
*out = new(S2iBuildSource)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iRunStatus.
|
||||
func (in *S2iRunStatus) DeepCopy() *S2iRunStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iRunStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *UserDefineTemplate) DeepCopyInto(out *UserDefineTemplate) {
|
||||
*out = *in
|
||||
if in.Parameters != nil {
|
||||
in, out := &in.Parameters, &out.Parameters
|
||||
*out = make([]Parameter, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UserDefineTemplate.
|
||||
func (in *UserDefineTemplate) DeepCopy() *UserDefineTemplate {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(UserDefineTemplate)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeSpec) DeepCopyInto(out *VolumeSpec) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSpec.
|
||||
func (in *VolumeSpec) DeepCopy() *VolumeSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
96
vendor/github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/clientset.go
generated
vendored
96
vendor/github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/clientset.go
generated
vendored
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package versioned
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
devopsv1alpha1 "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/typed/devops/v1alpha1"
|
||||
discovery "k8s.io/client-go/discovery"
|
||||
rest "k8s.io/client-go/rest"
|
||||
flowcontrol "k8s.io/client-go/util/flowcontrol"
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
Discovery() discovery.DiscoveryInterface
|
||||
DevopsV1alpha1() devopsv1alpha1.DevopsV1alpha1Interface
|
||||
}
|
||||
|
||||
// Clientset contains the clients for groups. Each group has exactly one
|
||||
// version included in a Clientset.
|
||||
type Clientset struct {
|
||||
*discovery.DiscoveryClient
|
||||
devopsV1alpha1 *devopsv1alpha1.DevopsV1alpha1Client
|
||||
}
|
||||
|
||||
// DevopsV1alpha1 retrieves the DevopsV1alpha1Client
|
||||
func (c *Clientset) DevopsV1alpha1() devopsv1alpha1.DevopsV1alpha1Interface {
|
||||
return c.devopsV1alpha1
|
||||
}
|
||||
|
||||
// Discovery retrieves the DiscoveryClient
|
||||
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.DiscoveryClient
|
||||
}
|
||||
|
||||
// NewForConfig creates a new Clientset for the given config.
|
||||
// If config's RateLimiter is not set and QPS and Burst are acceptable,
|
||||
// NewForConfig will generate a rate-limiter in configShallowCopy.
|
||||
func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||
configShallowCopy := *c
|
||||
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
|
||||
if configShallowCopy.Burst <= 0 {
|
||||
return nil, fmt.Errorf("Burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
|
||||
}
|
||||
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
|
||||
}
|
||||
var cs Clientset
|
||||
var err error
|
||||
cs.devopsV1alpha1, err = devopsv1alpha1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &cs, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new Clientset for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||
var cs Clientset
|
||||
cs.devopsV1alpha1 = devopsv1alpha1.NewForConfigOrDie(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
|
||||
return &cs
|
||||
}
|
||||
|
||||
// New creates a new Clientset for the given RESTClient.
|
||||
func New(c rest.Interface) *Clientset {
|
||||
var cs Clientset
|
||||
cs.devopsV1alpha1 = devopsv1alpha1.New(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
|
||||
return &cs
|
||||
}
|
||||
19
vendor/github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/doc.go
generated
vendored
19
vendor/github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/doc.go
generated
vendored
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// This package has the automatically generated clientset.
|
||||
package versioned
|
||||
19
vendor/github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/scheme/doc.go
generated
vendored
19
vendor/github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/scheme/doc.go
generated
vendored
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// This package contains the scheme of the automatically generated clientset.
|
||||
package scheme
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package scheme
|
||||
|
||||
import (
|
||||
devopsv1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
)
|
||||
|
||||
var Scheme = runtime.NewScheme()
|
||||
var Codecs = serializer.NewCodecFactory(Scheme)
|
||||
var ParameterCodec = runtime.NewParameterCodec(Scheme)
|
||||
var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
devopsv1alpha1.AddToScheme,
|
||||
}
|
||||
|
||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
||||
// of clientsets, like in:
|
||||
//
|
||||
// import (
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
||||
// )
|
||||
//
|
||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
||||
//
|
||||
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
|
||||
// correctly.
|
||||
var AddToScheme = localSchemeBuilder.AddToScheme
|
||||
|
||||
func init() {
|
||||
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
|
||||
utilruntime.Must(AddToScheme(Scheme))
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
"github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type DevopsV1alpha1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
S2iBuildersGetter
|
||||
S2iBuilderTemplatesGetter
|
||||
S2iRunsGetter
|
||||
}
|
||||
|
||||
// DevopsV1alpha1Client is used to interact with features provided by the devops.kubesphere.io group.
|
||||
type DevopsV1alpha1Client struct {
|
||||
restClient rest.Interface
|
||||
}
|
||||
|
||||
func (c *DevopsV1alpha1Client) S2iBuilders(namespace string) S2iBuilderInterface {
|
||||
return newS2iBuilders(c, namespace)
|
||||
}
|
||||
|
||||
func (c *DevopsV1alpha1Client) S2iBuilderTemplates() S2iBuilderTemplateInterface {
|
||||
return newS2iBuilderTemplates(c)
|
||||
}
|
||||
|
||||
func (c *DevopsV1alpha1Client) S2iRuns(namespace string) S2iRunInterface {
|
||||
return newS2iRuns(c, namespace)
|
||||
}
|
||||
|
||||
// NewForConfig creates a new DevopsV1alpha1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*DevopsV1alpha1Client, error) {
|
||||
config := *c
|
||||
if err := setConfigDefaults(&config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, err := rest.RESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DevopsV1alpha1Client{client}, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new DevopsV1alpha1Client for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *DevopsV1alpha1Client {
|
||||
client, err := NewForConfig(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// New creates a new DevopsV1alpha1Client for the given RESTClient.
|
||||
func New(c rest.Interface) *DevopsV1alpha1Client {
|
||||
return &DevopsV1alpha1Client{c}
|
||||
}
|
||||
|
||||
func setConfigDefaults(config *rest.Config) error {
|
||||
gv := v1alpha1.SchemeGroupVersion
|
||||
config.GroupVersion = &gv
|
||||
config.APIPath = "/apis"
|
||||
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
|
||||
|
||||
if config.UserAgent == "" {
|
||||
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *DevopsV1alpha1Client) RESTClient() rest.Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.restClient
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// This package has the automatically generated typed clients.
|
||||
package v1alpha1
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
type S2iBuilderExpansion interface{}
|
||||
|
||||
type S2iBuilderTemplateExpansion interface{}
|
||||
|
||||
type S2iRunExpansion interface{}
|
||||
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
scheme "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/scheme"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
// S2iBuildersGetter has a method to return a S2iBuilderInterface.
|
||||
// A group's client should implement this interface.
|
||||
type S2iBuildersGetter interface {
|
||||
S2iBuilders(namespace string) S2iBuilderInterface
|
||||
}
|
||||
|
||||
// S2iBuilderInterface has methods to work with S2iBuilder resources.
|
||||
type S2iBuilderInterface interface {
|
||||
Create(*v1alpha1.S2iBuilder) (*v1alpha1.S2iBuilder, error)
|
||||
Update(*v1alpha1.S2iBuilder) (*v1alpha1.S2iBuilder, error)
|
||||
UpdateStatus(*v1alpha1.S2iBuilder) (*v1alpha1.S2iBuilder, error)
|
||||
Delete(name string, options *v1.DeleteOptions) error
|
||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
||||
Get(name string, options v1.GetOptions) (*v1alpha1.S2iBuilder, error)
|
||||
List(opts v1.ListOptions) (*v1alpha1.S2iBuilderList, error)
|
||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.S2iBuilder, err error)
|
||||
S2iBuilderExpansion
|
||||
}
|
||||
|
||||
// s2iBuilders implements S2iBuilderInterface
|
||||
type s2iBuilders struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
}
|
||||
|
||||
// newS2iBuilders returns a S2iBuilders
|
||||
func newS2iBuilders(c *DevopsV1alpha1Client, namespace string) *s2iBuilders {
|
||||
return &s2iBuilders{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the s2iBuilder, and returns the corresponding s2iBuilder object, and an error if there is any.
|
||||
func (c *s2iBuilders) Get(name string, options v1.GetOptions) (result *v1alpha1.S2iBuilder, err error) {
|
||||
result = &v1alpha1.S2iBuilder{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("s2ibuilders").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of S2iBuilders that match those selectors.
|
||||
func (c *s2iBuilders) List(opts v1.ListOptions) (result *v1alpha1.S2iBuilderList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1alpha1.S2iBuilderList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("s2ibuilders").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested s2iBuilders.
|
||||
func (c *s2iBuilders) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("s2ibuilders").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Create takes the representation of a s2iBuilder and creates it. Returns the server's representation of the s2iBuilder, and an error, if there is any.
|
||||
func (c *s2iBuilders) Create(s2iBuilder *v1alpha1.S2iBuilder) (result *v1alpha1.S2iBuilder, err error) {
|
||||
result = &v1alpha1.S2iBuilder{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("s2ibuilders").
|
||||
Body(s2iBuilder).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a s2iBuilder and updates it. Returns the server's representation of the s2iBuilder, and an error, if there is any.
|
||||
func (c *s2iBuilders) Update(s2iBuilder *v1alpha1.S2iBuilder) (result *v1alpha1.S2iBuilder, err error) {
|
||||
result = &v1alpha1.S2iBuilder{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("s2ibuilders").
|
||||
Name(s2iBuilder.Name).
|
||||
Body(s2iBuilder).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
|
||||
func (c *s2iBuilders) UpdateStatus(s2iBuilder *v1alpha1.S2iBuilder) (result *v1alpha1.S2iBuilder, err error) {
|
||||
result = &v1alpha1.S2iBuilder{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("s2ibuilders").
|
||||
Name(s2iBuilder.Name).
|
||||
SubResource("status").
|
||||
Body(s2iBuilder).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the s2iBuilder and deletes it. Returns an error if one occurs.
|
||||
func (c *s2iBuilders) Delete(name string, options *v1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("s2ibuilders").
|
||||
Name(name).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *s2iBuilders) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOptions.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("s2ibuilders").
|
||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched s2iBuilder.
|
||||
func (c *s2iBuilders) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.S2iBuilder, err error) {
|
||||
result = &v1alpha1.S2iBuilder{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("s2ibuilders").
|
||||
SubResource(subresources...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
scheme "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/scheme"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
// S2iBuilderTemplatesGetter has a method to return a S2iBuilderTemplateInterface.
|
||||
// A group's client should implement this interface.
|
||||
type S2iBuilderTemplatesGetter interface {
|
||||
S2iBuilderTemplates() S2iBuilderTemplateInterface
|
||||
}
|
||||
|
||||
// S2iBuilderTemplateInterface has methods to work with S2iBuilderTemplate resources.
|
||||
type S2iBuilderTemplateInterface interface {
|
||||
Create(*v1alpha1.S2iBuilderTemplate) (*v1alpha1.S2iBuilderTemplate, error)
|
||||
Update(*v1alpha1.S2iBuilderTemplate) (*v1alpha1.S2iBuilderTemplate, error)
|
||||
UpdateStatus(*v1alpha1.S2iBuilderTemplate) (*v1alpha1.S2iBuilderTemplate, error)
|
||||
Delete(name string, options *v1.DeleteOptions) error
|
||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
||||
Get(name string, options v1.GetOptions) (*v1alpha1.S2iBuilderTemplate, error)
|
||||
List(opts v1.ListOptions) (*v1alpha1.S2iBuilderTemplateList, error)
|
||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.S2iBuilderTemplate, err error)
|
||||
S2iBuilderTemplateExpansion
|
||||
}
|
||||
|
||||
// s2iBuilderTemplates implements S2iBuilderTemplateInterface
|
||||
type s2iBuilderTemplates struct {
|
||||
client rest.Interface
|
||||
}
|
||||
|
||||
// newS2iBuilderTemplates returns a S2iBuilderTemplates
|
||||
func newS2iBuilderTemplates(c *DevopsV1alpha1Client) *s2iBuilderTemplates {
|
||||
return &s2iBuilderTemplates{
|
||||
client: c.RESTClient(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the s2iBuilderTemplate, and returns the corresponding s2iBuilderTemplate object, and an error if there is any.
|
||||
func (c *s2iBuilderTemplates) Get(name string, options v1.GetOptions) (result *v1alpha1.S2iBuilderTemplate, err error) {
|
||||
result = &v1alpha1.S2iBuilderTemplate{}
|
||||
err = c.client.Get().
|
||||
Resource("s2ibuildertemplates").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of S2iBuilderTemplates that match those selectors.
|
||||
func (c *s2iBuilderTemplates) List(opts v1.ListOptions) (result *v1alpha1.S2iBuilderTemplateList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1alpha1.S2iBuilderTemplateList{}
|
||||
err = c.client.Get().
|
||||
Resource("s2ibuildertemplates").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested s2iBuilderTemplates.
|
||||
func (c *s2iBuilderTemplates) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Resource("s2ibuildertemplates").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Create takes the representation of a s2iBuilderTemplate and creates it. Returns the server's representation of the s2iBuilderTemplate, and an error, if there is any.
|
||||
func (c *s2iBuilderTemplates) Create(s2iBuilderTemplate *v1alpha1.S2iBuilderTemplate) (result *v1alpha1.S2iBuilderTemplate, err error) {
|
||||
result = &v1alpha1.S2iBuilderTemplate{}
|
||||
err = c.client.Post().
|
||||
Resource("s2ibuildertemplates").
|
||||
Body(s2iBuilderTemplate).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a s2iBuilderTemplate and updates it. Returns the server's representation of the s2iBuilderTemplate, and an error, if there is any.
|
||||
func (c *s2iBuilderTemplates) Update(s2iBuilderTemplate *v1alpha1.S2iBuilderTemplate) (result *v1alpha1.S2iBuilderTemplate, err error) {
|
||||
result = &v1alpha1.S2iBuilderTemplate{}
|
||||
err = c.client.Put().
|
||||
Resource("s2ibuildertemplates").
|
||||
Name(s2iBuilderTemplate.Name).
|
||||
Body(s2iBuilderTemplate).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
|
||||
func (c *s2iBuilderTemplates) UpdateStatus(s2iBuilderTemplate *v1alpha1.S2iBuilderTemplate) (result *v1alpha1.S2iBuilderTemplate, err error) {
|
||||
result = &v1alpha1.S2iBuilderTemplate{}
|
||||
err = c.client.Put().
|
||||
Resource("s2ibuildertemplates").
|
||||
Name(s2iBuilderTemplate.Name).
|
||||
SubResource("status").
|
||||
Body(s2iBuilderTemplate).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the s2iBuilderTemplate and deletes it. Returns an error if one occurs.
|
||||
func (c *s2iBuilderTemplates) Delete(name string, options *v1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Resource("s2ibuildertemplates").
|
||||
Name(name).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *s2iBuilderTemplates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOptions.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Resource("s2ibuildertemplates").
|
||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched s2iBuilderTemplate.
|
||||
func (c *s2iBuilderTemplates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.S2iBuilderTemplate, err error) {
|
||||
result = &v1alpha1.S2iBuilderTemplate{}
|
||||
err = c.client.Patch(pt).
|
||||
Resource("s2ibuildertemplates").
|
||||
SubResource(subresources...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
scheme "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned/scheme"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
// S2iRunsGetter has a method to return a S2iRunInterface.
|
||||
// A group's client should implement this interface.
|
||||
type S2iRunsGetter interface {
|
||||
S2iRuns(namespace string) S2iRunInterface
|
||||
}
|
||||
|
||||
// S2iRunInterface has methods to work with S2iRun resources.
|
||||
type S2iRunInterface interface {
|
||||
Create(*v1alpha1.S2iRun) (*v1alpha1.S2iRun, error)
|
||||
Update(*v1alpha1.S2iRun) (*v1alpha1.S2iRun, error)
|
||||
UpdateStatus(*v1alpha1.S2iRun) (*v1alpha1.S2iRun, error)
|
||||
Delete(name string, options *v1.DeleteOptions) error
|
||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
||||
Get(name string, options v1.GetOptions) (*v1alpha1.S2iRun, error)
|
||||
List(opts v1.ListOptions) (*v1alpha1.S2iRunList, error)
|
||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.S2iRun, err error)
|
||||
S2iRunExpansion
|
||||
}
|
||||
|
||||
// s2iRuns implements S2iRunInterface
|
||||
type s2iRuns struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
}
|
||||
|
||||
// newS2iRuns returns a S2iRuns
|
||||
func newS2iRuns(c *DevopsV1alpha1Client, namespace string) *s2iRuns {
|
||||
return &s2iRuns{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the s2iRun, and returns the corresponding s2iRun object, and an error if there is any.
|
||||
func (c *s2iRuns) Get(name string, options v1.GetOptions) (result *v1alpha1.S2iRun, err error) {
|
||||
result = &v1alpha1.S2iRun{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("s2iruns").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of S2iRuns that match those selectors.
|
||||
func (c *s2iRuns) List(opts v1.ListOptions) (result *v1alpha1.S2iRunList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1alpha1.S2iRunList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("s2iruns").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested s2iRuns.
|
||||
func (c *s2iRuns) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("s2iruns").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Create takes the representation of a s2iRun and creates it. Returns the server's representation of the s2iRun, and an error, if there is any.
|
||||
func (c *s2iRuns) Create(s2iRun *v1alpha1.S2iRun) (result *v1alpha1.S2iRun, err error) {
|
||||
result = &v1alpha1.S2iRun{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("s2iruns").
|
||||
Body(s2iRun).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a s2iRun and updates it. Returns the server's representation of the s2iRun, and an error, if there is any.
|
||||
func (c *s2iRuns) Update(s2iRun *v1alpha1.S2iRun) (result *v1alpha1.S2iRun, err error) {
|
||||
result = &v1alpha1.S2iRun{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("s2iruns").
|
||||
Name(s2iRun.Name).
|
||||
Body(s2iRun).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
|
||||
func (c *s2iRuns) UpdateStatus(s2iRun *v1alpha1.S2iRun) (result *v1alpha1.S2iRun, err error) {
|
||||
result = &v1alpha1.S2iRun{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("s2iruns").
|
||||
Name(s2iRun.Name).
|
||||
SubResource("status").
|
||||
Body(s2iRun).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the s2iRun and deletes it. Returns an error if one occurs.
|
||||
func (c *s2iRuns) Delete(name string, options *v1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("s2iruns").
|
||||
Name(name).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *s2iRuns) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOptions.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("s2iruns").
|
||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched s2iRun.
|
||||
func (c *s2iRuns) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.S2iRun, err error) {
|
||||
result = &v1alpha1.S2iRun{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("s2iruns").
|
||||
SubResource(subresources...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package devops
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/devops/v1alpha1"
|
||||
internalinterfaces "github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/internalinterfaces"
|
||||
)
|
||||
|
||||
// Interface provides access to each of this group's versions.
|
||||
type Interface interface {
|
||||
// V1alpha1 provides access to shared informers for resources in V1alpha1.
|
||||
V1alpha1() v1alpha1.Interface
|
||||
}
|
||||
|
||||
type group struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
namespace string
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
}
|
||||
|
||||
// New returns a new Interface.
|
||||
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
|
||||
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
|
||||
}
|
||||
|
||||
// V1alpha1 returns a new v1alpha1.Interface.
|
||||
func (g *group) V1alpha1() v1alpha1.Interface {
|
||||
return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions)
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
internalinterfaces "github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/internalinterfaces"
|
||||
)
|
||||
|
||||
// Interface provides access to all the informers in this group version.
|
||||
type Interface interface {
|
||||
// S2iBuilders returns a S2iBuilderInformer.
|
||||
S2iBuilders() S2iBuilderInformer
|
||||
// S2iBuilderTemplates returns a S2iBuilderTemplateInformer.
|
||||
S2iBuilderTemplates() S2iBuilderTemplateInformer
|
||||
// S2iRuns returns a S2iRunInformer.
|
||||
S2iRuns() S2iRunInformer
|
||||
}
|
||||
|
||||
type version struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
namespace string
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
}
|
||||
|
||||
// New returns a new Interface.
|
||||
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
|
||||
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
|
||||
}
|
||||
|
||||
// S2iBuilders returns a S2iBuilderInformer.
|
||||
func (v *version) S2iBuilders() S2iBuilderInformer {
|
||||
return &s2iBuilderInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
|
||||
// S2iBuilderTemplates returns a S2iBuilderTemplateInformer.
|
||||
func (v *version) S2iBuilderTemplates() S2iBuilderTemplateInformer {
|
||||
return &s2iBuilderTemplateInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
|
||||
// S2iRuns returns a S2iRunInformer.
|
||||
func (v *version) S2iRuns() S2iRunInformer {
|
||||
return &s2iRunInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
devopsv1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
versioned "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned"
|
||||
internalinterfaces "github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/internalinterfaces"
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/client/listers/devops/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// S2iBuilderInformer provides access to a shared informer and lister for
|
||||
// S2iBuilders.
|
||||
type S2iBuilderInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1alpha1.S2iBuilderLister
|
||||
}
|
||||
|
||||
type s2iBuilderInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewS2iBuilderInformer constructs a new informer for S2iBuilder type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewS2iBuilderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredS2iBuilderInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredS2iBuilderInformer constructs a new informer for S2iBuilder type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewFilteredS2iBuilderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
||||
return cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.DevopsV1alpha1().S2iBuilders(namespace).List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.DevopsV1alpha1().S2iBuilders(namespace).Watch(options)
|
||||
},
|
||||
},
|
||||
&devopsv1alpha1.S2iBuilder{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *s2iBuilderInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredS2iBuilderInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *s2iBuilderInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&devopsv1alpha1.S2iBuilder{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *s2iBuilderInformer) Lister() v1alpha1.S2iBuilderLister {
|
||||
return v1alpha1.NewS2iBuilderLister(f.Informer().GetIndexer())
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
devopsv1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
versioned "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned"
|
||||
internalinterfaces "github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/internalinterfaces"
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/client/listers/devops/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// S2iBuilderTemplateInformer provides access to a shared informer and lister for
|
||||
// S2iBuilderTemplates.
|
||||
type S2iBuilderTemplateInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1alpha1.S2iBuilderTemplateLister
|
||||
}
|
||||
|
||||
type s2iBuilderTemplateInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
}
|
||||
|
||||
// NewS2iBuilderTemplateInformer constructs a new informer for S2iBuilderTemplate type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewS2iBuilderTemplateInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredS2iBuilderTemplateInformer(client, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredS2iBuilderTemplateInformer constructs a new informer for S2iBuilderTemplate type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewFilteredS2iBuilderTemplateInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
||||
return cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.DevopsV1alpha1().S2iBuilderTemplates().List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.DevopsV1alpha1().S2iBuilderTemplates().Watch(options)
|
||||
},
|
||||
},
|
||||
&devopsv1alpha1.S2iBuilderTemplate{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *s2iBuilderTemplateInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredS2iBuilderTemplateInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *s2iBuilderTemplateInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&devopsv1alpha1.S2iBuilderTemplate{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *s2iBuilderTemplateInformer) Lister() v1alpha1.S2iBuilderTemplateLister {
|
||||
return v1alpha1.NewS2iBuilderTemplateLister(f.Informer().GetIndexer())
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
devopsv1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
versioned "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned"
|
||||
internalinterfaces "github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/internalinterfaces"
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/client/listers/devops/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// S2iRunInformer provides access to a shared informer and lister for
|
||||
// S2iRuns.
|
||||
type S2iRunInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1alpha1.S2iRunLister
|
||||
}
|
||||
|
||||
type s2iRunInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewS2iRunInformer constructs a new informer for S2iRun type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewS2iRunInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredS2iRunInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredS2iRunInformer constructs a new informer for S2iRun type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewFilteredS2iRunInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
||||
return cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.DevopsV1alpha1().S2iRuns(namespace).List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.DevopsV1alpha1().S2iRuns(namespace).Watch(options)
|
||||
},
|
||||
},
|
||||
&devopsv1alpha1.S2iRun{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *s2iRunInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredS2iRunInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *s2iRunInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&devopsv1alpha1.S2iRun{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *s2iRunInformer) Lister() v1alpha1.S2iRunLister {
|
||||
return v1alpha1.NewS2iRunLister(f.Informer().GetIndexer())
|
||||
}
|
||||
179
vendor/github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/factory.go
generated
vendored
179
vendor/github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/factory.go
generated
vendored
@@ -1,179 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package externalversions
|
||||
|
||||
import (
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
time "time"
|
||||
|
||||
versioned "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned"
|
||||
devops "github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/devops"
|
||||
internalinterfaces "github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions/internalinterfaces"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// SharedInformerOption defines the functional option type for SharedInformerFactory.
|
||||
type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory
|
||||
|
||||
type sharedInformerFactory struct {
|
||||
client versioned.Interface
|
||||
namespace string
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
lock sync.Mutex
|
||||
defaultResync time.Duration
|
||||
customResync map[reflect.Type]time.Duration
|
||||
|
||||
informers map[reflect.Type]cache.SharedIndexInformer
|
||||
// startedInformers is used for tracking which informers have been started.
|
||||
// This allows Start() to be called multiple times safely.
|
||||
startedInformers map[reflect.Type]bool
|
||||
}
|
||||
|
||||
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
|
||||
func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption {
|
||||
return func(factory *sharedInformerFactory) *sharedInformerFactory {
|
||||
for k, v := range resyncConfig {
|
||||
factory.customResync[reflect.TypeOf(k)] = v
|
||||
}
|
||||
return factory
|
||||
}
|
||||
}
|
||||
|
||||
// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory.
|
||||
func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption {
|
||||
return func(factory *sharedInformerFactory) *sharedInformerFactory {
|
||||
factory.tweakListOptions = tweakListOptions
|
||||
return factory
|
||||
}
|
||||
}
|
||||
|
||||
// WithNamespace limits the SharedInformerFactory to the specified namespace.
|
||||
func WithNamespace(namespace string) SharedInformerOption {
|
||||
return func(factory *sharedInformerFactory) *sharedInformerFactory {
|
||||
factory.namespace = namespace
|
||||
return factory
|
||||
}
|
||||
}
|
||||
|
||||
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
|
||||
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
|
||||
return NewSharedInformerFactoryWithOptions(client, defaultResync)
|
||||
}
|
||||
|
||||
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
|
||||
// Listers obtained via this SharedInformerFactory will be subject to the same filters
|
||||
// as specified here.
|
||||
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
|
||||
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
|
||||
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
|
||||
}
|
||||
|
||||
// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options.
|
||||
func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory {
|
||||
factory := &sharedInformerFactory{
|
||||
client: client,
|
||||
namespace: v1.NamespaceAll,
|
||||
defaultResync: defaultResync,
|
||||
informers: make(map[reflect.Type]cache.SharedIndexInformer),
|
||||
startedInformers: make(map[reflect.Type]bool),
|
||||
customResync: make(map[reflect.Type]time.Duration),
|
||||
}
|
||||
|
||||
// Apply all options
|
||||
for _, opt := range options {
|
||||
factory = opt(factory)
|
||||
}
|
||||
|
||||
return factory
|
||||
}
|
||||
|
||||
// Start initializes all requested informers.
|
||||
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
for informerType, informer := range f.informers {
|
||||
if !f.startedInformers[informerType] {
|
||||
go informer.Run(stopCh)
|
||||
f.startedInformers[informerType] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WaitForCacheSync waits for all started informers' cache were synced.
|
||||
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
|
||||
informers := func() map[reflect.Type]cache.SharedIndexInformer {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
informers := map[reflect.Type]cache.SharedIndexInformer{}
|
||||
for informerType, informer := range f.informers {
|
||||
if f.startedInformers[informerType] {
|
||||
informers[informerType] = informer
|
||||
}
|
||||
}
|
||||
return informers
|
||||
}()
|
||||
|
||||
res := map[reflect.Type]bool{}
|
||||
for informType, informer := range informers {
|
||||
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
|
||||
// client.
|
||||
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
informerType := reflect.TypeOf(obj)
|
||||
informer, exists := f.informers[informerType]
|
||||
if exists {
|
||||
return informer
|
||||
}
|
||||
|
||||
resyncPeriod, exists := f.customResync[informerType]
|
||||
if !exists {
|
||||
resyncPeriod = f.defaultResync
|
||||
}
|
||||
|
||||
informer = newFunc(f.client, resyncPeriod)
|
||||
f.informers[informerType] = informer
|
||||
|
||||
return informer
|
||||
}
|
||||
|
||||
// SharedInformerFactory provides shared informers for resources in all known
|
||||
// API group versions.
|
||||
type SharedInformerFactory interface {
|
||||
internalinterfaces.SharedInformerFactory
|
||||
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
|
||||
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
|
||||
|
||||
Devops() devops.Interface
|
||||
}
|
||||
|
||||
func (f *sharedInformerFactory) Devops() devops.Interface {
|
||||
return devops.New(f, f.namespace, f.tweakListOptions)
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package externalversions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
|
||||
// sharedInformers based on type
|
||||
type GenericInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() cache.GenericLister
|
||||
}
|
||||
|
||||
type genericInformer struct {
|
||||
informer cache.SharedIndexInformer
|
||||
resource schema.GroupResource
|
||||
}
|
||||
|
||||
// Informer returns the SharedIndexInformer.
|
||||
func (f *genericInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.informer
|
||||
}
|
||||
|
||||
// Lister returns the GenericLister.
|
||||
func (f *genericInformer) Lister() cache.GenericLister {
|
||||
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
|
||||
}
|
||||
|
||||
// ForResource gives generic access to a shared informer of the matching type
|
||||
// TODO extend this to unknown resources with a client pool
|
||||
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
|
||||
switch resource {
|
||||
// Group=devops.kubesphere.io, Version=v1alpha1
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("s2ibuilders"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Devops().V1alpha1().S2iBuilders().Informer()}, nil
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("s2ibuildertemplates"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Devops().V1alpha1().S2iBuilderTemplates().Informer()}, nil
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("s2iruns"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Devops().V1alpha1().S2iRuns().Informer()}, nil
|
||||
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("no informer found for %v", resource)
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package internalinterfaces
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
versioned "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
|
||||
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
|
||||
|
||||
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
|
||||
type SharedInformerFactory interface {
|
||||
Start(stopCh <-chan struct{})
|
||||
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
|
||||
}
|
||||
|
||||
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
|
||||
type TweakListOptionsFunc func(*v1.ListOptions)
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
// S2iBuilderListerExpansion allows custom methods to be added to
|
||||
// S2iBuilderLister.
|
||||
type S2iBuilderListerExpansion interface{}
|
||||
|
||||
// S2iBuilderNamespaceListerExpansion allows custom methods to be added to
|
||||
// S2iBuilderNamespaceLister.
|
||||
type S2iBuilderNamespaceListerExpansion interface{}
|
||||
|
||||
// S2iBuilderTemplateListerExpansion allows custom methods to be added to
|
||||
// S2iBuilderTemplateLister.
|
||||
type S2iBuilderTemplateListerExpansion interface{}
|
||||
|
||||
// S2iRunListerExpansion allows custom methods to be added to
|
||||
// S2iRunLister.
|
||||
type S2iRunListerExpansion interface{}
|
||||
|
||||
// S2iRunNamespaceListerExpansion allows custom methods to be added to
|
||||
// S2iRunNamespaceLister.
|
||||
type S2iRunNamespaceListerExpansion interface{}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// S2iBuilderLister helps list S2iBuilders.
|
||||
type S2iBuilderLister interface {
|
||||
// List lists all S2iBuilders in the indexer.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.S2iBuilder, err error)
|
||||
// S2iBuilders returns an object that can list and get S2iBuilders.
|
||||
S2iBuilders(namespace string) S2iBuilderNamespaceLister
|
||||
S2iBuilderListerExpansion
|
||||
}
|
||||
|
||||
// s2iBuilderLister implements the S2iBuilderLister interface.
|
||||
type s2iBuilderLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewS2iBuilderLister returns a new S2iBuilderLister.
|
||||
func NewS2iBuilderLister(indexer cache.Indexer) S2iBuilderLister {
|
||||
return &s2iBuilderLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all S2iBuilders in the indexer.
|
||||
func (s *s2iBuilderLister) List(selector labels.Selector) (ret []*v1alpha1.S2iBuilder, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.S2iBuilder))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// S2iBuilders returns an object that can list and get S2iBuilders.
|
||||
func (s *s2iBuilderLister) S2iBuilders(namespace string) S2iBuilderNamespaceLister {
|
||||
return s2iBuilderNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
}
|
||||
|
||||
// S2iBuilderNamespaceLister helps list and get S2iBuilders.
|
||||
type S2iBuilderNamespaceLister interface {
|
||||
// List lists all S2iBuilders in the indexer for a given namespace.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.S2iBuilder, err error)
|
||||
// Get retrieves the S2iBuilder from the indexer for a given namespace and name.
|
||||
Get(name string) (*v1alpha1.S2iBuilder, error)
|
||||
S2iBuilderNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// s2iBuilderNamespaceLister implements the S2iBuilderNamespaceLister
|
||||
// interface.
|
||||
type s2iBuilderNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all S2iBuilders in the indexer for a given namespace.
|
||||
func (s s2iBuilderNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.S2iBuilder, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.S2iBuilder))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the S2iBuilder from the indexer for a given namespace and name.
|
||||
func (s s2iBuilderNamespaceLister) Get(name string) (*v1alpha1.S2iBuilder, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1alpha1.Resource("s2ibuilder"), name)
|
||||
}
|
||||
return obj.(*v1alpha1.S2iBuilder), nil
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// S2iBuilderTemplateLister helps list S2iBuilderTemplates.
|
||||
type S2iBuilderTemplateLister interface {
|
||||
// List lists all S2iBuilderTemplates in the indexer.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.S2iBuilderTemplate, err error)
|
||||
// Get retrieves the S2iBuilderTemplate from the index for a given name.
|
||||
Get(name string) (*v1alpha1.S2iBuilderTemplate, error)
|
||||
S2iBuilderTemplateListerExpansion
|
||||
}
|
||||
|
||||
// s2iBuilderTemplateLister implements the S2iBuilderTemplateLister interface.
|
||||
type s2iBuilderTemplateLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewS2iBuilderTemplateLister returns a new S2iBuilderTemplateLister.
|
||||
func NewS2iBuilderTemplateLister(indexer cache.Indexer) S2iBuilderTemplateLister {
|
||||
return &s2iBuilderTemplateLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all S2iBuilderTemplates in the indexer.
|
||||
func (s *s2iBuilderTemplateLister) List(selector labels.Selector) (ret []*v1alpha1.S2iBuilderTemplate, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.S2iBuilderTemplate))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the S2iBuilderTemplate from the index for a given name.
|
||||
func (s *s2iBuilderTemplateLister) Get(name string) (*v1alpha1.S2iBuilderTemplate, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1alpha1.Resource("s2ibuildertemplate"), name)
|
||||
}
|
||||
return obj.(*v1alpha1.S2iBuilderTemplate), nil
|
||||
}
|
||||
93
vendor/github.com/kubesphere/s2ioperator/pkg/client/listers/devops/v1alpha1/s2irun.go
generated
vendored
93
vendor/github.com/kubesphere/s2ioperator/pkg/client/listers/devops/v1alpha1/s2irun.go
generated
vendored
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubesphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Code generated by lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// S2iRunLister helps list S2iRuns.
|
||||
type S2iRunLister interface {
|
||||
// List lists all S2iRuns in the indexer.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.S2iRun, err error)
|
||||
// S2iRuns returns an object that can list and get S2iRuns.
|
||||
S2iRuns(namespace string) S2iRunNamespaceLister
|
||||
S2iRunListerExpansion
|
||||
}
|
||||
|
||||
// s2iRunLister implements the S2iRunLister interface.
|
||||
type s2iRunLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewS2iRunLister returns a new S2iRunLister.
|
||||
func NewS2iRunLister(indexer cache.Indexer) S2iRunLister {
|
||||
return &s2iRunLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all S2iRuns in the indexer.
|
||||
func (s *s2iRunLister) List(selector labels.Selector) (ret []*v1alpha1.S2iRun, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.S2iRun))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// S2iRuns returns an object that can list and get S2iRuns.
|
||||
func (s *s2iRunLister) S2iRuns(namespace string) S2iRunNamespaceLister {
|
||||
return s2iRunNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
}
|
||||
|
||||
// S2iRunNamespaceLister helps list and get S2iRuns.
|
||||
type S2iRunNamespaceLister interface {
|
||||
// List lists all S2iRuns in the indexer for a given namespace.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.S2iRun, err error)
|
||||
// Get retrieves the S2iRun from the indexer for a given namespace and name.
|
||||
Get(name string) (*v1alpha1.S2iRun, error)
|
||||
S2iRunNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// s2iRunNamespaceLister implements the S2iRunNamespaceLister
|
||||
// interface.
|
||||
type s2iRunNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all S2iRuns in the indexer for a given namespace.
|
||||
func (s s2iRunNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.S2iRun, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.S2iRun))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the S2iRun from the indexer for a given namespace and name.
|
||||
func (s s2iRunNamespaceLister) Get(name string) (*v1alpha1.S2iRun, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1alpha1.Resource("s2irun"), name)
|
||||
}
|
||||
return obj.(*v1alpha1.S2iRun), nil
|
||||
}
|
||||
56
vendor/github.com/kubesphere/s2ioperator/pkg/errors/error.go
generated
vendored
56
vendor/github.com/kubesphere/s2ioperator/pkg/errors/error.go
generated
vendored
@@ -1,56 +0,0 @@
|
||||
package errors
|
||||
|
||||
import "fmt"
|
||||
|
||||
// NewFieldRequired returns a *ValidationError indicating "value required"
|
||||
func NewFieldRequired(field string) Error {
|
||||
return Error{Type: ErrorTypeRequired, Field: field}
|
||||
}
|
||||
|
||||
// NewFieldInvalidValue returns a ValidationError indicating "invalid value"
|
||||
func NewFieldInvalidValue(field string) Error {
|
||||
return Error{Type: ErrorInvalidValue, Field: field}
|
||||
}
|
||||
|
||||
// NewFieldInvalidValueWithReason returns a ValidationError indicating "invalid value" and a reason for the error
|
||||
func NewFieldInvalidValueWithReason(field, reason string) Error {
|
||||
return Error{Type: ErrorInvalidValue, Field: field, Reason: reason}
|
||||
}
|
||||
|
||||
// ErrorType is a machine readable value providing more detail about why a field
|
||||
// is invalid.
|
||||
type ErrorType string
|
||||
|
||||
const (
|
||||
// ErrorTypeRequired is used to report required values that are not provided
|
||||
// (e.g. empty strings, null values, or empty arrays).
|
||||
ErrorTypeRequired ErrorType = "FieldValueRequired"
|
||||
|
||||
// ErrorInvalidValue is used to report values that do not conform to the
|
||||
// expected schema.
|
||||
ErrorInvalidValue ErrorType = "InvalidValue"
|
||||
)
|
||||
|
||||
// Error is an implementation of the 'error' interface, which represents an
|
||||
// error of validation.
|
||||
type Error struct {
|
||||
Type ErrorType
|
||||
Field string
|
||||
Reason string
|
||||
}
|
||||
|
||||
func (v Error) Error() string {
|
||||
var msg string
|
||||
switch v.Type {
|
||||
case ErrorInvalidValue:
|
||||
msg = fmt.Sprintf("Invalid value specified for %q", v.Field)
|
||||
case ErrorTypeRequired:
|
||||
msg = fmt.Sprintf("Required value not specified for %q", v.Field)
|
||||
default:
|
||||
msg = fmt.Sprintf("%s: %s", v.Type, v.Field)
|
||||
}
|
||||
if len(v.Reason) > 0 {
|
||||
msg = fmt.Sprintf("%s: %s", msg, v.Reason)
|
||||
}
|
||||
return msg
|
||||
}
|
||||
23
vendor/github.com/kubesphere/s2ioperator/pkg/util/reflectutils/reflect.go
generated
vendored
23
vendor/github.com/kubesphere/s2ioperator/pkg/util/reflectutils/reflect.go
generated
vendored
@@ -1,23 +0,0 @@
|
||||
package reflectutils
|
||||
|
||||
import "reflect"
|
||||
|
||||
// ContainsString checks if a given slice contains the provided value.
|
||||
func Contains(value interface{}, container interface{}) bool {
|
||||
containerValue := reflect.ValueOf(container)
|
||||
switch reflect.TypeOf(container).Kind() {
|
||||
case reflect.Slice, reflect.Array:
|
||||
for i := 0; i < containerValue.Len(); i++ {
|
||||
if containerValue.Index(i).Interface() == value {
|
||||
return true
|
||||
}
|
||||
}
|
||||
case reflect.Map:
|
||||
if containerValue.MapIndex(reflect.ValueOf(value)).IsValid() {
|
||||
return true
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
169
vendor/github.com/marten-seemann/qtls/generate_cert.go
generated
vendored
169
vendor/github.com/marten-seemann/qtls/generate_cert.go
generated
vendored
@@ -1,169 +0,0 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
// Generate a self-signed X.509 certificate for a TLS server. Outputs to
|
||||
// 'cert.pem' and 'key.pem' and will overwrite existing files.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"encoding/pem"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/big"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
host = flag.String("host", "", "Comma-separated hostnames and IPs to generate a certificate for")
|
||||
validFrom = flag.String("start-date", "", "Creation date formatted as Jan 1 15:04:05 2011")
|
||||
validFor = flag.Duration("duration", 365*24*time.Hour, "Duration that certificate is valid for")
|
||||
isCA = flag.Bool("ca", false, "whether this cert should be its own Certificate Authority")
|
||||
rsaBits = flag.Int("rsa-bits", 2048, "Size of RSA key to generate. Ignored if --ecdsa-curve is set")
|
||||
ecdsaCurve = flag.String("ecdsa-curve", "", "ECDSA curve to use to generate a key. Valid values are P224, P256 (recommended), P384, P521")
|
||||
)
|
||||
|
||||
func publicKey(priv interface{}) interface{} {
|
||||
switch k := priv.(type) {
|
||||
case *rsa.PrivateKey:
|
||||
return &k.PublicKey
|
||||
case *ecdsa.PrivateKey:
|
||||
return &k.PublicKey
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func pemBlockForKey(priv interface{}) *pem.Block {
|
||||
switch k := priv.(type) {
|
||||
case *rsa.PrivateKey:
|
||||
return &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(k)}
|
||||
case *ecdsa.PrivateKey:
|
||||
b, err := x509.MarshalECPrivateKey(k)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Unable to marshal ECDSA private key: %v", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
return &pem.Block{Type: "EC PRIVATE KEY", Bytes: b}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if len(*host) == 0 {
|
||||
log.Fatalf("Missing required --host parameter")
|
||||
}
|
||||
|
||||
var priv interface{}
|
||||
var err error
|
||||
switch *ecdsaCurve {
|
||||
case "":
|
||||
priv, err = rsa.GenerateKey(rand.Reader, *rsaBits)
|
||||
case "P224":
|
||||
priv, err = ecdsa.GenerateKey(elliptic.P224(), rand.Reader)
|
||||
case "P256":
|
||||
priv, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
case "P384":
|
||||
priv, err = ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
|
||||
case "P521":
|
||||
priv, err = ecdsa.GenerateKey(elliptic.P521(), rand.Reader)
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "Unrecognized elliptic curve: %q", *ecdsaCurve)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("failed to generate private key: %s", err)
|
||||
}
|
||||
|
||||
var notBefore time.Time
|
||||
if len(*validFrom) == 0 {
|
||||
notBefore = time.Now()
|
||||
} else {
|
||||
notBefore, err = time.Parse("Jan 2 15:04:05 2006", *validFrom)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to parse creation date: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
notAfter := notBefore.Add(*validFor)
|
||||
|
||||
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
|
||||
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to generate serial number: %s", err)
|
||||
}
|
||||
|
||||
template := x509.Certificate{
|
||||
SerialNumber: serialNumber,
|
||||
Subject: pkix.Name{
|
||||
Organization: []string{"Acme Co"},
|
||||
},
|
||||
NotBefore: notBefore,
|
||||
NotAfter: notAfter,
|
||||
|
||||
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
|
||||
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
|
||||
BasicConstraintsValid: true,
|
||||
}
|
||||
|
||||
hosts := strings.Split(*host, ",")
|
||||
for _, h := range hosts {
|
||||
if ip := net.ParseIP(h); ip != nil {
|
||||
template.IPAddresses = append(template.IPAddresses, ip)
|
||||
} else {
|
||||
template.DNSNames = append(template.DNSNames, h)
|
||||
}
|
||||
}
|
||||
|
||||
if *isCA {
|
||||
template.IsCA = true
|
||||
template.KeyUsage |= x509.KeyUsageCertSign
|
||||
}
|
||||
|
||||
derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, publicKey(priv), priv)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create certificate: %s", err)
|
||||
}
|
||||
|
||||
certOut, err := os.Create("cert.pem")
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open cert.pem for writing: %s", err)
|
||||
}
|
||||
if err := pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}); err != nil {
|
||||
log.Fatalf("failed to write data to cert.pem: %s", err)
|
||||
}
|
||||
if err := certOut.Close(); err != nil {
|
||||
log.Fatalf("error closing cert.pem: %s", err)
|
||||
}
|
||||
log.Print("wrote cert.pem\n")
|
||||
|
||||
keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
||||
if err != nil {
|
||||
log.Print("failed to open key.pem for writing:", err)
|
||||
return
|
||||
}
|
||||
if err := pem.Encode(keyOut, pemBlockForKey(priv)); err != nil {
|
||||
log.Fatalf("failed to write data to key.pem: %s", err)
|
||||
}
|
||||
if err := keyOut.Close(); err != nil {
|
||||
log.Fatalf("error closing key.pem: %s", err)
|
||||
}
|
||||
log.Print("wrote key.pem\n")
|
||||
}
|
||||
144
vendor/github.com/miekg/dns/duplicate_generate.go
generated
vendored
144
vendor/github.com/miekg/dns/duplicate_generate.go
generated
vendored
@@ -1,144 +0,0 @@
|
||||
//+build ignore
|
||||
|
||||
// types_generate.go is meant to run with go generate. It will use
|
||||
// go/{importer,types} to track down all the RR struct types. Then for each type
|
||||
// it will generate conversion tables (TypeToRR and TypeToString) and banal
|
||||
// methods (len, Header, copy) based on the struct tags. The generated source is
|
||||
// written to ztypes.go, and is meant to be checked into git.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"go/importer"
|
||||
"go/types"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
var packageHdr = `
|
||||
// Code generated by "go run duplicate_generate.go"; DO NOT EDIT.
|
||||
|
||||
package dns
|
||||
|
||||
`
|
||||
|
||||
func getTypeStruct(t types.Type, scope *types.Scope) (*types.Struct, bool) {
|
||||
st, ok := t.Underlying().(*types.Struct)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
if st.Field(0).Type() == scope.Lookup("RR_Header").Type() {
|
||||
return st, false
|
||||
}
|
||||
if st.Field(0).Anonymous() {
|
||||
st, _ := getTypeStruct(st.Field(0).Type(), scope)
|
||||
return st, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Import and type-check the package
|
||||
pkg, err := importer.Default().Import("github.com/miekg/dns")
|
||||
fatalIfErr(err)
|
||||
scope := pkg.Scope()
|
||||
|
||||
// Collect actual types (*X)
|
||||
var namedTypes []string
|
||||
for _, name := range scope.Names() {
|
||||
o := scope.Lookup(name)
|
||||
if o == nil || !o.Exported() {
|
||||
continue
|
||||
}
|
||||
|
||||
if st, _ := getTypeStruct(o.Type(), scope); st == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if name == "PrivateRR" || name == "OPT" {
|
||||
continue
|
||||
}
|
||||
|
||||
namedTypes = append(namedTypes, o.Name())
|
||||
}
|
||||
|
||||
b := &bytes.Buffer{}
|
||||
b.WriteString(packageHdr)
|
||||
|
||||
// Generate the duplicate check for each type.
|
||||
fmt.Fprint(b, "// isDuplicate() functions\n\n")
|
||||
for _, name := range namedTypes {
|
||||
|
||||
o := scope.Lookup(name)
|
||||
st, isEmbedded := getTypeStruct(o.Type(), scope)
|
||||
if isEmbedded {
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(b, "func (r1 *%s) isDuplicate(_r2 RR) bool {\n", name)
|
||||
fmt.Fprintf(b, "r2, ok := _r2.(*%s)\n", name)
|
||||
fmt.Fprint(b, "if !ok { return false }\n")
|
||||
fmt.Fprint(b, "_ = r2\n")
|
||||
for i := 1; i < st.NumFields(); i++ {
|
||||
field := st.Field(i).Name()
|
||||
o2 := func(s string) { fmt.Fprintf(b, s+"\n", field, field) }
|
||||
o3 := func(s string) { fmt.Fprintf(b, s+"\n", field, field, field) }
|
||||
|
||||
// For some reason, a and aaaa don't pop up as *types.Slice here (mostly like because the are
|
||||
// *indirectly* defined as a slice in the net package).
|
||||
if _, ok := st.Field(i).Type().(*types.Slice); ok {
|
||||
o2("if len(r1.%s) != len(r2.%s) {\nreturn false\n}")
|
||||
|
||||
if st.Tag(i) == `dns:"cdomain-name"` || st.Tag(i) == `dns:"domain-name"` {
|
||||
o3(`for i := 0; i < len(r1.%s); i++ {
|
||||
if !isDuplicateName(r1.%s[i], r2.%s[i]) {
|
||||
return false
|
||||
}
|
||||
}`)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
o3(`for i := 0; i < len(r1.%s); i++ {
|
||||
if r1.%s[i] != r2.%s[i] {
|
||||
return false
|
||||
}
|
||||
}`)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
switch st.Tag(i) {
|
||||
case `dns:"-"`:
|
||||
// ignored
|
||||
case `dns:"a"`, `dns:"aaaa"`:
|
||||
o2("if !r1.%s.Equal(r2.%s) {\nreturn false\n}")
|
||||
case `dns:"cdomain-name"`, `dns:"domain-name"`:
|
||||
o2("if !isDuplicateName(r1.%s, r2.%s) {\nreturn false\n}")
|
||||
default:
|
||||
o2("if r1.%s != r2.%s {\nreturn false\n}")
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(b, "return true\n}\n\n")
|
||||
}
|
||||
|
||||
// gofmt
|
||||
res, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
b.WriteTo(os.Stderr)
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// write result
|
||||
f, err := os.Create("zduplicate.go")
|
||||
fatalIfErr(err)
|
||||
defer f.Close()
|
||||
f.Write(res)
|
||||
}
|
||||
|
||||
func fatalIfErr(err error) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
328
vendor/github.com/miekg/dns/msg_generate.go
generated
vendored
328
vendor/github.com/miekg/dns/msg_generate.go
generated
vendored
@@ -1,328 +0,0 @@
|
||||
//+build ignore
|
||||
|
||||
// msg_generate.go is meant to run with go generate. It will use
|
||||
// go/{importer,types} to track down all the RR struct types. Then for each type
|
||||
// it will generate pack/unpack methods based on the struct tags. The generated source is
|
||||
// written to zmsg.go, and is meant to be checked into git.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"go/importer"
|
||||
"go/types"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var packageHdr = `
|
||||
// Code generated by "go run msg_generate.go"; DO NOT EDIT.
|
||||
|
||||
package dns
|
||||
|
||||
`
|
||||
|
||||
// getTypeStruct will take a type and the package scope, and return the
|
||||
// (innermost) struct if the type is considered a RR type (currently defined as
|
||||
// those structs beginning with a RR_Header, could be redefined as implementing
|
||||
// the RR interface). The bool return value indicates if embedded structs were
|
||||
// resolved.
|
||||
func getTypeStruct(t types.Type, scope *types.Scope) (*types.Struct, bool) {
|
||||
st, ok := t.Underlying().(*types.Struct)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
if st.Field(0).Type() == scope.Lookup("RR_Header").Type() {
|
||||
return st, false
|
||||
}
|
||||
if st.Field(0).Anonymous() {
|
||||
st, _ := getTypeStruct(st.Field(0).Type(), scope)
|
||||
return st, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Import and type-check the package
|
||||
pkg, err := importer.Default().Import("github.com/miekg/dns")
|
||||
fatalIfErr(err)
|
||||
scope := pkg.Scope()
|
||||
|
||||
// Collect actual types (*X)
|
||||
var namedTypes []string
|
||||
for _, name := range scope.Names() {
|
||||
o := scope.Lookup(name)
|
||||
if o == nil || !o.Exported() {
|
||||
continue
|
||||
}
|
||||
if st, _ := getTypeStruct(o.Type(), scope); st == nil {
|
||||
continue
|
||||
}
|
||||
if name == "PrivateRR" {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if corresponding TypeX exists
|
||||
if scope.Lookup("Type"+o.Name()) == nil && o.Name() != "RFC3597" {
|
||||
log.Fatalf("Constant Type%s does not exist.", o.Name())
|
||||
}
|
||||
|
||||
namedTypes = append(namedTypes, o.Name())
|
||||
}
|
||||
|
||||
b := &bytes.Buffer{}
|
||||
b.WriteString(packageHdr)
|
||||
|
||||
fmt.Fprint(b, "// pack*() functions\n\n")
|
||||
for _, name := range namedTypes {
|
||||
o := scope.Lookup(name)
|
||||
st, _ := getTypeStruct(o.Type(), scope)
|
||||
|
||||
fmt.Fprintf(b, "func (rr *%s) pack(msg []byte, off int, compression compressionMap, compress bool) (off1 int, err error) {\n", name)
|
||||
for i := 1; i < st.NumFields(); i++ {
|
||||
o := func(s string) {
|
||||
fmt.Fprintf(b, s, st.Field(i).Name())
|
||||
fmt.Fprint(b, `if err != nil {
|
||||
return off, err
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
if _, ok := st.Field(i).Type().(*types.Slice); ok {
|
||||
switch st.Tag(i) {
|
||||
case `dns:"-"`: // ignored
|
||||
case `dns:"txt"`:
|
||||
o("off, err = packStringTxt(rr.%s, msg, off)\n")
|
||||
case `dns:"opt"`:
|
||||
o("off, err = packDataOpt(rr.%s, msg, off)\n")
|
||||
case `dns:"nsec"`:
|
||||
o("off, err = packDataNsec(rr.%s, msg, off)\n")
|
||||
case `dns:"domain-name"`:
|
||||
o("off, err = packDataDomainNames(rr.%s, msg, off, compression, false)\n")
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
switch {
|
||||
case st.Tag(i) == `dns:"-"`: // ignored
|
||||
case st.Tag(i) == `dns:"cdomain-name"`:
|
||||
o("off, err = packDomainName(rr.%s, msg, off, compression, compress)\n")
|
||||
case st.Tag(i) == `dns:"domain-name"`:
|
||||
o("off, err = packDomainName(rr.%s, msg, off, compression, false)\n")
|
||||
case st.Tag(i) == `dns:"a"`:
|
||||
o("off, err = packDataA(rr.%s, msg, off)\n")
|
||||
case st.Tag(i) == `dns:"aaaa"`:
|
||||
o("off, err = packDataAAAA(rr.%s, msg, off)\n")
|
||||
case st.Tag(i) == `dns:"uint48"`:
|
||||
o("off, err = packUint48(rr.%s, msg, off)\n")
|
||||
case st.Tag(i) == `dns:"txt"`:
|
||||
o("off, err = packString(rr.%s, msg, off)\n")
|
||||
|
||||
case strings.HasPrefix(st.Tag(i), `dns:"size-base32`): // size-base32 can be packed just like base32
|
||||
fallthrough
|
||||
case st.Tag(i) == `dns:"base32"`:
|
||||
o("off, err = packStringBase32(rr.%s, msg, off)\n")
|
||||
|
||||
case strings.HasPrefix(st.Tag(i), `dns:"size-base64`): // size-base64 can be packed just like base64
|
||||
fallthrough
|
||||
case st.Tag(i) == `dns:"base64"`:
|
||||
o("off, err = packStringBase64(rr.%s, msg, off)\n")
|
||||
|
||||
case strings.HasPrefix(st.Tag(i), `dns:"size-hex:SaltLength`):
|
||||
// directly write instead of using o() so we get the error check in the correct place
|
||||
field := st.Field(i).Name()
|
||||
fmt.Fprintf(b, `// Only pack salt if value is not "-", i.e. empty
|
||||
if rr.%s != "-" {
|
||||
off, err = packStringHex(rr.%s, msg, off)
|
||||
if err != nil {
|
||||
return off, err
|
||||
}
|
||||
}
|
||||
`, field, field)
|
||||
continue
|
||||
case strings.HasPrefix(st.Tag(i), `dns:"size-hex`): // size-hex can be packed just like hex
|
||||
fallthrough
|
||||
case st.Tag(i) == `dns:"hex"`:
|
||||
o("off, err = packStringHex(rr.%s, msg, off)\n")
|
||||
case st.Tag(i) == `dns:"any"`:
|
||||
o("off, err = packStringAny(rr.%s, msg, off)\n")
|
||||
case st.Tag(i) == `dns:"octet"`:
|
||||
o("off, err = packStringOctet(rr.%s, msg, off)\n")
|
||||
case st.Tag(i) == "":
|
||||
switch st.Field(i).Type().(*types.Basic).Kind() {
|
||||
case types.Uint8:
|
||||
o("off, err = packUint8(rr.%s, msg, off)\n")
|
||||
case types.Uint16:
|
||||
o("off, err = packUint16(rr.%s, msg, off)\n")
|
||||
case types.Uint32:
|
||||
o("off, err = packUint32(rr.%s, msg, off)\n")
|
||||
case types.Uint64:
|
||||
o("off, err = packUint64(rr.%s, msg, off)\n")
|
||||
case types.String:
|
||||
o("off, err = packString(rr.%s, msg, off)\n")
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name())
|
||||
}
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
|
||||
}
|
||||
}
|
||||
fmt.Fprintln(b, "return off, nil }\n")
|
||||
}
|
||||
|
||||
fmt.Fprint(b, "// unpack*() functions\n\n")
|
||||
for _, name := range namedTypes {
|
||||
o := scope.Lookup(name)
|
||||
st, _ := getTypeStruct(o.Type(), scope)
|
||||
|
||||
fmt.Fprintf(b, "func (rr *%s) unpack(msg []byte, off int) (off1 int, err error) {\n", name)
|
||||
fmt.Fprint(b, `rdStart := off
|
||||
_ = rdStart
|
||||
|
||||
`)
|
||||
for i := 1; i < st.NumFields(); i++ {
|
||||
o := func(s string) {
|
||||
fmt.Fprintf(b, s, st.Field(i).Name())
|
||||
fmt.Fprint(b, `if err != nil {
|
||||
return off, err
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
// size-* are special, because they reference a struct member we should use for the length.
|
||||
if strings.HasPrefix(st.Tag(i), `dns:"size-`) {
|
||||
structMember := structMember(st.Tag(i))
|
||||
structTag := structTag(st.Tag(i))
|
||||
switch structTag {
|
||||
case "hex":
|
||||
fmt.Fprintf(b, "rr.%s, off, err = unpackStringHex(msg, off, off + int(rr.%s))\n", st.Field(i).Name(), structMember)
|
||||
case "base32":
|
||||
fmt.Fprintf(b, "rr.%s, off, err = unpackStringBase32(msg, off, off + int(rr.%s))\n", st.Field(i).Name(), structMember)
|
||||
case "base64":
|
||||
fmt.Fprintf(b, "rr.%s, off, err = unpackStringBase64(msg, off, off + int(rr.%s))\n", st.Field(i).Name(), structMember)
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
|
||||
}
|
||||
fmt.Fprint(b, `if err != nil {
|
||||
return off, err
|
||||
}
|
||||
`)
|
||||
continue
|
||||
}
|
||||
|
||||
if _, ok := st.Field(i).Type().(*types.Slice); ok {
|
||||
switch st.Tag(i) {
|
||||
case `dns:"-"`: // ignored
|
||||
case `dns:"txt"`:
|
||||
o("rr.%s, off, err = unpackStringTxt(msg, off)\n")
|
||||
case `dns:"opt"`:
|
||||
o("rr.%s, off, err = unpackDataOpt(msg, off)\n")
|
||||
case `dns:"nsec"`:
|
||||
o("rr.%s, off, err = unpackDataNsec(msg, off)\n")
|
||||
case `dns:"domain-name"`:
|
||||
o("rr.%s, off, err = unpackDataDomainNames(msg, off, rdStart + int(rr.Hdr.Rdlength))\n")
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
switch st.Tag(i) {
|
||||
case `dns:"-"`: // ignored
|
||||
case `dns:"cdomain-name"`:
|
||||
fallthrough
|
||||
case `dns:"domain-name"`:
|
||||
o("rr.%s, off, err = UnpackDomainName(msg, off)\n")
|
||||
case `dns:"a"`:
|
||||
o("rr.%s, off, err = unpackDataA(msg, off)\n")
|
||||
case `dns:"aaaa"`:
|
||||
o("rr.%s, off, err = unpackDataAAAA(msg, off)\n")
|
||||
case `dns:"uint48"`:
|
||||
o("rr.%s, off, err = unpackUint48(msg, off)\n")
|
||||
case `dns:"txt"`:
|
||||
o("rr.%s, off, err = unpackString(msg, off)\n")
|
||||
case `dns:"base32"`:
|
||||
o("rr.%s, off, err = unpackStringBase32(msg, off, rdStart + int(rr.Hdr.Rdlength))\n")
|
||||
case `dns:"base64"`:
|
||||
o("rr.%s, off, err = unpackStringBase64(msg, off, rdStart + int(rr.Hdr.Rdlength))\n")
|
||||
case `dns:"hex"`:
|
||||
o("rr.%s, off, err = unpackStringHex(msg, off, rdStart + int(rr.Hdr.Rdlength))\n")
|
||||
case `dns:"any"`:
|
||||
o("rr.%s, off, err = unpackStringAny(msg, off, rdStart + int(rr.Hdr.Rdlength))\n")
|
||||
case `dns:"octet"`:
|
||||
o("rr.%s, off, err = unpackStringOctet(msg, off)\n")
|
||||
case "":
|
||||
switch st.Field(i).Type().(*types.Basic).Kind() {
|
||||
case types.Uint8:
|
||||
o("rr.%s, off, err = unpackUint8(msg, off)\n")
|
||||
case types.Uint16:
|
||||
o("rr.%s, off, err = unpackUint16(msg, off)\n")
|
||||
case types.Uint32:
|
||||
o("rr.%s, off, err = unpackUint32(msg, off)\n")
|
||||
case types.Uint64:
|
||||
o("rr.%s, off, err = unpackUint64(msg, off)\n")
|
||||
case types.String:
|
||||
o("rr.%s, off, err = unpackString(msg, off)\n")
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name())
|
||||
}
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
|
||||
}
|
||||
// If we've hit len(msg) we return without error.
|
||||
if i < st.NumFields()-1 {
|
||||
fmt.Fprintf(b, `if off == len(msg) {
|
||||
return off, nil
|
||||
}
|
||||
`)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(b, "return off, nil }\n\n")
|
||||
}
|
||||
|
||||
// gofmt
|
||||
res, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
b.WriteTo(os.Stderr)
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// write result
|
||||
f, err := os.Create("zmsg.go")
|
||||
fatalIfErr(err)
|
||||
defer f.Close()
|
||||
f.Write(res)
|
||||
}
|
||||
|
||||
// structMember will take a tag like dns:"size-base32:SaltLength" and return the last part of this string.
|
||||
func structMember(s string) string {
|
||||
fields := strings.Split(s, ":")
|
||||
if len(fields) == 0 {
|
||||
return ""
|
||||
}
|
||||
f := fields[len(fields)-1]
|
||||
// f should have a closing "
|
||||
if len(f) > 1 {
|
||||
return f[:len(f)-1]
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
// structTag will take a tag like dns:"size-base32:SaltLength" and return base32.
|
||||
func structTag(s string) string {
|
||||
fields := strings.Split(s, ":")
|
||||
if len(fields) < 2 {
|
||||
return ""
|
||||
}
|
||||
return fields[1][len("\"size-"):]
|
||||
}
|
||||
|
||||
func fatalIfErr(err error) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
287
vendor/github.com/miekg/dns/types_generate.go
generated
vendored
287
vendor/github.com/miekg/dns/types_generate.go
generated
vendored
@@ -1,287 +0,0 @@
|
||||
//+build ignore
|
||||
|
||||
// types_generate.go is meant to run with go generate. It will use
|
||||
// go/{importer,types} to track down all the RR struct types. Then for each type
|
||||
// it will generate conversion tables (TypeToRR and TypeToString) and banal
|
||||
// methods (len, Header, copy) based on the struct tags. The generated source is
|
||||
// written to ztypes.go, and is meant to be checked into git.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"go/importer"
|
||||
"go/types"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var skipLen = map[string]struct{}{
|
||||
"NSEC": {},
|
||||
"NSEC3": {},
|
||||
"OPT": {},
|
||||
"CSYNC": {},
|
||||
}
|
||||
|
||||
var packageHdr = `
|
||||
// Code generated by "go run types_generate.go"; DO NOT EDIT.
|
||||
|
||||
package dns
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net"
|
||||
)
|
||||
|
||||
`
|
||||
|
||||
var TypeToRR = template.Must(template.New("TypeToRR").Parse(`
|
||||
// TypeToRR is a map of constructors for each RR type.
|
||||
var TypeToRR = map[uint16]func() RR{
|
||||
{{range .}}{{if ne . "RFC3597"}} Type{{.}}: func() RR { return new({{.}}) },
|
||||
{{end}}{{end}} }
|
||||
|
||||
`))
|
||||
|
||||
var typeToString = template.Must(template.New("typeToString").Parse(`
|
||||
// TypeToString is a map of strings for each RR type.
|
||||
var TypeToString = map[uint16]string{
|
||||
{{range .}}{{if ne . "NSAPPTR"}} Type{{.}}: "{{.}}",
|
||||
{{end}}{{end}} TypeNSAPPTR: "NSAP-PTR",
|
||||
}
|
||||
|
||||
`))
|
||||
|
||||
var headerFunc = template.Must(template.New("headerFunc").Parse(`
|
||||
{{range .}} func (rr *{{.}}) Header() *RR_Header { return &rr.Hdr }
|
||||
{{end}}
|
||||
|
||||
`))
|
||||
|
||||
// getTypeStruct will take a type and the package scope, and return the
|
||||
// (innermost) struct if the type is considered a RR type (currently defined as
|
||||
// those structs beginning with a RR_Header, could be redefined as implementing
|
||||
// the RR interface). The bool return value indicates if embedded structs were
|
||||
// resolved.
|
||||
func getTypeStruct(t types.Type, scope *types.Scope) (*types.Struct, bool) {
|
||||
st, ok := t.Underlying().(*types.Struct)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
if st.Field(0).Type() == scope.Lookup("RR_Header").Type() {
|
||||
return st, false
|
||||
}
|
||||
if st.Field(0).Anonymous() {
|
||||
st, _ := getTypeStruct(st.Field(0).Type(), scope)
|
||||
return st, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Import and type-check the package
|
||||
pkg, err := importer.Default().Import("github.com/miekg/dns")
|
||||
fatalIfErr(err)
|
||||
scope := pkg.Scope()
|
||||
|
||||
// Collect constants like TypeX
|
||||
var numberedTypes []string
|
||||
for _, name := range scope.Names() {
|
||||
o := scope.Lookup(name)
|
||||
if o == nil || !o.Exported() {
|
||||
continue
|
||||
}
|
||||
b, ok := o.Type().(*types.Basic)
|
||||
if !ok || b.Kind() != types.Uint16 {
|
||||
continue
|
||||
}
|
||||
if !strings.HasPrefix(o.Name(), "Type") {
|
||||
continue
|
||||
}
|
||||
name := strings.TrimPrefix(o.Name(), "Type")
|
||||
if name == "PrivateRR" {
|
||||
continue
|
||||
}
|
||||
numberedTypes = append(numberedTypes, name)
|
||||
}
|
||||
|
||||
// Collect actual types (*X)
|
||||
var namedTypes []string
|
||||
for _, name := range scope.Names() {
|
||||
o := scope.Lookup(name)
|
||||
if o == nil || !o.Exported() {
|
||||
continue
|
||||
}
|
||||
if st, _ := getTypeStruct(o.Type(), scope); st == nil {
|
||||
continue
|
||||
}
|
||||
if name == "PrivateRR" {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if corresponding TypeX exists
|
||||
if scope.Lookup("Type"+o.Name()) == nil && o.Name() != "RFC3597" {
|
||||
log.Fatalf("Constant Type%s does not exist.", o.Name())
|
||||
}
|
||||
|
||||
namedTypes = append(namedTypes, o.Name())
|
||||
}
|
||||
|
||||
b := &bytes.Buffer{}
|
||||
b.WriteString(packageHdr)
|
||||
|
||||
// Generate TypeToRR
|
||||
fatalIfErr(TypeToRR.Execute(b, namedTypes))
|
||||
|
||||
// Generate typeToString
|
||||
fatalIfErr(typeToString.Execute(b, numberedTypes))
|
||||
|
||||
// Generate headerFunc
|
||||
fatalIfErr(headerFunc.Execute(b, namedTypes))
|
||||
|
||||
// Generate len()
|
||||
fmt.Fprint(b, "// len() functions\n")
|
||||
for _, name := range namedTypes {
|
||||
if _, ok := skipLen[name]; ok {
|
||||
continue
|
||||
}
|
||||
o := scope.Lookup(name)
|
||||
st, isEmbedded := getTypeStruct(o.Type(), scope)
|
||||
if isEmbedded {
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(b, "func (rr *%s) len(off int, compression map[string]struct{}) int {\n", name)
|
||||
fmt.Fprintf(b, "l := rr.Hdr.len(off, compression)\n")
|
||||
for i := 1; i < st.NumFields(); i++ {
|
||||
o := func(s string) { fmt.Fprintf(b, s, st.Field(i).Name()) }
|
||||
|
||||
if _, ok := st.Field(i).Type().(*types.Slice); ok {
|
||||
switch st.Tag(i) {
|
||||
case `dns:"-"`:
|
||||
// ignored
|
||||
case `dns:"cdomain-name"`:
|
||||
o("for _, x := range rr.%s { l += domainNameLen(x, off+l, compression, true) }\n")
|
||||
case `dns:"domain-name"`:
|
||||
o("for _, x := range rr.%s { l += domainNameLen(x, off+l, compression, false) }\n")
|
||||
case `dns:"txt"`:
|
||||
o("for _, x := range rr.%s { l += len(x) + 1 }\n")
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
switch {
|
||||
case st.Tag(i) == `dns:"-"`:
|
||||
// ignored
|
||||
case st.Tag(i) == `dns:"cdomain-name"`:
|
||||
o("l += domainNameLen(rr.%s, off+l, compression, true)\n")
|
||||
case st.Tag(i) == `dns:"domain-name"`:
|
||||
o("l += domainNameLen(rr.%s, off+l, compression, false)\n")
|
||||
case st.Tag(i) == `dns:"octet"`:
|
||||
o("l += len(rr.%s)\n")
|
||||
case strings.HasPrefix(st.Tag(i), `dns:"size-base64`):
|
||||
fallthrough
|
||||
case st.Tag(i) == `dns:"base64"`:
|
||||
o("l += base64.StdEncoding.DecodedLen(len(rr.%s))\n")
|
||||
case strings.HasPrefix(st.Tag(i), `dns:"size-hex:`): // this has an extra field where the length is stored
|
||||
o("l += len(rr.%s)/2\n")
|
||||
case strings.HasPrefix(st.Tag(i), `dns:"size-hex`):
|
||||
fallthrough
|
||||
case st.Tag(i) == `dns:"hex"`:
|
||||
o("l += len(rr.%s)/2 + 1\n")
|
||||
case st.Tag(i) == `dns:"any"`:
|
||||
o("l += len(rr.%s)\n")
|
||||
case st.Tag(i) == `dns:"a"`:
|
||||
o("if len(rr.%s) != 0 { l += net.IPv4len }\n")
|
||||
case st.Tag(i) == `dns:"aaaa"`:
|
||||
o("if len(rr.%s) != 0 { l += net.IPv6len }\n")
|
||||
case st.Tag(i) == `dns:"txt"`:
|
||||
o("for _, t := range rr.%s { l += len(t) + 1 }\n")
|
||||
case st.Tag(i) == `dns:"uint48"`:
|
||||
o("l += 6 // %s\n")
|
||||
case st.Tag(i) == "":
|
||||
switch st.Field(i).Type().(*types.Basic).Kind() {
|
||||
case types.Uint8:
|
||||
o("l++ // %s\n")
|
||||
case types.Uint16:
|
||||
o("l += 2 // %s\n")
|
||||
case types.Uint32:
|
||||
o("l += 4 // %s\n")
|
||||
case types.Uint64:
|
||||
o("l += 8 // %s\n")
|
||||
case types.String:
|
||||
o("l += len(rr.%s) + 1\n")
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name())
|
||||
}
|
||||
default:
|
||||
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(b, "return l }\n")
|
||||
}
|
||||
|
||||
// Generate copy()
|
||||
fmt.Fprint(b, "// copy() functions\n")
|
||||
for _, name := range namedTypes {
|
||||
o := scope.Lookup(name)
|
||||
st, isEmbedded := getTypeStruct(o.Type(), scope)
|
||||
if isEmbedded {
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(b, "func (rr *%s) copy() RR {\n", name)
|
||||
fields := []string{"rr.Hdr"}
|
||||
for i := 1; i < st.NumFields(); i++ {
|
||||
f := st.Field(i).Name()
|
||||
if sl, ok := st.Field(i).Type().(*types.Slice); ok {
|
||||
t := sl.Underlying().String()
|
||||
t = strings.TrimPrefix(t, "[]")
|
||||
if strings.Contains(t, ".") {
|
||||
splits := strings.Split(t, ".")
|
||||
t = splits[len(splits)-1]
|
||||
}
|
||||
// For the EDNS0 interface (used in the OPT RR), we need to call the copy method on each element.
|
||||
if t == "EDNS0" {
|
||||
fmt.Fprintf(b, "%s := make([]%s, len(rr.%s));\nfor i,e := range rr.%s {\n %s[i] = e.copy()\n}\n",
|
||||
f, t, f, f, f)
|
||||
fields = append(fields, f)
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(b, "%s := make([]%s, len(rr.%s)); copy(%s, rr.%s)\n",
|
||||
f, t, f, f, f)
|
||||
fields = append(fields, f)
|
||||
continue
|
||||
}
|
||||
if st.Field(i).Type().String() == "net.IP" {
|
||||
fields = append(fields, "copyIP(rr."+f+")")
|
||||
continue
|
||||
}
|
||||
fields = append(fields, "rr."+f)
|
||||
}
|
||||
fmt.Fprintf(b, "return &%s{%s}\n", name, strings.Join(fields, ","))
|
||||
fmt.Fprintf(b, "}\n")
|
||||
}
|
||||
|
||||
// gofmt
|
||||
res, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
b.WriteTo(os.Stderr)
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// write result
|
||||
f, err := os.Create("ztypes.go")
|
||||
fatalIfErr(err)
|
||||
defer f.Close()
|
||||
f.Write(res)
|
||||
}
|
||||
|
||||
func fatalIfErr(err error) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user