[v3.2] Add grafana dashboard importing API (#11)
* Add API to import grafana templates to kubesphere dashboard * Merge and fix the latest codes from kubesphere #2501 Signed-off-by: zhu733756 <talonzhu@yunify.com>
This commit is contained in:
6
go.mod
6
go.mod
@@ -91,7 +91,9 @@ require (
|
||||
github.com/yvasiyarov/gorelic v0.0.6 // indirect
|
||||
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f // indirect
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
|
||||
golang.org/x/tools v0.1.5 // indirect
|
||||
google.golang.org/grpc v1.30.0
|
||||
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
|
||||
gopkg.in/cas.v2 v2.2.0
|
||||
@@ -122,7 +124,7 @@ require (
|
||||
k8s.io/utils v0.0.0-20210527160623-6fdb442a123b
|
||||
kubesphere.io/api v0.0.0
|
||||
kubesphere.io/client-go v0.0.0
|
||||
kubesphere.io/monitoring-dashboard v0.1.2
|
||||
kubesphere.io/monitoring-dashboard v0.2.2
|
||||
rsc.io/letsencrypt v0.0.1 // indirect
|
||||
sigs.k8s.io/application v0.8.4-0.20201016185654-c8e2959e57a0
|
||||
sigs.k8s.io/controller-runtime v0.9.3
|
||||
@@ -797,7 +799,7 @@ replace (
|
||||
k8s.io/utils => k8s.io/utils v0.0.0-20200603063816-c1c6865ac451
|
||||
kubesphere.io/api => ./staging/src/kubesphere.io/api
|
||||
kubesphere.io/client-go => ./staging/src/kubesphere.io/client-go
|
||||
kubesphere.io/monitoring-dashboard => kubesphere.io/monitoring-dashboard v0.1.2
|
||||
kubesphere.io/monitoring-dashboard => kubesphere.io/monitoring-dashboard v0.2.2
|
||||
rsc.io/binaryregexp => rsc.io/binaryregexp v0.2.0
|
||||
rsc.io/letsencrypt => rsc.io/letsencrypt v0.0.1
|
||||
rsc.io/pdf => rsc.io/pdf v0.1.1
|
||||
|
||||
23
go.sum
23
go.sum
@@ -124,7 +124,9 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw=
|
||||
github.com/chromedp/cdproto v0.0.0-20200424080200-0de008e41fa0 h1:Mf2aT0YmWsdNULwaHeCktDLWHb1s+VoDi9xEcFboLQ4=
|
||||
github.com/chromedp/cdproto v0.0.0-20200424080200-0de008e41fa0/go.mod h1:PfAWWKJqjlGFYJEidUM6aVIWPr0EpobeyVWEEmplX7g=
|
||||
github.com/chromedp/chromedp v0.5.3 h1:F9LafxmYpsQhWQBdCs+6Sret1zzeeFyHS5LkRF//Ffg=
|
||||
github.com/chromedp/chromedp v0.5.3/go.mod h1:YLdPtndaHQ4rCpSpBG+IPpy9JvX0VD+7aaLxYgYj28w=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
@@ -152,6 +154,7 @@ github.com/containernetworking/cni v0.8.0 h1:BT9lpgGoH4jw3lFC7Odz2prU5ruiYKcgAjM
|
||||
github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
|
||||
github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.17+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-oidc v2.1.0+incompatible h1:sdJrfw8akMnCuUlaZU3tE/uYXFgfqom8DBE9so9EBsM=
|
||||
github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
|
||||
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
|
||||
@@ -207,6 +210,7 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4=
|
||||
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
|
||||
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
@@ -336,8 +340,11 @@ github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754 h1:tpom+2CJmpzAWj5
|
||||
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
|
||||
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
|
||||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
|
||||
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
|
||||
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
|
||||
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
|
||||
github.com/gocql/gocql v0.0.0-20200526081602-cd04bd7f22a7/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY=
|
||||
github.com/gocraft/dbr v0.0.0-20180507214907-a0fd650918f6 h1:kumyNm8Vr8cbVm/aLQYTbDE3SKCbbn5HEVoDp/Dyyfc=
|
||||
@@ -402,8 +409,12 @@ github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gosimple/slug v1.1.1 h1:fRu/digW+NMwBIP+RmviTK97Ho/bEj/C9swrCspN3D4=
|
||||
github.com/gosimple/slug v1.1.1/go.mod h1:ER78kgg1Mv0NQGlXiDe57DpCyfbNywXXZ9mIorhxAf0=
|
||||
github.com/gosuri/uitable v0.0.1 h1:M9sMNgSZPyAu1FJZJLpJ16ofL8q5ko2EDUkICsynvlY=
|
||||
github.com/gosuri/uitable v0.0.1/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo=
|
||||
github.com/grafana-tools/sdk v0.0.0-20210625151406-43693eb2f02b h1:I93owT2rHuA+t7YsUSnu88McWKllcXbPUbrkpMzIQbU=
|
||||
github.com/grafana-tools/sdk v0.0.0-20210625151406-43693eb2f02b/go.mod h1:uby+6hPUCRVNG/iAZKCOlaq5YhyK0oKMRke+FDesZdw=
|
||||
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f h1:ShTPMJQes6tubcjzGMODIVG5hlrCeImaBnZzKF2N8SM=
|
||||
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 h1:THDBEeQ9xZ8JEaCLyLQqXMMdRqNr0QAUJTIkQAUtFjg=
|
||||
@@ -500,6 +511,7 @@ github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0
|
||||
github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg=
|
||||
github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
github.com/knq/sysutil v0.0.0-20191005231841-15668db23d08 h1:V0an7KRw92wmJysvFvtqtKMAPmvS5O0jtB0nYo6t+gs=
|
||||
github.com/knq/sysutil v0.0.0-20191005231841-15668db23d08/go.mod h1:dFWs1zEqDjFtnBXsd1vPOZaLsESovai349994nHx3e0=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
@@ -701,6 +713,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
|
||||
github.com/prometheus/prometheus v1.8.2-0.20200507164740-ecee9c8abfd1 h1:Oh/bmW9DXCbMeAZbxMmt2wuY6Q4cD0IIbR6vJP3kdHg=
|
||||
github.com/prometheus/prometheus v1.8.2-0.20200507164740-ecee9c8abfd1/go.mod h1:S5n0C6tSgdnwWshBUceRx5G1OsjLv/EeZ9t3wIfEtsY=
|
||||
github.com/rafaeljusto/redigomock v0.0.0-20190202135759-257e089e14a1/go.mod h1:JaY6n2sDr+z2WTsXkOmNRUfDy6FN0L6Nk7x06ndm4tY=
|
||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
|
||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc=
|
||||
@@ -774,6 +788,7 @@ github.com/uber/jaeger-client-go v2.23.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMW
|
||||
github.com/uber/jaeger-lib v2.2.0+incompatible h1:MxZXOiR2JuoANZ3J6DE/U0kSFv/eJ/GfSYVCjK7dyaw=
|
||||
github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
|
||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
@@ -969,8 +984,8 @@ k8s.io/metrics v0.21.2 h1:6ajprhWZnI64RSrNqET0cBdwzaxPxr9Vh8zURBkR1zY=
|
||||
k8s.io/metrics v0.21.2/go.mod h1:wzlOINZMCtWq8dR9gHlyaOemmYlOpAoldEIXE82gAhI=
|
||||
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 h1:v8ud2Up6QK1lNOKFgiIVrZdMg7MpmSnvtrOieolJKoE=
|
||||
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
kubesphere.io/monitoring-dashboard v0.1.2 h1:KRAQbjpconHYwOYBmbpKWzE6k2DHpqQAPyZnxB5FKso=
|
||||
kubesphere.io/monitoring-dashboard v0.1.2/go.mod h1:VSP7rZv0dG4lq6aVaFB1khdjma4SPtWNAOCzgdnYvXQ=
|
||||
kubesphere.io/monitoring-dashboard v0.2.2 h1:aniATtXLgRAAvKOjd2UxWWHMh4/T7a0HoQ9bd+/bGcA=
|
||||
kubesphere.io/monitoring-dashboard v0.2.2/go.mod h1:ksDjmOuoN0C0GuYp0s5X3186cPgk2asLUaO1WlEKISY=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/letsencrypt v0.0.1 h1:DV0d09Ne9E7UUa9ZqWktZ9L2VmybgTgfq7xlfFR/bbU=
|
||||
rsc.io/letsencrypt v0.0.1/go.mod h1:buyQKZ6IXrRnB7TdkHP0RyEybLx18HHyOSoTyoOLqNY=
|
||||
@@ -995,6 +1010,10 @@ sigs.k8s.io/kustomize/cmd/config v0.9.10/go.mod h1:Mrby0WnRH7hA6OwOYnYpfpiY0WJIM
|
||||
sigs.k8s.io/kustomize/kustomize/v4 v4.1.2/go.mod h1:PxBvo4WGYlCLeRPL+ziT64wBXqbgfcalOS/SXa/tcyo=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.17 h1:4zrV0ym5AYa0e512q7K3Wp1u7mzoWW0xR3UHJcGWGIg=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.17/go.mod h1:mlQFagmkm1P+W4lZJbJ/yaxMd8PqMRSC4cPcfUVt5Hg=
|
||||
sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06 h1:zD2IemQ4LmOcAumeiyDWXKUI2SO0NYDe3H6QGvPOVgU=
|
||||
sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18=
|
||||
sigs.k8s.io/structured-merge-diff/v3 v3.0.0 h1:dOmIZBMfhcHS09XZkMyUgkq5trg3/jRyJYFZUiaOp8E=
|
||||
sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.0 h1:C4r9BgJ98vrKnnVCjwCSXcWjWe0NKcUQkmzDXZXGwH8=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
|
||||
7
pkg/apis/addtoscheme_dashboard_v1alpha2.go
Normal file
7
pkg/apis/addtoscheme_dashboard_v1alpha2.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package apis
|
||||
|
||||
import monitoringdashboardv1alpha2 "kubesphere.io/monitoring-dashboard/api/v1alpha2"
|
||||
|
||||
func init() {
|
||||
AddToSchemes = append(AddToSchemes, monitoringdashboardv1alpha2.SchemeBuilder.AddToScheme)
|
||||
}
|
||||
@@ -129,6 +129,8 @@ const (
|
||||
NotificationTag = "Notification"
|
||||
NotificationSecretNamespace = "kubesphere-monitoring-federated"
|
||||
NotificationManagedLabel = "notification.kubesphere.io/managed"
|
||||
|
||||
DashboardTag = "Dashboard"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
3
pkg/kapis/monitoring/v1alpha3/dashboard_template_test.sh
Normal file
3
pkg/kapis/monitoring/v1alpha3/dashboard_template_test.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#! /bin/bash
|
||||
|
||||
curl -d '{"grafanaDashboardName":"test2","grafanaDashboardUrl":"https://grafana.com/api/dashboards/7362/revisions/5/download"}' -H "Content-Type: application/json" localhost:9090/kapis/monitoring.kubesphere.io/v1alpha3/dashboard/template
|
||||
@@ -19,12 +19,19 @@
|
||||
package v1alpha3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"k8s.io/klog"
|
||||
|
||||
converter "kubesphere.io/monitoring-dashboard/tools/converter"
|
||||
|
||||
openpitrixoptions "kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/s3"
|
||||
|
||||
@@ -32,8 +39,11 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix"
|
||||
|
||||
"github.com/emicklei/go-restful"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
monitoringdashboardv1alpha2 "kubesphere.io/monitoring-dashboard/api/v1alpha2"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/api"
|
||||
"kubesphere.io/kubesphere/pkg/informers"
|
||||
model "kubesphere.io/kubesphere/pkg/models/monitoring"
|
||||
@@ -302,3 +312,116 @@ func (h handler) handleAdhocQuery(req *restful.Request, resp *restful.Response)
|
||||
resp.WriteAsJson(res)
|
||||
}
|
||||
}
|
||||
|
||||
// handleGrafanaDashboardImport imports Grafana template and converts it to KubeSphere dashboard.
|
||||
// The description of the Parameters:
|
||||
// grafanaDashboardName: the name of this Grafana template needed to convert.
|
||||
// grafanaDashboardUrl: the link to download this Grafana template.
|
||||
// grafanaDashboardContent: the whole JSON content needed to convert.
|
||||
// Note that the parameter grafanaDashboardName is indispensable,
|
||||
// and the requested parameter grafanaDashboardUrl and grafanaDashboardContent cannot be empty at the same time.
|
||||
func (h handler) handleGrafanaDashboardImport(req *restful.Request, resp *restful.Response) {
|
||||
var entity monitoring.DashboardEntity
|
||||
err := req.ReadEntity(&entity)
|
||||
if err != nil {
|
||||
api.HandleBadRequest(resp, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
if entity.GrafanaDashboardName == "" {
|
||||
err := errors.New("the requested parameter grafanaDashboardName cannot be empty")
|
||||
api.HandleBadRequest(resp, nil, err)
|
||||
return
|
||||
}
|
||||
if entity.GrafanaDashboardUrl == "" && entity.GrafanaDashboardContent == "" {
|
||||
err := errors.New("the requested parameter grafanaDashboardUrl and grafanaDashboardContent cannot be empty at the same time")
|
||||
api.HandleBadRequest(resp, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
grafanaDashboardContent := []byte(entity.GrafanaDashboardContent)
|
||||
if entity.GrafanaDashboardUrl != "" {
|
||||
c, err := func(u string) ([]byte, error) {
|
||||
_, err := url.ParseRequestURI(u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer r.Body.Close()
|
||||
|
||||
c, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c, nil
|
||||
}(entity.GrafanaDashboardUrl)
|
||||
|
||||
if err != nil {
|
||||
api.HandleBadRequest(resp, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
grafanaDashboardContent = []byte(c)
|
||||
}
|
||||
|
||||
c := converter.NewConverter()
|
||||
convertedDashboard, err := c.ConvertToDashboard(grafanaDashboardContent, true, "", entity.GrafanaDashboardName)
|
||||
if err != nil {
|
||||
api.HandleBadRequest(resp, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
dashboard := monitoringdashboardv1alpha2.ClusterDashboard{
|
||||
TypeMeta: v1.TypeMeta{
|
||||
APIVersion: convertedDashboard.APIVersion,
|
||||
Kind: convertedDashboard.Kind,
|
||||
},
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: convertedDashboard.Metadata["name"],
|
||||
},
|
||||
Spec: *convertedDashboard.Spec,
|
||||
}
|
||||
|
||||
jsonDashbaord, err := json.Marshal(dashboard)
|
||||
if err != nil {
|
||||
api.HandleBadRequest(resp, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
// a dashboard with the same name cannot post.
|
||||
ctx := context.TODO()
|
||||
_, err = h.k.Discovery().RESTClient().
|
||||
Get().
|
||||
AbsPath("/apis/monitoring.kubesphere.io/v1alpha2/clusterdashboards/" + dashboard.Name).
|
||||
DoRaw(ctx)
|
||||
|
||||
if err == nil {
|
||||
api.HandleBadRequest(resp, nil, errors.New("a dashboard with the same name already exists!"))
|
||||
return
|
||||
}
|
||||
|
||||
// create this dashboard
|
||||
_, err = h.k.Discovery().RESTClient().
|
||||
Post().
|
||||
AbsPath("/apis/monitoring.kubesphere.io/v1alpha2/clusterdashboards").
|
||||
Body(jsonDashbaord).
|
||||
DoRaw(ctx)
|
||||
|
||||
if err != nil {
|
||||
api.HandleBadRequest(resp, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
resp.WriteAsJson(dashboard)
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ package v1alpha3
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
monitoringdashboardv1alpha2 "kubesphere.io/monitoring-dashboard/api/v1alpha2"
|
||||
|
||||
openpitrixoptions "kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/client/clientset/versioned"
|
||||
@@ -504,6 +506,14 @@ func AddToContainer(c *restful.Container, k8sClient kubernetes.Interface, monito
|
||||
Returns(http.StatusOK, respOK, monitoring.Metric{})).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.POST("/dashboard/template").
|
||||
To(h.handleGrafanaDashboardImport).
|
||||
Doc("Convert Grafana templates to KubeSphere dashboards.").
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.DashboardTag}).
|
||||
Writes(monitoringdashboardv1alpha2.ClusterDashboard{}).
|
||||
Returns(http.StatusOK, respOK, monitoringdashboardv1alpha2.ClusterDashboard{})).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
c.Add(ws)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/klog"
|
||||
monitoringdashboardv1alpha1 "kubesphere.io/monitoring-dashboard/api/v1alpha1"
|
||||
monitoringdashboardv1alpha2 "kubesphere.io/monitoring-dashboard/api/v1alpha2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/api"
|
||||
@@ -39,7 +39,7 @@ func New(c client.Reader) v1alpha3.Interface {
|
||||
}
|
||||
|
||||
func (d *dashboardGetter) Get(_, name string) (runtime.Object, error) {
|
||||
dashboard := monitoringdashboardv1alpha1.ClusterDashboard{}
|
||||
dashboard := monitoringdashboardv1alpha2.ClusterDashboard{}
|
||||
err := d.c.Get(context.Background(), types.NamespacedName{Name: name}, &dashboard)
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -49,7 +49,7 @@ func (d *dashboardGetter) Get(_, name string) (runtime.Object, error) {
|
||||
}
|
||||
|
||||
func (d *dashboardGetter) List(_ string, query *query.Query) (*api.ListResult, error) {
|
||||
dashboards := monitoringdashboardv1alpha1.ClusterDashboardList{}
|
||||
dashboards := monitoringdashboardv1alpha2.ClusterDashboardList{}
|
||||
err := d.c.List(context.Background(), &dashboards, &client.ListOptions{LabelSelector: query.Selector()})
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -65,12 +65,12 @@ func (d *dashboardGetter) List(_ string, query *query.Query) (*api.ListResult, e
|
||||
|
||||
func (d *dashboardGetter) compare(left runtime.Object, right runtime.Object, field query.Field) bool {
|
||||
|
||||
leftClusterDashboard, ok := left.(*monitoringdashboardv1alpha1.ClusterDashboard)
|
||||
leftClusterDashboard, ok := left.(*monitoringdashboardv1alpha2.ClusterDashboard)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
rightClusterDashboard, ok := right.(*monitoringdashboardv1alpha1.ClusterDashboard)
|
||||
rightClusterDashboard, ok := right.(*monitoringdashboardv1alpha2.ClusterDashboard)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func (d *dashboardGetter) compare(left runtime.Object, right runtime.Object, fie
|
||||
}
|
||||
|
||||
func (d *dashboardGetter) filter(object runtime.Object, filter query.Filter) bool {
|
||||
dashboard, ok := object.(*monitoringdashboardv1alpha1.ClusterDashboard)
|
||||
dashboard, ok := object.(*monitoringdashboardv1alpha2.ClusterDashboard)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
monitoringdashboardv1alpha1 "kubesphere.io/monitoring-dashboard/api/v1alpha1"
|
||||
monitoringdashboardv1alpha2 "kubesphere.io/monitoring-dashboard/api/v1alpha2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
|
||||
@@ -32,8 +32,8 @@ import (
|
||||
|
||||
var c client.Client
|
||||
|
||||
func compare(actual *monitoringdashboardv1alpha1.ClusterDashboard,
|
||||
expects ...*monitoringdashboardv1alpha1.ClusterDashboard) bool {
|
||||
func compare(actual *monitoringdashboardv1alpha2.ClusterDashboard,
|
||||
expects ...*monitoringdashboardv1alpha2.ClusterDashboard) bool {
|
||||
for _, app := range expects {
|
||||
if actual.Name == app.Name && reflect.DeepEqual(actual.Labels, app.Labels) {
|
||||
return true
|
||||
@@ -44,7 +44,7 @@ func compare(actual *monitoringdashboardv1alpha1.ClusterDashboard,
|
||||
|
||||
func TestGetListClusterDashboards(t *testing.T) {
|
||||
sch := scheme.Scheme
|
||||
if err := monitoringdashboardv1alpha1.AddToScheme(sch); err != nil {
|
||||
if err := monitoringdashboardv1alpha2.AddToScheme(sch); err != nil {
|
||||
t.Fatalf("unable add APIs to scheme: %v", err)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestGetListClusterDashboards(t *testing.T) {
|
||||
var labelSet1 = map[string]string{"foo-1": "bar-1"}
|
||||
var labelSet2 = map[string]string{"foo-2": "bar-2"}
|
||||
|
||||
testCases := []*monitoringdashboardv1alpha1.ClusterDashboard{
|
||||
testCases := []*monitoringdashboardv1alpha2.ClusterDashboard{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "clusterdashboard-1",
|
||||
@@ -92,7 +92,7 @@ func TestGetListClusterDashboards(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, dashboard := range results.Items {
|
||||
dashboard, err := dashboard.(*monitoringdashboardv1alpha1.ClusterDashboard)
|
||||
dashboard, err := dashboard.(*monitoringdashboardv1alpha2.ClusterDashboard)
|
||||
if !err {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func TestGetListClusterDashboards(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dashboard := result.(*monitoringdashboardv1alpha1.ClusterDashboard)
|
||||
dashboard := result.(*monitoringdashboardv1alpha2.ClusterDashboard)
|
||||
if !compare(dashboard, testCases...) {
|
||||
t.Errorf("The results %v not match testcases %v", result, testCases)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/klog"
|
||||
monitoringdashboardv1alpha1 "kubesphere.io/monitoring-dashboard/api/v1alpha1"
|
||||
monitoringdashboardv1alpha2 "kubesphere.io/monitoring-dashboard/api/v1alpha2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/api"
|
||||
@@ -39,7 +39,7 @@ func New(c client.Reader) v1alpha3.Interface {
|
||||
}
|
||||
|
||||
func (d *dashboardGetter) Get(namespace, name string) (runtime.Object, error) {
|
||||
dashboard := monitoringdashboardv1alpha1.Dashboard{}
|
||||
dashboard := monitoringdashboardv1alpha2.Dashboard{}
|
||||
err := d.c.Get(context.Background(), types.NamespacedName{Namespace: namespace, Name: name}, &dashboard)
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -49,7 +49,7 @@ func (d *dashboardGetter) Get(namespace, name string) (runtime.Object, error) {
|
||||
}
|
||||
|
||||
func (d *dashboardGetter) List(namespace string, query *query.Query) (*api.ListResult, error) {
|
||||
dashboards := monitoringdashboardv1alpha1.DashboardList{}
|
||||
dashboards := monitoringdashboardv1alpha2.DashboardList{}
|
||||
err := d.c.List(context.Background(), &dashboards, &client.ListOptions{Namespace: namespace, LabelSelector: query.Selector()})
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -65,12 +65,12 @@ func (d *dashboardGetter) List(namespace string, query *query.Query) (*api.ListR
|
||||
|
||||
func (d *dashboardGetter) compare(left runtime.Object, right runtime.Object, field query.Field) bool {
|
||||
|
||||
leftDashboard, ok := left.(*monitoringdashboardv1alpha1.Dashboard)
|
||||
leftDashboard, ok := left.(*monitoringdashboardv1alpha2.Dashboard)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
rightDashboard, ok := right.(*monitoringdashboardv1alpha1.Dashboard)
|
||||
rightDashboard, ok := right.(*monitoringdashboardv1alpha2.Dashboard)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func (d *dashboardGetter) compare(left runtime.Object, right runtime.Object, fie
|
||||
}
|
||||
|
||||
func (d *dashboardGetter) filter(object runtime.Object, filter query.Filter) bool {
|
||||
dashboard, ok := object.(*monitoringdashboardv1alpha1.Dashboard)
|
||||
dashboard, ok := object.(*monitoringdashboardv1alpha2.Dashboard)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
monitoringdashboardv1alpha1 "kubesphere.io/monitoring-dashboard/api/v1alpha1"
|
||||
monitoringdashboardv1alpha2 "kubesphere.io/monitoring-dashboard/api/v1alpha2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
|
||||
var c client.Client
|
||||
|
||||
func compare(actual *monitoringdashboardv1alpha1.Dashboard, expects ...*monitoringdashboardv1alpha1.Dashboard) bool {
|
||||
func compare(actual *monitoringdashboardv1alpha2.Dashboard, expects ...*monitoringdashboardv1alpha2.Dashboard) bool {
|
||||
for _, app := range expects {
|
||||
if actual.Name == app.Name && actual.Namespace == app.Namespace && reflect.DeepEqual(actual.Labels, app.Labels) {
|
||||
return true
|
||||
@@ -43,7 +43,7 @@ func compare(actual *monitoringdashboardv1alpha1.Dashboard, expects ...*monitori
|
||||
|
||||
func TestGetListDashboards(t *testing.T) {
|
||||
sch := scheme.Scheme
|
||||
if err := monitoringdashboardv1alpha1.AddToScheme(sch); err != nil {
|
||||
if err := monitoringdashboardv1alpha2.AddToScheme(sch); err != nil {
|
||||
t.Fatalf("unable add APIs to scheme: %v", err)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestGetListDashboards(t *testing.T) {
|
||||
var labelSet2 = map[string]string{"foo-2": "bar-2"}
|
||||
|
||||
var ns = "ns-1"
|
||||
testCases := []*monitoringdashboardv1alpha1.Dashboard{
|
||||
testCases := []*monitoringdashboardv1alpha2.Dashboard{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "dashboard-1",
|
||||
@@ -94,7 +94,7 @@ func TestGetListDashboards(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, dashboard := range results.Items {
|
||||
dashboard, err := dashboard.(*monitoringdashboardv1alpha1.Dashboard)
|
||||
dashboard, err := dashboard.(*monitoringdashboardv1alpha2.Dashboard)
|
||||
if !err {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -108,7 +108,7 @@ func TestGetListDashboards(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dashboard := result.(*monitoringdashboardv1alpha1.Dashboard)
|
||||
dashboard := result.(*monitoringdashboardv1alpha2.Dashboard)
|
||||
if !compare(dashboard, testCases...) {
|
||||
t.Errorf("The results %v not match testcases %v", result, testCases)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
monitoringdashboardv1alpha1 "kubesphere.io/monitoring-dashboard/api/v1alpha1"
|
||||
monitoringdashboardv1alpha2 "kubesphere.io/monitoring-dashboard/api/v1alpha2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/cache"
|
||||
|
||||
clusterv1alpha1 "kubesphere.io/api/cluster/v1alpha1"
|
||||
@@ -136,7 +136,7 @@ func NewResourceGetter(factory informers.InformerFactory, cache cache.Cache) *Re
|
||||
clusterResourceGetters[clusterv1alpha1.SchemeGroupVersion.WithResource(clusterv1alpha1.ResourcesPluralCluster)] = cluster.New(factory.KubeSphereSharedInformerFactory())
|
||||
clusterResourceGetters[notificationv2beta1.SchemeGroupVersion.WithResource(notificationv2beta1.ResourcesPluralConfig)] = notification.NewNotificationConfigGetter(factory.KubeSphereSharedInformerFactory())
|
||||
clusterResourceGetters[notificationv2beta1.SchemeGroupVersion.WithResource(notificationv2beta1.ResourcesPluralReceiver)] = notification.NewNotificationReceiverGetter(factory.KubeSphereSharedInformerFactory())
|
||||
clusterResourceGetters[monitoringdashboardv1alpha1.GroupVersion.WithResource("clusterdashboards")] = clusterdashboard.New(cache)
|
||||
clusterResourceGetters[monitoringdashboardv1alpha2.GroupVersion.WithResource("clusterdashboards")] = clusterdashboard.New(cache)
|
||||
|
||||
// federated resources
|
||||
namespacedResourceGetters[typesv1beta1.SchemeGroupVersion.WithResource(typesv1beta1.ResourcePluralFederatedNamespace)] = federatednamespace.New(factory.KubeSphereSharedInformerFactory())
|
||||
@@ -148,7 +148,7 @@ func NewResourceGetter(factory informers.InformerFactory, cache cache.Cache) *Re
|
||||
namespacedResourceGetters[typesv1beta1.SchemeGroupVersion.WithResource(typesv1beta1.ResourcePluralFederatedPersistentVolumeClaim)] = federatedpersistentvolumeclaim.New(factory.KubeSphereSharedInformerFactory())
|
||||
namespacedResourceGetters[typesv1beta1.SchemeGroupVersion.WithResource(typesv1beta1.ResourcePluralFederatedStatefulSet)] = federatedstatefulset.New(factory.KubeSphereSharedInformerFactory())
|
||||
namespacedResourceGetters[typesv1beta1.SchemeGroupVersion.WithResource(typesv1beta1.ResourcePluralFederatedIngress)] = federatedingress.New(factory.KubeSphereSharedInformerFactory())
|
||||
namespacedResourceGetters[monitoringdashboardv1alpha1.GroupVersion.WithResource("dashboards")] = dashboard.New(cache)
|
||||
namespacedResourceGetters[monitoringdashboardv1alpha2.GroupVersion.WithResource("dashboards")] = dashboard.New(cache)
|
||||
|
||||
return &ResourceGetter{
|
||||
namespacedResourceGetters: namespacedResourceGetters,
|
||||
|
||||
@@ -49,6 +49,12 @@ type MetricData struct {
|
||||
MetricValues `json:"result,omitempty" description:"metric data including labels, time series and values" csv:"metric_values"`
|
||||
}
|
||||
|
||||
type DashboardEntity struct {
|
||||
GrafanaDashboardName string `json:"grafanaDashboardName"`
|
||||
GrafanaDashboardUrl string `json:"grafanaDashboardUrl,omitempty"`
|
||||
GrafanaDashboardContent string `json:"grafanaDashboardContent,omitempty"`
|
||||
}
|
||||
|
||||
// The first element is the timestamp, the second is the metric value.
|
||||
// eg, [1585658599.195, 0.528]
|
||||
type Point [2]float64
|
||||
|
||||
2
vendor/github.com/gosimple/slug/.gitignore
generated
vendored
Normal file
2
vendor/github.com/gosimple/slug/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
_*
|
||||
cover*.out
|
||||
373
vendor/github.com/gosimple/slug/LICENSE
generated
vendored
Normal file
373
vendor/github.com/gosimple/slug/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,373 @@
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
||||
54
vendor/github.com/gosimple/slug/README.md
generated
vendored
Normal file
54
vendor/github.com/gosimple/slug/README.md
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
slug
|
||||
====
|
||||
|
||||
Package `slug` generate slug from unicode string, URL-friendly slugify with
|
||||
multiple languages support.
|
||||
|
||||
[](https://godoc.org/github.com/gosimple/slug)
|
||||
[](https://drone.io/github.com/gosimple/slug/latest)
|
||||
|
||||
[Documentation online](http://godoc.org/github.com/gosimple/slug)
|
||||
|
||||
## Example
|
||||
|
||||
package main
|
||||
|
||||
import(
|
||||
"github.com/gosimple/slug"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main () {
|
||||
text := slug.Make("Hellö Wörld хелло ворлд")
|
||||
fmt.Println(text) // Will print: "hello-world-khello-vorld"
|
||||
|
||||
someText := slug.Make("影師")
|
||||
fmt.Println(someText) // Will print: "ying-shi"
|
||||
|
||||
enText := slug.MakeLang("This & that", "en")
|
||||
fmt.Println(enText) // Will print: "this-and-that"
|
||||
|
||||
deText := slug.MakeLang("Diese & Dass", "de")
|
||||
fmt.Println(deText) // Will print: "diese-und-dass"
|
||||
|
||||
slug.CustomSub = map[string]string{
|
||||
"water": "sand",
|
||||
}
|
||||
textSub := slug.Make("water is hot")
|
||||
fmt.Println(textSub) // Will print: "sand-is-hot"
|
||||
}
|
||||
|
||||
### Requests or bugs?
|
||||
<https://github.com/gosimple/slug/issues>
|
||||
|
||||
## Installation
|
||||
|
||||
go get -u github.com/gosimple/slug
|
||||
|
||||
## License
|
||||
|
||||
The source files are distributed under the
|
||||
[Mozilla Public License, version 2.0](http://mozilla.org/MPL/2.0/),
|
||||
unless otherwise noted.
|
||||
Please read the [FAQ](http://www.mozilla.org/MPL/2.0/FAQ.html)
|
||||
if you have further questions regarding the license.
|
||||
43
vendor/github.com/gosimple/slug/doc.go
generated
vendored
Normal file
43
vendor/github.com/gosimple/slug/doc.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2013 by Dobrosław Żybort. All rights reserved.
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
/*
|
||||
Package slug generate slug from unicode string, URL-friendly slugify with
|
||||
multiple languages support.
|
||||
|
||||
Example:
|
||||
|
||||
package main
|
||||
|
||||
import(
|
||||
"github.com/gosimple/slug"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main () {
|
||||
text := slug.Make("Hellö Wörld хелло ворлд")
|
||||
fmt.Println(text) // Will print hello-world-khello-vorld
|
||||
|
||||
someText := slug.Make("影師")
|
||||
fmt.Println(someText) // Will print: ying-shi
|
||||
|
||||
enText := slug.MakeLang("This & that", "en")
|
||||
fmt.Println(enText) // Will print 'this-and-that'
|
||||
|
||||
deText := slug.MakeLang("Diese & Dass", "de")
|
||||
fmt.Println(deText) // Will print 'diese-und-dass'
|
||||
|
||||
slug.CustomSub = map[string]string{
|
||||
"water": "sand",
|
||||
}
|
||||
textSub := slug.Make("water is hot")
|
||||
fmt.Println(textSub) // Will print 'sand-is-hot'
|
||||
}
|
||||
|
||||
Requests or bugs?
|
||||
|
||||
https://github.com/gosimple/slug/issues
|
||||
*/
|
||||
package slug
|
||||
57
vendor/github.com/gosimple/slug/languages_substitution.go
generated
vendored
Normal file
57
vendor/github.com/gosimple/slug/languages_substitution.go
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright 2013 by Dobrosław Żybort. All rights reserved.
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package slug
|
||||
|
||||
func init() {
|
||||
// Merge language subs with the default one
|
||||
for _, sub := range []*map[rune]string{&deSub, &enSub, &plSub, &esSub} {
|
||||
for key, value := range defaultSub {
|
||||
(*sub)[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var defaultSub = map[rune]string{
|
||||
'"': "",
|
||||
'\'': "",
|
||||
'’': "",
|
||||
'‒': "-", // figure dash
|
||||
'–': "-", // en dash
|
||||
'—': "-", // em dash
|
||||
'―': "-", // horizontal bar
|
||||
}
|
||||
|
||||
var deSub = map[rune]string{
|
||||
'&': "und",
|
||||
'@': "an",
|
||||
}
|
||||
|
||||
var enSub = map[rune]string{
|
||||
'&': "and",
|
||||
'@': "at",
|
||||
}
|
||||
|
||||
var plSub = map[rune]string{
|
||||
'&': "i",
|
||||
'@': "na",
|
||||
}
|
||||
|
||||
var esSub = map[rune]string{
|
||||
'&': "y",
|
||||
'@': "en",
|
||||
}
|
||||
|
||||
var grSub = map[rune]string{
|
||||
'&': "kai",
|
||||
'η': "i",
|
||||
'ή': "i",
|
||||
'Η': "i",
|
||||
'ι': "i",
|
||||
'ί': "i",
|
||||
'Ι': "i",
|
||||
'χ': "x",
|
||||
'Χ': "x",
|
||||
}
|
||||
157
vendor/github.com/gosimple/slug/slug.go
generated
vendored
Normal file
157
vendor/github.com/gosimple/slug/slug.go
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
// Copyright 2013 by Dobrosław Żybort. All rights reserved.
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package slug
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/rainycape/unidecode"
|
||||
)
|
||||
|
||||
var (
|
||||
// CustomSub stores custom substitution map
|
||||
CustomSub map[string]string
|
||||
// CustomRuneSub stores custom rune substitution map
|
||||
CustomRuneSub map[rune]string
|
||||
|
||||
// MaxLength stores maximum slug length.
|
||||
// It's smart so it will cat slug after full word.
|
||||
// By default slugs aren't shortened.
|
||||
// If MaxLength is smaller than length of the first word, then returned
|
||||
// slug will contain only substring from the first word truncated
|
||||
// after MaxLength.
|
||||
MaxLength int
|
||||
|
||||
regexpNonAuthorizedChars = regexp.MustCompile("[^a-z0-9-_]")
|
||||
regexpMultipleDashes = regexp.MustCompile("-+")
|
||||
)
|
||||
|
||||
//=============================================================================
|
||||
|
||||
// Make returns slug generated from provided string. Will use "en" as language
|
||||
// substitution.
|
||||
func Make(s string) (slug string) {
|
||||
return MakeLang(s, "en")
|
||||
}
|
||||
|
||||
// MakeLang returns slug generated from provided string and will use provided
|
||||
// language for chars substitution.
|
||||
func MakeLang(s string, lang string) (slug string) {
|
||||
slug = strings.TrimSpace(s)
|
||||
|
||||
// Custom substitutions
|
||||
// Always substitute runes first
|
||||
slug = SubstituteRune(slug, CustomRuneSub)
|
||||
slug = Substitute(slug, CustomSub)
|
||||
|
||||
// Process string with selected substitution language
|
||||
switch lang {
|
||||
case "de":
|
||||
slug = SubstituteRune(slug, deSub)
|
||||
case "en":
|
||||
slug = SubstituteRune(slug, enSub)
|
||||
case "pl":
|
||||
slug = SubstituteRune(slug, plSub)
|
||||
case "es":
|
||||
slug = SubstituteRune(slug, esSub)
|
||||
case "gr":
|
||||
slug = SubstituteRune(slug, grSub)
|
||||
default: // fallback to "en" if lang not found
|
||||
slug = SubstituteRune(slug, enSub)
|
||||
}
|
||||
|
||||
// Process all non ASCII symbols
|
||||
slug = unidecode.Unidecode(slug)
|
||||
|
||||
slug = strings.ToLower(slug)
|
||||
|
||||
// Process all remaining symbols
|
||||
slug = regexpNonAuthorizedChars.ReplaceAllString(slug, "-")
|
||||
slug = regexpMultipleDashes.ReplaceAllString(slug, "-")
|
||||
slug = strings.Trim(slug, "-")
|
||||
|
||||
if MaxLength > 0 {
|
||||
slug = smartTruncate(slug)
|
||||
}
|
||||
|
||||
return slug
|
||||
}
|
||||
|
||||
// Substitute returns string with superseded all substrings from
|
||||
// provided substitution map. Substitution map will be applied in alphabetic
|
||||
// order. Many passes, on one substitution another one could apply.
|
||||
func Substitute(s string, sub map[string]string) (buf string) {
|
||||
buf = s
|
||||
var keys []string
|
||||
for k := range sub {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, key := range keys {
|
||||
buf = strings.Replace(buf, key, sub[key], -1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// SubstituteRune substitutes string chars with provided rune
|
||||
// substitution map. One pass.
|
||||
func SubstituteRune(s string, sub map[rune]string) string {
|
||||
var buf bytes.Buffer
|
||||
for _, c := range s {
|
||||
if d, ok := sub[c]; ok {
|
||||
buf.WriteString(d)
|
||||
} else {
|
||||
buf.WriteRune(c)
|
||||
}
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func smartTruncate(text string) string {
|
||||
if len(text) < MaxLength {
|
||||
return text
|
||||
}
|
||||
|
||||
var truncated string
|
||||
words := strings.SplitAfter(text, "-")
|
||||
// If MaxLength is smaller than length of the first word return word
|
||||
// truncated after MaxLength.
|
||||
if len(words[0]) > MaxLength {
|
||||
return words[0][:MaxLength]
|
||||
}
|
||||
for _, word := range words {
|
||||
if len(truncated)+len(word)-1 <= MaxLength {
|
||||
truncated = truncated + word
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return strings.Trim(truncated, "-")
|
||||
}
|
||||
|
||||
// IsSlug returns True if provided text does not contain white characters,
|
||||
// punctuation, all letters are lower case and only from ASCII range.
|
||||
// It could contain `-` and `_` but not at the beginning or end of the text.
|
||||
// It should be in range of the MaxLength var if specified.
|
||||
// All output from slug.Make(text) should pass this test.
|
||||
func IsSlug(text string) bool {
|
||||
if text == "" ||
|
||||
(MaxLength > 0 && len(text) > MaxLength) ||
|
||||
text[0] == '-' || text[0] == '_' ||
|
||||
text[len(text)-1] == '-' || text[len(text)-1] == '_' {
|
||||
return false
|
||||
}
|
||||
for _, c := range text {
|
||||
if (c < 'a' || c > 'z') && c != '-' && c != '_' && (c < '0' || c > '9') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
30
vendor/github.com/grafana-tools/sdk/.gitignore
generated
vendored
Normal file
30
vendor/github.com/grafana-tools/sdk/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
|
||||
# Tests
|
||||
coverage.out
|
||||
|
||||
# IDE
|
||||
.idea
|
||||
110
vendor/github.com/grafana-tools/sdk/.travis.yml
generated
vendored
Normal file
110
vendor/github.com/grafana-tools/sdk/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
---
|
||||
language: go
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
# Different Grafana + Go versions that will be tested.
|
||||
jobs:
|
||||
include:
|
||||
- name: "Grafana 6.7.1 1.14.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.7.1"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.14.x"
|
||||
- name: "Grafana 6.6.2 1.14.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.6.2"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.14.x"
|
||||
- name: "Grafana 6.5.3 1.14.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.5.3"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.14.x"
|
||||
- name: "Grafana 6.4.5 1.14.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.4.5 1.13.x"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.13.x"
|
||||
- name: "Grafana 6.7.1 1.13.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.7.1"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.13.x"
|
||||
- name: "Grafana 6.6.2 1.13.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.6.2"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.13.x"
|
||||
- name: "Grafana 6.5.3 1.13.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.5.3"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.13.x"
|
||||
- name: "Grafana 6.4.5 1.13.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.4.5 1.13.x"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.13.x"
|
||||
- name: "Grafana 6.7.1 1.12.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.7.1"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.12.x"
|
||||
- name: "Grafana 6.6.2 1.12.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.6.2"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.12.x"
|
||||
- name: "Grafana 6.5.3 1.12.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.5.3"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.12.x"
|
||||
- name: "Grafana 6.4.5 1.12.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.4.5"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.12.x"
|
||||
- name: "Grafana 6.7.1 1.11.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.7.1"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.11.x"
|
||||
- name: "Grafana 6.6.2 1.11.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.6.2"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.11.x"
|
||||
- name: "Grafana 6.5.3 1.11.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.5.3"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.11.x"
|
||||
- name: "Grafana 6.4.5 1.11.x"
|
||||
env:
|
||||
- "GRAFANA_VERSION=6.4.5"
|
||||
- "GRAFANA_INTEGRATION=1"
|
||||
go: "1.11.x"
|
||||
|
||||
# Required for coverage.
|
||||
before_install:
|
||||
- go get golang.org/x/tools/cmd/cover
|
||||
- go get github.com/mattn/goveralls
|
||||
# Run Grafana
|
||||
- "docker pull grafana/grafana:$GRAFANA_VERSION"
|
||||
- "docker network create grafana"
|
||||
- "docker run -d -p 9222:9222 --network grafana --rm --name headless-shell --shm-size 2G chromedp/headless-shell"
|
||||
- "docker run --network grafana -e GF_AUTH_ANONYMOUS_ENABLED=true --rm -d -p 3000:3000 grafana/grafana:$GRAFANA_VERSION"
|
||||
|
||||
before_script:
|
||||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin
|
||||
|
||||
|
||||
# only one subpackage tested yet
|
||||
script:
|
||||
- go build -a -v ./...
|
||||
- golangci-lint run
|
||||
- go test -v -covermode=count -coverprofile=coverage.out
|
||||
- $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis-ci
|
||||
201
vendor/github.com/grafana-tools/sdk/LICENSE
generated
vendored
Normal file
201
vendor/github.com/grafana-tools/sdk/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
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.
|
||||
138
vendor/github.com/grafana-tools/sdk/README.md
generated
vendored
Normal file
138
vendor/github.com/grafana-tools/sdk/README.md
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
<!--*- mode:markdown -*-->
|
||||
|
||||
# Grafana SDK [](https://goreportcard.com/report/github.com/grafana-tools/sdk)
|
||||
|
||||
SDK for Go language offers a library for interacting with
|
||||
[Grafana](http://grafana.org) server from Go applications. It
|
||||
realizes many of
|
||||
[HTTP REST API](https://grafana.com/docs/grafana/latest/http_api/) calls for
|
||||
administration, client, organizations. Beside of them it allows
|
||||
creating of Grafana objects (dashboards, panels, datasources) locally
|
||||
and manipulating them for constructing dashboards programmatically.
|
||||
It would be helpful for massive operations on a large set of
|
||||
Grafana objects.
|
||||
|
||||
It was made foremost for
|
||||
[autograf](https://github.com/grafana-tools/autograf) project but
|
||||
later separated from it and moved to this new repository because the
|
||||
library is useful per se.
|
||||
|
||||
## Library design principles
|
||||
|
||||
1. SDK offers client functionality so it covers Grafana REST API with
|
||||
its requests and responses as close as possible.
|
||||
1. SDK maps Grafana objects (dashboard, row, panel, datasource) to
|
||||
similar Go structures but not follows exactly all Grafana
|
||||
abstractions.
|
||||
1. It doesn't use any logger, instead API functions could return errors
|
||||
where it need.
|
||||
1. Prefere no external deps except Go stdlib.
|
||||
1. Cover SDK calls with unit tests.
|
||||
|
||||
## Examples [](https://godoc.org/github.com/grafana-tools/sdk)
|
||||
|
||||
```go
|
||||
board := sdk.NewBoard("Sample dashboard title")
|
||||
board.ID = 1
|
||||
board.Time.From = "now-30m"
|
||||
board.Time.To = "now"
|
||||
row1 := board.AddRow("Sample row title")
|
||||
row1.Add(sdk.NewGraph("Sample graph"))
|
||||
graph := sdk.NewGraph("Sample graph 2")
|
||||
target := sdk.Target{
|
||||
RefID: "A",
|
||||
Datasource: "Sample Source 1",
|
||||
Expr: "sample request 1"}
|
||||
graph.AddTarget(&target)
|
||||
row1.Add(graph)
|
||||
grafanaURL := "http://grafana.host"
|
||||
c := sdk.NewClient(grafanaURL, "grafana-api-key", sdk.DefaultHTTPClient)
|
||||
response, err := c.SetDashboard(context.TODO() ,*board, sdk.SetDashboardParams{
|
||||
Overwrite: false,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Printf("error on uploading dashboard %s", board.Title)
|
||||
} else {
|
||||
fmt.Printf("dashboard URL: %v", grafanaURL+*response.URL)
|
||||
}
|
||||
```
|
||||
|
||||
The library includes several demo apps for showing API usage:
|
||||
|
||||
* [backup-dashboards](cmd/backup-dashboards) — saves all your dashboards as JSON-files.
|
||||
* [backup-datasources](cmd/backup-datasources) — saves all your datasources as JSON-files.
|
||||
* [import-datasources](cmd/import-datasources) — imports datasources from JSON-files.
|
||||
* [import-dashboards](cmd/import-dashboards) — imports dashboards from JSON-files.
|
||||
|
||||
You need Grafana API key with _admin rights_ for using these utilities.
|
||||
|
||||
## Installation [](https://travis-ci.org/grafana-tools/sdk)
|
||||
|
||||
Of course Go development environment should be set up first. Then:
|
||||
|
||||
go get github.com/grafana-tools/sdk
|
||||
|
||||
Dependency packages have included into
|
||||
distro. [govendor](https://github.com/kardianos/govendor) utility used
|
||||
for vendoring. The single dependency now is:
|
||||
|
||||
go get github.com/gosimple/slug
|
||||
|
||||
The "slugify" for URLs is a simple task but this package used in
|
||||
Grafana server so it used in the SDK for the compatibility reasons.
|
||||
|
||||
## Status of REST API realization [](https://coveralls.io/github/grafana-tools/sdk?branch=master)
|
||||
|
||||
Work on full API implementation still in progress. Currently
|
||||
implemented only create/update/delete operations for dashboards and
|
||||
datasources. State of support for misc API parts noted below.
|
||||
|
||||
| API | Status |
|
||||
|-----------------------------|---------------------------|
|
||||
| Authorization | API tokens and Basic Auth |
|
||||
| Annotations | partially |
|
||||
| Dashboards | partially |
|
||||
| Datasources | + |
|
||||
| Alert notification channels | + |
|
||||
| Organization (current) | partially |
|
||||
| Organizations | partially |
|
||||
| Users | partially |
|
||||
| User (actual) | partially |
|
||||
| Snapshots | partially |
|
||||
| Frontend settings | - |
|
||||
| Admin | partially |
|
||||
|
||||
There is no exact roadmap. The integration tests are being run against the
|
||||
following Grafana versions:
|
||||
|
||||
* [6.7.1](./travis.yml)
|
||||
* [6.6.2](/.travis.yml)
|
||||
* [6.5.3](/.travis.yml)
|
||||
* [6.4.5](/.travis.yml)
|
||||
|
||||
With the following Go versions:
|
||||
|
||||
* 1.14.x
|
||||
* 1.13.x
|
||||
* 1.12.x
|
||||
* 1.11.x
|
||||
|
||||
I still have interest to this library development but not always have
|
||||
time for it. So I gladly accept new contributions. Drop an issue or
|
||||
[contact me](grafov@gmail.com).
|
||||
|
||||
## Licence
|
||||
|
||||
Distributed under Apache v2.0. All rights belong to the SDK
|
||||
authors. There is no authors list yet, you can see the full list of
|
||||
the contributors in the git history. Official repository is
|
||||
https://github.com/grafana-tools/sdk
|
||||
|
||||
## Collection of Grafana tools in Golang
|
||||
|
||||
* [github.com/nytm/go-grafana-api](https://github.com/nytm/go-grafana-api) — a golang client of Grafana project currently that realizes parts of the REST API, used for the Grafana Terraform provider.
|
||||
* [github.com/adejoux/grafanaclient](https://github.com/adejoux/grafanaclient) — API to manage Grafana 2.0 datasources and dashboards. It lacks features from 2.5 and later Grafana versions.
|
||||
* [github.com/mgit-at/grafana-backup](https://github.com/mgit-at/grafana-backup) — just saves dashboards localy.
|
||||
* [github.com/raintank/memo](https://github.com/raintank/memo) — send slack mentions to Grafana annotations.
|
||||
* [github.com/retzkek/grafctl](https://github.com/retzkek/grafctl) — backup/restore/track dashboards with git.
|
||||
* [github.com/grafana/grizzly](https://github.com/grafana/grizzly) — manage Grafana dashboards via CLI and libsonnet/jsonnet
|
||||
29
vendor/github.com/grafana-tools/sdk/address.go
generated
vendored
Normal file
29
vendor/github.com/grafana-tools/sdk/address.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
type Address struct {
|
||||
Address1 string `json:"address1"`
|
||||
Address2 string `json:"address2"`
|
||||
City string `json:"city"`
|
||||
ZipCode string `json:"zipCode"`
|
||||
State string `json:"state"`
|
||||
Country string `json:"country"`
|
||||
}
|
||||
31
vendor/github.com/grafana-tools/sdk/alertnotification.go
generated
vendored
Normal file
31
vendor/github.com/grafana-tools/sdk/alertnotification.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016-2020 The Grafana SDK 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.
|
||||
*/
|
||||
|
||||
// AlertNotification as described in the doc
|
||||
// https://grafana.com/docs/grafana/latest/http_api/alerting_notification_channels/
|
||||
type AlertNotification struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
IsDefault bool `json:"isDefault"`
|
||||
DisableResolveMessage bool `json:"disableResolveMessage"`
|
||||
SendReminder bool `json:"sendReminder"`
|
||||
Frequency string `json:"frequency"`
|
||||
Settings interface{} `json:"settings"`
|
||||
UID string `json:"uid,omitempty"`
|
||||
}
|
||||
37
vendor/github.com/grafana-tools/sdk/annotation.go
generated
vendored
Normal file
37
vendor/github.com/grafana-tools/sdk/annotation.go
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
package sdk
|
||||
|
||||
// AnnotationResponse is representation of an existing annotation
|
||||
type AnnotationResponse struct {
|
||||
ID uint `json:"id"`
|
||||
AlertID uint `json:"alertId"`
|
||||
DashboardID uint `json:"dashboardId,omitempty"`
|
||||
PanelID uint `json:"panelId,omitempty"`
|
||||
UserID uint `json:"userId,omitempty"`
|
||||
UserName string `json:"userName,omitempty"`
|
||||
NewState string `json:"newState,omitempty"`
|
||||
PrevState string `json:"prevState,omitempty"`
|
||||
Time int64 `json:"time,omitempty"`
|
||||
TimeEnd int64 `json:"timeEnd,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
Type string `json:"type"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
}
|
||||
|
||||
// CreateAnnotationRequest is a request to create a new annotation
|
||||
type CreateAnnotationRequest struct {
|
||||
DashboardID uint `json:"dashboardId,omitempty"`
|
||||
PanelID uint `json:"panelId,omitempty"`
|
||||
Time int64 `json:"time,omitempty"`
|
||||
TimeEnd int64 `json:"timeEnd,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
// PatchAnnotationRequest is a request to patch an existing annotation
|
||||
type PatchAnnotationRequest struct {
|
||||
Time int64 `json:"time,omitempty"`
|
||||
TimeEnd int64 `json:"timeEnd,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
}
|
||||
240
vendor/github.com/grafana-tools/sdk/board.go
generated
vendored
Normal file
240
vendor/github.com/grafana-tools/sdk/board.go
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/gosimple/slug"
|
||||
)
|
||||
|
||||
var (
|
||||
boardID uint
|
||||
)
|
||||
|
||||
// Constants for templating
|
||||
const (
|
||||
TemplatingHideNone = iota
|
||||
TemplatingHideLabel
|
||||
TemplatingHideVariable
|
||||
)
|
||||
|
||||
type (
|
||||
// Board represents Grafana dashboard.
|
||||
Board struct {
|
||||
ID uint `json:"id,omitempty"`
|
||||
UID string `json:"uid,omitempty"`
|
||||
Slug string `json:"slug"`
|
||||
Title string `json:"title"`
|
||||
OriginalTitle string `json:"originalTitle"`
|
||||
Tags []string `json:"tags"`
|
||||
Style string `json:"style"`
|
||||
Timezone string `json:"timezone"`
|
||||
Editable bool `json:"editable"`
|
||||
HideControls bool `json:"hideControls" graf:"hide-controls"`
|
||||
SharedCrosshair bool `json:"sharedCrosshair" graf:"shared-crosshair"`
|
||||
Panels []*Panel `json:"panels"`
|
||||
Rows []*Row `json:"rows"`
|
||||
Templating Templating `json:"templating"`
|
||||
Annotations struct {
|
||||
List []Annotation `json:"list"`
|
||||
} `json:"annotations"`
|
||||
Refresh *BoolString `json:"refresh,omitempty"`
|
||||
SchemaVersion uint `json:"schemaVersion"`
|
||||
Version uint `json:"version"`
|
||||
Links []Link `json:"links"`
|
||||
Time Time `json:"time"`
|
||||
Timepicker Timepicker `json:"timepicker"`
|
||||
GraphTooltip int `json:"graphTooltip,omitempty"`
|
||||
}
|
||||
Time struct {
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
}
|
||||
Timepicker struct {
|
||||
Now *bool `json:"now,omitempty"`
|
||||
RefreshIntervals []string `json:"refresh_intervals"`
|
||||
TimeOptions []string `json:"time_options"`
|
||||
}
|
||||
Templating struct {
|
||||
List []TemplateVar `json:"list"`
|
||||
}
|
||||
TemplateVar struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Auto bool `json:"auto,omitempty"`
|
||||
AutoCount *int `json:"auto_count,omitempty"`
|
||||
Datasource *string `json:"datasource"`
|
||||
Refresh BoolInt `json:"refresh"`
|
||||
Options []Option `json:"options"`
|
||||
IncludeAll bool `json:"includeAll"`
|
||||
AllFormat string `json:"allFormat"`
|
||||
AllValue string `json:"allValue"`
|
||||
Multi bool `json:"multi"`
|
||||
MultiFormat string `json:"multiFormat"`
|
||||
Query interface{} `json:"query"`
|
||||
Regex string `json:"regex"`
|
||||
Current Current `json:"current"`
|
||||
Label string `json:"label"`
|
||||
Hide uint8 `json:"hide"`
|
||||
Sort int `json:"sort"`
|
||||
}
|
||||
// for templateVar
|
||||
Option struct {
|
||||
Text string `json:"text"`
|
||||
Value string `json:"value"`
|
||||
Selected bool `json:"selected"`
|
||||
}
|
||||
// for templateVar
|
||||
Current struct {
|
||||
Tags []*string `json:"tags,omitempty"`
|
||||
Text *StringSliceString `json:"text"`
|
||||
Value interface{} `json:"value"` // TODO select more precise type
|
||||
}
|
||||
Annotation struct {
|
||||
Name string `json:"name"`
|
||||
Datasource *string `json:"datasource"`
|
||||
ShowLine bool `json:"showLine"`
|
||||
IconColor string `json:"iconColor"`
|
||||
LineColor string `json:"lineColor"`
|
||||
IconSize uint `json:"iconSize"`
|
||||
Enable bool `json:"enable"`
|
||||
Query string `json:"query"`
|
||||
Expr string `json:"expr"`
|
||||
Step string `json:"step"`
|
||||
TextField string `json:"textField"`
|
||||
TextFormat string `json:"textFormat"`
|
||||
TitleFormat string `json:"titleFormat"`
|
||||
TagsField string `json:"tagsField"`
|
||||
Tags []string `json:"tags"`
|
||||
TagKeys string `json:"tagKeys"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
// Link represents link to another dashboard or external weblink
|
||||
Link struct {
|
||||
Title string `json:"title"`
|
||||
Type string `json:"type"`
|
||||
AsDropdown *bool `json:"asDropdown,omitempty"`
|
||||
DashURI *string `json:"dashUri,omitempty"`
|
||||
Dashboard *string `json:"dashboard,omitempty"`
|
||||
Icon *string `json:"icon,omitempty"`
|
||||
IncludeVars bool `json:"includeVars"`
|
||||
KeepTime *bool `json:"keepTime,omitempty"`
|
||||
Params *string `json:"params,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
TargetBlank *bool `json:"targetBlank,omitempty"`
|
||||
Tooltip *string `json:"tooltip,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
// Height of rows maybe passed as number (ex 200) or
|
||||
// as string (ex "200px") or empty string
|
||||
type Height string
|
||||
|
||||
func (h *Height) UnmarshalJSON(raw []byte) error {
|
||||
if raw == nil || bytes.Equal(raw, []byte(`"null"`)) {
|
||||
return nil
|
||||
}
|
||||
if raw[0] != '"' {
|
||||
tmp := []byte{'"'}
|
||||
raw = append(tmp, raw...)
|
||||
raw = append(raw, byte('"'))
|
||||
}
|
||||
var tmp string
|
||||
err := json.Unmarshal(raw, &tmp)
|
||||
*h = Height(tmp)
|
||||
return err
|
||||
}
|
||||
|
||||
func NewBoard(title string) *Board {
|
||||
boardID++
|
||||
return &Board{
|
||||
ID: boardID,
|
||||
Title: title,
|
||||
Style: "dark",
|
||||
Timezone: "browser",
|
||||
Editable: true,
|
||||
HideControls: false,
|
||||
Rows: []*Row{},
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Board) AddLink(link Link) {
|
||||
b.Links = append(b.Links, link)
|
||||
}
|
||||
|
||||
func (b *Board) RemoveTags(tags ...string) {
|
||||
// order might change after removing the tags
|
||||
for _, toRemoveTag := range tags {
|
||||
tagLen := len(b.Tags)
|
||||
for i, tag := range b.Tags {
|
||||
if tag == toRemoveTag {
|
||||
b.Tags[tagLen-1], b.Tags[i] = b.Tags[i], b.Tags[tagLen-1]
|
||||
b.Tags = b.Tags[:tagLen-1]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Board) AddTags(tags ...string) {
|
||||
tagFound := make(map[string]bool, len(b.Tags))
|
||||
for _, tag := range b.Tags {
|
||||
tagFound[tag] = true
|
||||
}
|
||||
for _, tag := range tags {
|
||||
if tagFound[tag] {
|
||||
continue
|
||||
}
|
||||
b.Tags = append(b.Tags, tag)
|
||||
tagFound[tag] = true
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Board) HasTag(tag string) bool {
|
||||
for _, t := range b.Tags {
|
||||
if t == tag {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (b *Board) AddRow(title string) *Row {
|
||||
if title == "" {
|
||||
title = "New row"
|
||||
}
|
||||
row := &Row{
|
||||
Title: title,
|
||||
Collapse: false,
|
||||
Editable: true,
|
||||
Height: "250px",
|
||||
}
|
||||
b.Rows = append(b.Rows, row)
|
||||
return row
|
||||
}
|
||||
|
||||
func (b *Board) UpdateSlug() string {
|
||||
b.Slug = strings.ToLower(slug.Make(b.Title))
|
||||
return b.Slug
|
||||
}
|
||||
235
vendor/github.com/grafana-tools/sdk/custom-types.go
generated
vendored
Normal file
235
vendor/github.com/grafana-tools/sdk/custom-types.go
generated
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type BoolString struct {
|
||||
Flag bool
|
||||
Value string
|
||||
}
|
||||
|
||||
func (s *BoolString) UnmarshalJSON(raw []byte) error {
|
||||
if raw == nil || bytes.Equal(raw, []byte(`"null"`)) {
|
||||
return nil
|
||||
}
|
||||
var (
|
||||
tmp string
|
||||
err error
|
||||
)
|
||||
if raw[0] != '"' {
|
||||
if bytes.Equal(raw, []byte("true")) {
|
||||
s.Flag = true
|
||||
return nil
|
||||
}
|
||||
if bytes.Equal(raw, []byte("false")) {
|
||||
return nil
|
||||
}
|
||||
return errors.New("bad boolean value provided")
|
||||
}
|
||||
if err = json.Unmarshal(raw, &tmp); err != nil {
|
||||
return err
|
||||
}
|
||||
s.Value = tmp
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s BoolString) MarshalJSON() ([]byte, error) {
|
||||
if s.Value != "" {
|
||||
var buf bytes.Buffer
|
||||
buf.WriteRune('"')
|
||||
buf.WriteString(s.Value)
|
||||
buf.WriteRune('"')
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
return strconv.AppendBool([]byte{}, s.Flag), nil
|
||||
}
|
||||
|
||||
type BoolInt struct {
|
||||
Flag bool
|
||||
Value *int64
|
||||
}
|
||||
|
||||
func (s *BoolInt) UnmarshalJSON(raw []byte) error {
|
||||
if raw == nil || bytes.Equal(raw, []byte(`"null"`)) {
|
||||
return nil
|
||||
}
|
||||
var (
|
||||
tmp int64
|
||||
err error
|
||||
)
|
||||
if tmp, err = strconv.ParseInt(string(raw), 10, 64); err != nil {
|
||||
if bytes.Equal(raw, []byte("true")) {
|
||||
s.Flag = true
|
||||
return nil
|
||||
}
|
||||
if bytes.Equal(raw, []byte("false")) {
|
||||
return nil
|
||||
}
|
||||
return errors.New("bad value provided")
|
||||
}
|
||||
s.Value = &tmp
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s BoolInt) MarshalJSON() ([]byte, error) {
|
||||
if s.Value != nil {
|
||||
return strconv.AppendInt([]byte{}, *s.Value, 10), nil
|
||||
}
|
||||
return strconv.AppendBool([]byte{}, s.Flag), nil
|
||||
}
|
||||
|
||||
func NewIntString(i int64) *IntString {
|
||||
return &IntString{
|
||||
Value: i,
|
||||
Valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
// IntString represents special type for json values that could be strings or ints: 100 or "100"
|
||||
type IntString struct {
|
||||
Value int64
|
||||
Valid bool
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements custom unmarshalling for IntString type
|
||||
func (v *IntString) UnmarshalJSON(raw []byte) error {
|
||||
if raw == nil || bytes.Equal(raw, []byte(`"null"`)) || bytes.Equal(raw, []byte(`""`)) {
|
||||
return nil
|
||||
}
|
||||
|
||||
strVal := string(raw)
|
||||
if rune(raw[0]) == '"' {
|
||||
strVal = strings.Trim(strVal, `"`)
|
||||
}
|
||||
|
||||
i, err := strconv.ParseInt(strVal, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
v.Value = i
|
||||
v.Valid = true
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements custom marshalling for IntString type
|
||||
func (v *IntString) MarshalJSON() ([]byte, error) {
|
||||
if v.Valid {
|
||||
strVal := strconv.FormatInt(v.Value, 10)
|
||||
return []byte(strVal), nil
|
||||
}
|
||||
|
||||
return []byte(`"null"`), nil
|
||||
}
|
||||
|
||||
func NewFloatString(i float64) *FloatString {
|
||||
return &FloatString{
|
||||
Value: i,
|
||||
Valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
// FloatString represents special type for json values that could be strings or ints: 100 or "100"
|
||||
type FloatString struct {
|
||||
Value float64
|
||||
Valid bool
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements custom unmarshalling for FloatString type
|
||||
func (v *FloatString) UnmarshalJSON(raw []byte) error {
|
||||
if raw == nil || bytes.Equal(raw, []byte(`"null"`)) || bytes.Equal(raw, []byte(`""`)) {
|
||||
return nil
|
||||
}
|
||||
|
||||
strVal := string(raw)
|
||||
if rune(raw[0]) == '"' {
|
||||
strVal = strings.Trim(strVal, `"`)
|
||||
}
|
||||
|
||||
i, err := strconv.ParseFloat(strVal, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
v.Value = i
|
||||
v.Valid = true
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements custom marshalling for FloatString type
|
||||
func (v *FloatString) MarshalJSON() ([]byte, error) {
|
||||
if v.Valid {
|
||||
strVal := strconv.FormatFloat(v.Value, 'g', -1, 64)
|
||||
return []byte(strVal), nil
|
||||
}
|
||||
|
||||
return []byte(`"null"`), nil
|
||||
}
|
||||
|
||||
// StringSliceString represents special type for json values that could be
|
||||
// strings or slice of strings: "something" or ["something"].
|
||||
type StringSliceString struct {
|
||||
Value []string
|
||||
Valid bool
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements custom unmarshalling for StringSliceString type.
|
||||
func (v *StringSliceString) UnmarshalJSON(raw []byte) error {
|
||||
if raw == nil || bytes.Equal(raw, []byte(`"null"`)) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// First try with string.
|
||||
var str string
|
||||
if err := json.Unmarshal(raw, &str); err == nil {
|
||||
v.Value = []string{str}
|
||||
v.Valid = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// Lastly try with string slice.
|
||||
var strSlice []string
|
||||
err := json.Unmarshal(raw, &strSlice)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
v.Value = strSlice
|
||||
v.Valid = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements custom marshalling for StringSliceString type.
|
||||
func (v *StringSliceString) MarshalJSON() ([]byte, error) {
|
||||
if !v.Valid {
|
||||
return []byte(`"null"`), nil
|
||||
}
|
||||
|
||||
return json.Marshal(v.Value)
|
||||
}
|
||||
54
vendor/github.com/grafana-tools/sdk/datasource.go
generated
vendored
Normal file
54
vendor/github.com/grafana-tools/sdk/datasource.go
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
// Datasource as described in the doc
|
||||
// http://docs.grafana.org/reference/http_api/#get-all-datasources
|
||||
type Datasource struct {
|
||||
ID uint `json:"id"`
|
||||
OrgID uint `json:"orgId"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Access string `json:"access"` // direct or proxy
|
||||
URL string `json:"url"`
|
||||
Password *string `json:"password,omitempty"`
|
||||
User *string `json:"user,omitempty"`
|
||||
Database *string `json:"database,omitempty"`
|
||||
BasicAuth *bool `json:"basicAuth,omitempty"`
|
||||
BasicAuthUser *string `json:"basicAuthUser,omitempty"`
|
||||
BasicAuthPassword *string `json:"basicAuthPassword,omitempty"`
|
||||
IsDefault bool `json:"isDefault"`
|
||||
JSONData interface{} `json:"jsonData"`
|
||||
SecureJSONData interface{} `json:"secureJsonData"`
|
||||
}
|
||||
|
||||
// Datasource type as described in
|
||||
// http://docs.grafana.org/reference/http_api/#available-data-source-types
|
||||
type DatasourceType struct {
|
||||
Metrics bool `json:"metrics"`
|
||||
Module string `json:"module"`
|
||||
Name string `json:"name"`
|
||||
Partials struct {
|
||||
Query string `json:"query"`
|
||||
} `json:"datasource"`
|
||||
PluginType string `json:"pluginType"`
|
||||
ServiceName string `json:"serviceName"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
39
vendor/github.com/grafana-tools/sdk/folder.go
generated
vendored
Normal file
39
vendor/github.com/grafana-tools/sdk/folder.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
// Folder as described in the doc
|
||||
// https://grafana.com/docs/grafana/latest/http_api/folder/#get-all-folders
|
||||
type Folder struct {
|
||||
ID int `json:"id"`
|
||||
UID string `json:"uid"`
|
||||
Title string `json:"title"`
|
||||
URL string `json:"url"`
|
||||
HasAcl bool `json:"hasAcl"`
|
||||
CanSave bool `json:"canSave"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
CanAdmin bool `json:"canAdmin"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
Created string `json:"created"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
Updated string `json:"updated"`
|
||||
Version int `json:"version"`
|
||||
Overwrite bool `json:"overwrite"`
|
||||
}
|
||||
11
vendor/github.com/grafana-tools/sdk/go.mod
generated
vendored
Normal file
11
vendor/github.com/grafana-tools/sdk/go.mod
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
module github.com/grafana-tools/sdk
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/chromedp/cdproto v0.0.0-20210122124816-7a656c010d57
|
||||
github.com/chromedp/chromedp v0.6.5
|
||||
github.com/gosimple/slug v1.1.1
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be // indirect
|
||||
)
|
||||
23
vendor/github.com/grafana-tools/sdk/go.sum
generated
vendored
Normal file
23
vendor/github.com/grafana-tools/sdk/go.sum
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
github.com/chromedp/cdproto v0.0.0-20210122124816-7a656c010d57 h1:htpyTFarq7OHx9SpkQ+7x20thTQA6JAsgnuMGoPbH4E=
|
||||
github.com/chromedp/cdproto v0.0.0-20210122124816-7a656c010d57/go.mod h1:55pim6Ht4LJKdVLlyFJV/g++HsEA1hQxPbB5JyNdZC0=
|
||||
github.com/chromedp/chromedp v0.6.5 h1:hPaDYBpvD2WFicln0ByzV+XRhSOtLgAgsu39O455iWY=
|
||||
github.com/chromedp/chromedp v0.6.5/go.mod h1:/Q6h52DkrFuvOgmCuR6O3xT5g0bZYoPqjANKBEvQGEY=
|
||||
github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic=
|
||||
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
|
||||
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
|
||||
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.0.4 h1:5eXU1CZhpQdq5kXbKb+sECH5Ia5KiO6CYzIzdlVx6Bs=
|
||||
github.com/gobwas/ws v1.0.4/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
|
||||
github.com/gosimple/slug v1.1.1 h1:fRu/digW+NMwBIP+RmviTK97Ho/bEj/C9swrCspN3D4=
|
||||
github.com/gosimple/slug v1.1.1/go.mod h1:ER78kgg1Mv0NQGlXiDe57DpCyfbNywXXZ9mIorhxAf0=
|
||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
|
||||
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
|
||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
|
||||
golang.org/x/sys v0.0.0-20210122093101-04d7465088b8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
33
vendor/github.com/grafana-tools/sdk/org.go
generated
vendored
Normal file
33
vendor/github.com/grafana-tools/sdk/org.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016-2017 Alexander I.Grafov <grafov@gmail.com>
|
||||
|
||||
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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
type Org struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Address Address `json:"address"`
|
||||
}
|
||||
|
||||
type OrgUser struct {
|
||||
ID uint `json:"userId"`
|
||||
OrgId uint `json:"orgId"`
|
||||
Email string `json:"email"`
|
||||
Login string `json:"login"`
|
||||
Role string `json:"role"`
|
||||
}
|
||||
1070
vendor/github.com/grafana-tools/sdk/panel.go
generated
vendored
Normal file
1070
vendor/github.com/grafana-tools/sdk/panel.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
26
vendor/github.com/grafana-tools/sdk/preferences.go
generated
vendored
Normal file
26
vendor/github.com/grafana-tools/sdk/preferences.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
type Preferences struct {
|
||||
Theme string `json:"theme,omitempty"`
|
||||
HomeDashboardId uint `json:"homeDashboardId,omitempty"`
|
||||
Timezone string `json:"timezone,omitempty"`
|
||||
}
|
||||
66
vendor/github.com/grafana-tools/sdk/rest-admin.go
generated
vendored
Normal file
66
vendor/github.com/grafana-tools/sdk/rest-admin.go
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// CreateUser creates a new global user.
|
||||
// Requires basic authentication and that the authenticated user is a Grafana Admin.
|
||||
// Reflects POST /api/admin/users API call.
|
||||
func (r *Client) CreateUser(ctx context.Context, user User) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(user); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.post(ctx, "api/admin/users", nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// UpdateUserPermissions updates the permissions of a global user.
|
||||
// Requires basic authentication and that the authenticated user is a Grafana Admin.
|
||||
// Reflects PUT /api/admin/users/:userId/password API call.
|
||||
func (r *Client) UpdateUserPermissions(ctx context.Context, permissions UserPermissions, uid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
reply StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(permissions); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.put(ctx, fmt.Sprintf("api/admin/users/%d/permissions", uid), nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
err = json.Unmarshal(raw, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
// SwitchUserContext switches user context to the given organization.
|
||||
// Requires basic authentication and that the authenticated user is a Grafana Admin.
|
||||
// Reflects POST /api/users/:userId/using/:organizationId API call.
|
||||
func (r *Client) SwitchUserContext(ctx context.Context, uid uint, oid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
|
||||
if raw, _, err = r.post(ctx, fmt.Sprintf("/api/users/%d/using/%d", uid, oid), nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
178
vendor/github.com/grafana-tools/sdk/rest-alertnotification.go
generated
vendored
Normal file
178
vendor/github.com/grafana-tools/sdk/rest-alertnotification.go
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016-2020 The Grafana SDK 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.
|
||||
*/
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// GetAllAlertNotifications gets all alert notification channels.
|
||||
// Reflects GET /api/alert-notifications API call.
|
||||
func (c *Client) GetAllAlertNotifications(ctx context.Context) ([]AlertNotification, error) {
|
||||
var (
|
||||
raw []byte
|
||||
an []AlertNotification
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = c.get(ctx, "api/alert-notifications", nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if code != 200 {
|
||||
return nil, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &an)
|
||||
return an, err
|
||||
}
|
||||
|
||||
// GetAlertNotificationUID gets the alert notification channel which has the specified uid.
|
||||
// Reflects GET /api/alert-notifications/uid/:uid API call.
|
||||
func (c *Client) GetAlertNotificationUID(ctx context.Context, uid string) (AlertNotification, error) {
|
||||
var (
|
||||
raw []byte
|
||||
an AlertNotification
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = c.get(ctx, fmt.Sprintf("api/alert-notifications/uid/%s", uid), nil); err != nil {
|
||||
return an, err
|
||||
}
|
||||
if code != 200 {
|
||||
return an, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &an)
|
||||
return an, err
|
||||
}
|
||||
|
||||
// GetAlertNotificationID gets the alert notification channel which has the specified id.
|
||||
// Reflects GET /api/alert-notifications/:id API call.
|
||||
func (c *Client) GetAlertNotificationID(ctx context.Context, id uint) (AlertNotification, error) {
|
||||
var (
|
||||
raw []byte
|
||||
an AlertNotification
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = c.get(ctx, fmt.Sprintf("api/alert-notifications/%d", id), nil); err != nil {
|
||||
return an, err
|
||||
}
|
||||
if code != 200 {
|
||||
return an, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &an)
|
||||
return an, err
|
||||
}
|
||||
|
||||
// CreateAlertNotification creates a new alert notification channel.
|
||||
// Reflects POST /api/alert-notifications API call.
|
||||
func (c *Client) CreateAlertNotification(ctx context.Context, an AlertNotification) (int64, error) {
|
||||
var (
|
||||
raw []byte
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(an); err != nil {
|
||||
return -1, err
|
||||
}
|
||||
if raw, code, err = c.post(ctx, "api/alert-notifications", nil, raw); err != nil {
|
||||
return -1, err
|
||||
}
|
||||
if code != 200 {
|
||||
return -1, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
result := struct {
|
||||
ID int64 `json:"id"`
|
||||
}{}
|
||||
err = json.Unmarshal(raw, &result)
|
||||
return result.ID, err
|
||||
}
|
||||
|
||||
// UpdateAlertNotificationUID updates the specified alert notification channel.
|
||||
// Reflects PUT /api/alert-notifications/uid/:uid API call.
|
||||
func (c *Client) UpdateAlertNotificationUID(ctx context.Context, an AlertNotification, uid string) error {
|
||||
var (
|
||||
raw []byte
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(an); err != nil {
|
||||
return err
|
||||
}
|
||||
if raw, code, err = c.put(ctx, fmt.Sprintf("api/alert-notifications/uid/%s", uid), nil, raw); err != nil {
|
||||
return err
|
||||
}
|
||||
if code != 200 {
|
||||
return fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateAlertNotificationID updates the specified alert notification channel.
|
||||
// Reflects PUT /api/alert-notifications/:id API call.
|
||||
func (c *Client) UpdateAlertNotificationID(ctx context.Context, an AlertNotification, id uint) error {
|
||||
var (
|
||||
raw []byte
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(an); err != nil {
|
||||
return err
|
||||
}
|
||||
if raw, code, err = c.put(ctx, fmt.Sprintf("api/alert-notifications/%d", id), nil, raw); err != nil {
|
||||
return err
|
||||
}
|
||||
if code != 200 {
|
||||
return fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteAlertNotificationUID deletes the specified alert notification channel.
|
||||
// Reflects DELETE /api/alert-notifications/uid/:uid API call.
|
||||
func (c *Client) DeleteAlertNotificationUID(ctx context.Context, uid string) error {
|
||||
var (
|
||||
raw []byte
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = c.delete(ctx, fmt.Sprintf("api/alert-notifications/uid/%s", uid)); err != nil {
|
||||
return err
|
||||
}
|
||||
if code != 200 {
|
||||
return fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteAlertNotificationID deletes the specified alert notification channel.
|
||||
// Reflects DELETE /api/alert-notifications/:id API call.
|
||||
func (c *Client) DeleteAlertNotificationID(ctx context.Context, id uint) error {
|
||||
var (
|
||||
raw []byte
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = c.delete(ctx, fmt.Sprintf("api/alert-notifications/%d", id)); err != nil {
|
||||
return err
|
||||
}
|
||||
if code != 200 {
|
||||
return fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
162
vendor/github.com/grafana-tools/sdk/rest-annotation.go
generated
vendored
Normal file
162
vendor/github.com/grafana-tools/sdk/rest-annotation.go
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// https://grafana.com/docs/grafana/latest/http_api/annotations/
|
||||
|
||||
// CreateAnnotation creates a new annotation from the annotation request
|
||||
func (r *Client) CreateAnnotation(ctx context.Context, a CreateAnnotationRequest) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(a); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "marshal request")
|
||||
}
|
||||
if raw, _, err = r.post(ctx, "api/annotations", nil, raw); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "create annotation")
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "unmarshal response message")
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// PatchAnnotation patches the annotation with id with the request
|
||||
func (r *Client) PatchAnnotation(ctx context.Context, id uint, a PatchAnnotationRequest) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(a); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "marshal request")
|
||||
}
|
||||
if raw, _, err = r.patch(ctx, fmt.Sprintf("api/annotations/%d", id), nil, raw); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "patch annotation")
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "unmarshal response message")
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetAnnotations gets annotations matching the annotation parameters
|
||||
func (r *Client) GetAnnotations(ctx context.Context, params ...GetAnnotationsParams) ([]AnnotationResponse, error) {
|
||||
var (
|
||||
raw []byte
|
||||
err error
|
||||
resp []AnnotationResponse
|
||||
requestParams = make(url.Values)
|
||||
)
|
||||
|
||||
for _, p := range params {
|
||||
p(requestParams)
|
||||
}
|
||||
|
||||
if raw, _, err = r.get(ctx, "api/annotations", requestParams); err != nil {
|
||||
return nil, errors.Wrap(err, "get annotations")
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return nil, errors.Wrap(err, "unmarshal response message")
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// DeleteAnnotation deletes the annotation with id
|
||||
func (r *Client) DeleteAnnotation(ctx context.Context, id uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
err error
|
||||
resp StatusMessage
|
||||
)
|
||||
|
||||
if raw, _, err = r.delete(ctx, fmt.Sprintf("api/annotations/%d", id)); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "delete annotation")
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "unmarshal response message")
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetAnnotationsParams is the type for all options implementing query parameters
|
||||
// https://grafana.com/docs/grafana/latest/http_api/annotations/#find-annotations
|
||||
type GetAnnotationsParams func(values url.Values)
|
||||
|
||||
// WithTag adds the tag to the
|
||||
func WithTag(tag string) GetAnnotationsParams {
|
||||
return func(v url.Values) {
|
||||
v.Add("tags", tag)
|
||||
}
|
||||
}
|
||||
|
||||
// WithLimit sets the max number of alerts to return
|
||||
func WithLimit(limit uint) GetAnnotationsParams {
|
||||
return func(v url.Values) {
|
||||
v.Set("limit", strconv.FormatUint(uint64(limit), 10))
|
||||
}
|
||||
}
|
||||
|
||||
// WithAnnotationType filters the type to annotations
|
||||
func WithAnnotationType() GetAnnotationsParams {
|
||||
return func(v url.Values) {
|
||||
v.Set("type", "annotation")
|
||||
}
|
||||
}
|
||||
|
||||
// WithAlertType filters the type to alerts
|
||||
func WithAlertType() GetAnnotationsParams {
|
||||
return func(v url.Values) {
|
||||
v.Set("type", "alert")
|
||||
}
|
||||
}
|
||||
|
||||
// WithDashboard filters the response to the specified dashboard ID
|
||||
func WithDashboard(id uint) GetAnnotationsParams {
|
||||
return func(v url.Values) {
|
||||
v.Set("dashboardId", strconv.FormatUint(uint64(id), 10))
|
||||
}
|
||||
}
|
||||
|
||||
// WithPanel filters the response to the specified panel ID
|
||||
func WithPanel(id uint) GetAnnotationsParams {
|
||||
return func(v url.Values) {
|
||||
v.Set("panelId", strconv.FormatUint(uint64(id), 10))
|
||||
}
|
||||
}
|
||||
|
||||
// WithUser filters the annotations to only be made by the specified user ID
|
||||
func WithUser(id uint) GetAnnotationsParams {
|
||||
return func(v url.Values) {
|
||||
v.Set("userId", strconv.FormatUint(uint64(id), 10))
|
||||
}
|
||||
}
|
||||
|
||||
// WithStartTime filters the annotations to after the specified time
|
||||
func WithStartTime(t time.Time) GetAnnotationsParams {
|
||||
return func(v url.Values) {
|
||||
v.Set("from", strconv.FormatInt(toMilliseconds(t), 10))
|
||||
}
|
||||
}
|
||||
|
||||
// WithEndTime filters the annotations to before the specified time
|
||||
func WithEndTime(t time.Time) GetAnnotationsParams {
|
||||
return func(v url.Values) {
|
||||
v.Set("to", strconv.FormatInt(toMilliseconds(t), 10))
|
||||
}
|
||||
}
|
||||
|
||||
func toMilliseconds(t time.Time) int64 {
|
||||
return t.UnixNano() / 1000000
|
||||
}
|
||||
456
vendor/github.com/grafana-tools/sdk/rest-dashboard.go
generated
vendored
Normal file
456
vendor/github.com/grafana-tools/sdk/rest-dashboard.go
generated
vendored
Normal file
@@ -0,0 +1,456 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// DefaultFolderId is the id of the general folder
|
||||
// that is pre-created and cannot be removed.
|
||||
const DefaultFolderId = 0
|
||||
|
||||
// BoardProperties keeps metadata of a dashboard.
|
||||
type BoardProperties struct {
|
||||
IsStarred bool `json:"isStarred,omitempty"`
|
||||
IsHome bool `json:"isHome,omitempty"`
|
||||
IsSnapshot bool `json:"isSnapshot,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
CanSave bool `json:"canSave"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
CanStar bool `json:"canStar"`
|
||||
Slug string `json:"slug"`
|
||||
Expires time.Time `json:"expires"`
|
||||
Created time.Time `json:"created"`
|
||||
Updated time.Time `json:"updated"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
Version int `json:"version"`
|
||||
FolderID int `json:"folderId"`
|
||||
FolderTitle string `json:"folderTitle"`
|
||||
FolderURL string `json:"folderUrl"`
|
||||
}
|
||||
|
||||
// GetDashboardByUID loads a dashboard and its metadata from Grafana by dashboard uid.
|
||||
//
|
||||
// Reflects GET /api/dashboards/uid/:uid API call.
|
||||
func (r *Client) GetDashboardByUID(ctx context.Context, uid string) (Board, BoardProperties, error) {
|
||||
return r.getDashboard(ctx, "uid/"+uid)
|
||||
}
|
||||
|
||||
// GetDashboardBySlug loads a dashboard and its metadata from Grafana by dashboard slug.
|
||||
//
|
||||
// For dashboards from a filesystem set "file/" prefix for slug. By default dashboards from
|
||||
// a database assumed. Database dashboards may have "db/" prefix or may have not, it will
|
||||
// be appended automatically.
|
||||
//
|
||||
// Reflects GET /api/dashboards/db/:slug API call.
|
||||
// Deprecated: since Grafana v5 you should use uids. Use GetDashboardByUID() for that.
|
||||
func (r *Client) GetDashboardBySlug(ctx context.Context, slug string) (Board, BoardProperties, error) {
|
||||
path := setPrefix(slug)
|
||||
return r.getDashboard(ctx, path)
|
||||
}
|
||||
|
||||
// getDashboard loads a dashboard from Grafana instance along with metadata for a dashboard.
|
||||
// For dashboards from a filesystem set "file/" prefix for slug. By default dashboards from
|
||||
// a database assumed. Database dashboards may have "db/" prefix or may have not, it will
|
||||
// be appended automatically.
|
||||
//
|
||||
// Reflects GET /api/dashboards/db/:slug API call.
|
||||
func (r *Client) getDashboard(ctx context.Context, path string) (Board, BoardProperties, error) {
|
||||
raw, bp, err := r.getRawDashboard(ctx, path)
|
||||
if err != nil {
|
||||
return Board{}, BoardProperties{}, errors.Wrap(err, "get raw dashboard")
|
||||
}
|
||||
var (
|
||||
result struct {
|
||||
Meta BoardProperties `json:"meta"`
|
||||
Board Board `json:"dashboard"`
|
||||
}
|
||||
)
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&result.Board); err != nil {
|
||||
return Board{}, BoardProperties{}, errors.Wrap(err, "unmarshal board")
|
||||
}
|
||||
return result.Board, bp, err
|
||||
}
|
||||
|
||||
// GetRawDashboard loads a dashboard JSON from Grafana instance along with metadata for a dashboard.
|
||||
// Contrary to GetDashboard() it not unpack loaded JSON to Board structure. Instead it
|
||||
// returns it as byte slice. It guarantee that data of dashboard returned untouched by conversion
|
||||
// with Board so no matter how properly fields from a current version of Grafana mapped to
|
||||
// our Board fields. It useful for backuping purposes when you want a dashboard exactly with
|
||||
// same data as it exported by Grafana.
|
||||
//
|
||||
// For dashboards from a filesystem set "file/" prefix for slug. By default dashboards from
|
||||
// a database assumed. Database dashboards may have "db/" prefix or may have not, it will
|
||||
// be appended automatically.
|
||||
//
|
||||
// Reflects GET /api/dashboards/db/:slug API call.
|
||||
// Deprecated: since Grafana v5 you should use uids. Use GetRawDashboardByUID() for that.
|
||||
func (r *Client) getRawDashboard(ctx context.Context, path string) ([]byte, BoardProperties, error) {
|
||||
var (
|
||||
raw []byte
|
||||
result struct {
|
||||
Meta BoardProperties `json:"meta"`
|
||||
Board json.RawMessage `json:"dashboard"`
|
||||
}
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, fmt.Sprintf("api/dashboards/%s", path), nil); err != nil {
|
||||
return nil, BoardProperties{}, err
|
||||
}
|
||||
if code != 200 {
|
||||
return nil, BoardProperties{}, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&result); err != nil {
|
||||
return nil, BoardProperties{}, errors.Wrap(err, "unmarshal board")
|
||||
}
|
||||
return []byte(result.Board), result.Meta, err
|
||||
}
|
||||
|
||||
// GetRawDashboardByUID loads a dashboard and its metadata from Grafana by dashboard uid.
|
||||
//
|
||||
// Reflects GET /api/dashboards/uid/:uid API call.
|
||||
func (r *Client) GetRawDashboardByUID(ctx context.Context, uid string) ([]byte, BoardProperties, error) {
|
||||
return r.getRawDashboard(ctx, "uid/"+uid)
|
||||
}
|
||||
|
||||
// GetRawDashboardBySlug loads a dashboard and its metadata from Grafana by dashboard slug.
|
||||
//
|
||||
// For dashboards from a filesystem set "file/" prefix for slug. By default dashboards from
|
||||
// a database assumed. Database dashboards may have "db/" prefix or may have not, it will
|
||||
// be appended automatically.
|
||||
//
|
||||
// Reflects GET /api/dashboards/db/:slug API call.
|
||||
// Deprecated: since Grafana v5 you should use uids. Use GetRawDashboardByUID() for that.
|
||||
func (r *Client) GetRawDashboardBySlug(ctx context.Context, slug string) ([]byte, BoardProperties, error) {
|
||||
path := setPrefix(slug)
|
||||
return r.getRawDashboard(ctx, path)
|
||||
}
|
||||
|
||||
// FoundBoard keeps result of search with metadata of a dashboard.
|
||||
type FoundBoard struct {
|
||||
ID uint `json:"id"`
|
||||
UID string `json:"uid"`
|
||||
Title string `json:"title"`
|
||||
URI string `json:"uri"`
|
||||
URL string `json:"url"`
|
||||
Slug string `json:"slug"`
|
||||
Type string `json:"type"`
|
||||
Tags []string `json:"tags"`
|
||||
IsStarred bool `json:"isStarred"`
|
||||
FolderID int `json:"folderId"`
|
||||
FolderUID string `json:"folderUid"`
|
||||
FolderTitle string `json:"folderTitle"`
|
||||
FolderURL string `json:"folderUrl"`
|
||||
}
|
||||
|
||||
// SearchDashboards search dashboards by substring of their title. It allows restrict the result set with
|
||||
// only starred dashboards and only for tags (logical OR applied to multiple tags).
|
||||
//
|
||||
// Reflects GET /api/search API call.
|
||||
// Deprecated: This interface does not allow for API extension and is out of date.
|
||||
// Please use Search(SearchType(SearchTypeDashboard))
|
||||
func (r *Client) SearchDashboards(ctx context.Context, query string, starred bool, tags ...string) ([]FoundBoard, error) {
|
||||
params := []SearchParam{
|
||||
SearchType(SearchTypeDashboard),
|
||||
SearchQuery(query),
|
||||
SearchStarred(starred),
|
||||
}
|
||||
for _, tag := range tags {
|
||||
params = append(params, SearchTag(tag))
|
||||
}
|
||||
return r.Search(ctx, params...)
|
||||
}
|
||||
|
||||
// Search searches folders and dashboards with query params specified.
|
||||
//
|
||||
// Reflects GET /api/search API call.
|
||||
func (r *Client) Search(ctx context.Context, params ...SearchParam) ([]FoundBoard, error) {
|
||||
var (
|
||||
raw []byte
|
||||
boards []FoundBoard
|
||||
code int
|
||||
err error
|
||||
)
|
||||
u := url.URL{}
|
||||
q := u.Query()
|
||||
for _, p := range params {
|
||||
p(&q)
|
||||
}
|
||||
if raw, code, err = r.get(ctx, "api/search", q); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if code != 200 {
|
||||
return nil, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &boards)
|
||||
return boards, err
|
||||
}
|
||||
|
||||
// SetDashboardParams contains the extra parameteres
|
||||
// that affects where and how the dashboard will be stored
|
||||
type SetDashboardParams struct {
|
||||
FolderID int
|
||||
Overwrite bool
|
||||
}
|
||||
|
||||
// SetDashboard updates existing dashboard or creates a new one.
|
||||
// Set dasboard ID to nil to create a new dashboard.
|
||||
// Set overwrite to true if you want to overwrite existing dashboard with
|
||||
// newer version or with same dashboard title.
|
||||
// Grafana only can create or update a dashboard in a database. File dashboards
|
||||
// may be only loaded with HTTP API but not created or updated.
|
||||
//
|
||||
// Reflects POST /api/dashboards/db API call.
|
||||
func (r *Client) SetDashboard(ctx context.Context, board Board, params SetDashboardParams) (StatusMessage, error) {
|
||||
var (
|
||||
isBoardFromDB bool
|
||||
newBoard struct {
|
||||
Dashboard Board `json:"dashboard"`
|
||||
FolderID int `json:"folderId"`
|
||||
Overwrite bool `json:"overwrite"`
|
||||
}
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if board.Slug, isBoardFromDB = cleanPrefix(board.Slug); !isBoardFromDB {
|
||||
return StatusMessage{}, errors.New("only database dashboard (with 'db/' prefix in a slug) can be set")
|
||||
}
|
||||
newBoard.Dashboard = board
|
||||
newBoard.FolderID = params.FolderID
|
||||
newBoard.Overwrite = params.Overwrite
|
||||
if !params.Overwrite {
|
||||
newBoard.Dashboard.ID = 0
|
||||
}
|
||||
if raw, err = json.Marshal(newBoard); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, code, err = r.post(ctx, "api/dashboards/db", nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if code != 200 {
|
||||
return resp, fmt.Errorf("HTTP error %d: returns %s", code, *resp.Message)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// SetRawDashboard updates existing dashboard or creates a new one.
|
||||
// Contrary to SetDashboard() it accepts raw JSON instead of Board structure.
|
||||
// Grafana only can create or update a dashboard in a database. File dashboards
|
||||
// may be only loaded with HTTP API but not created or updated.
|
||||
//
|
||||
// Reflects POST /api/dashboards/db API call.
|
||||
func (r *Client) SetRawDashboard(ctx context.Context, raw []byte) (StatusMessage, error) {
|
||||
var (
|
||||
rawResp []byte
|
||||
resp StatusMessage
|
||||
code int
|
||||
err error
|
||||
buf bytes.Buffer
|
||||
plain = make(map[string]interface{})
|
||||
)
|
||||
if err = json.Unmarshal(raw, &plain); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
// TODO(axel) fragile place, refactor it
|
||||
plain["id"] = 0
|
||||
raw, _ = json.Marshal(plain)
|
||||
buf.WriteString(`{"dashboard":`)
|
||||
buf.Write(raw)
|
||||
buf.WriteString(`, "overwrite": true}`)
|
||||
if rawResp, code, err = r.post(ctx, "api/dashboards/db", nil, buf.Bytes()); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(rawResp, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if code != 200 {
|
||||
return StatusMessage{}, fmt.Errorf("HTTP error %d: returns %s", code, *resp.Message)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// DeleteDashboard deletes dashboard that selected by slug string.
|
||||
// Grafana only can delete a dashboard in a database. File dashboards
|
||||
// may be only loaded with HTTP API but not deteled.
|
||||
//
|
||||
// Reflects DELETE /api/dashboards/db/:slug API call.
|
||||
func (r *Client) DeleteDashboard(ctx context.Context, slug string) (StatusMessage, error) {
|
||||
var (
|
||||
isBoardFromDB bool
|
||||
raw []byte
|
||||
reply StatusMessage
|
||||
err error
|
||||
)
|
||||
if slug, isBoardFromDB = cleanPrefix(slug); !isBoardFromDB {
|
||||
return StatusMessage{}, errors.New("only database dashboards (with 'db/' prefix in a slug) can be removed")
|
||||
}
|
||||
if raw, _, err = r.delete(ctx, fmt.Sprintf("api/dashboards/db/%s", slug)); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
err = json.Unmarshal(raw, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
// DeleteDashboard deletes dashboard by UID
|
||||
// Reflects DELETE /api/dashboards/uid/:uid API call.
|
||||
func (r *Client) DeleteDashboardByUID(ctx context.Context, uid string) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
reply StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, _, err = r.delete(ctx, fmt.Sprintf("api/dashboards/uid/%s", uid)); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
err = json.Unmarshal(raw, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
type (
|
||||
// SearchParam is a type for specifying Search params.
|
||||
SearchParam func(*url.Values)
|
||||
// SearchParamType is a type accepted by SearchType func.
|
||||
SearchParamType string
|
||||
)
|
||||
|
||||
// Search entities to be used with SearchType().
|
||||
const (
|
||||
SearchTypeFolder SearchParamType = "dash-folder"
|
||||
SearchTypeDashboard SearchParamType = "dash-db"
|
||||
)
|
||||
|
||||
// SearchQuery specifies Search search query.
|
||||
// Empty query is silently ignored.
|
||||
// Specifying it multiple times is futile, only last one will be sent.
|
||||
func SearchQuery(query string) SearchParam {
|
||||
return func(v *url.Values) {
|
||||
if query != "" {
|
||||
v.Set("query", query)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SearchTag specifies Search tag to search for.
|
||||
// Empty tag is silently ignored.
|
||||
// Can be specified multiple times, logical OR is applied.
|
||||
func SearchTag(tag string) SearchParam {
|
||||
return func(v *url.Values) {
|
||||
if tag != "" {
|
||||
v.Add("tag", tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SearchType specifies Search type to search for.
|
||||
// Specifying it multiple times is futile, only last one will be sent.
|
||||
func SearchType(searchType SearchParamType) SearchParam {
|
||||
return func(v *url.Values) {
|
||||
v.Set("type", string(searchType))
|
||||
}
|
||||
}
|
||||
|
||||
// SearchDashboardID specifies Search dashboard id's to search for.
|
||||
// Can be specified multiple times, logical OR is applied.
|
||||
func SearchDashboardID(dashboardID int) SearchParam {
|
||||
return func(v *url.Values) {
|
||||
v.Add("dashboardIds", strconv.Itoa(dashboardID))
|
||||
}
|
||||
}
|
||||
|
||||
// SearchFolderID specifies Search folder id's to search for.
|
||||
// Can be specified multiple times, logical OR is applied.
|
||||
func SearchFolderID(folderID int) SearchParam {
|
||||
return func(v *url.Values) {
|
||||
v.Add("folderIds", strconv.Itoa(folderID))
|
||||
}
|
||||
}
|
||||
|
||||
// SearchStarred specifies if Search should search for starred dashboards only.
|
||||
// Specifying it multiple times is futile, only last one will be sent.
|
||||
func SearchStarred(starred bool) SearchParam {
|
||||
return func(v *url.Values) {
|
||||
v.Set("starred", strconv.FormatBool(starred))
|
||||
}
|
||||
}
|
||||
|
||||
// SearchLimit specifies maximum number of results from Search query.
|
||||
// As of grafana 6.7 it has to be <= 5000. 0 stands for absence of parameter in a query.
|
||||
// Specifying it multiple times is futile, only last one will be sent.
|
||||
func SearchLimit(limit uint) SearchParam {
|
||||
return func(v *url.Values) {
|
||||
if limit > 0 {
|
||||
v.Set("limit", strconv.FormatUint(uint64(limit), 10))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SearchPage specifies Search page number to be queried for.
|
||||
// Zero page is silently ignored, page numbers start from one.
|
||||
// Specifying it multiple times is futile, only last one will be sent.
|
||||
func SearchPage(page uint) SearchParam {
|
||||
return func(v *url.Values) {
|
||||
if page > 0 {
|
||||
v.Set("page", strconv.FormatUint(uint64(page), 10))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// implicitly use dashboards from Grafana DB not from a file system
|
||||
func setPrefix(slug string) string {
|
||||
if strings.HasPrefix(slug, "db") {
|
||||
return slug
|
||||
}
|
||||
if strings.HasPrefix(slug, "file/") {
|
||||
return slug
|
||||
}
|
||||
return fmt.Sprintf("db/%s", slug)
|
||||
}
|
||||
|
||||
// assume we use database dashboard by default
|
||||
func cleanPrefix(slug string) (string, bool) {
|
||||
if strings.HasPrefix(slug, "db") {
|
||||
return slug[3:], true
|
||||
}
|
||||
if strings.HasPrefix(slug, "file") {
|
||||
return slug[3:], false
|
||||
}
|
||||
return slug, true
|
||||
}
|
||||
172
vendor/github.com/grafana-tools/sdk/rest-datasource.go
generated
vendored
Normal file
172
vendor/github.com/grafana-tools/sdk/rest-datasource.go
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// GetAllDatasources gets all datasources.
|
||||
// Reflects GET /api/datasources API call.
|
||||
func (r *Client) GetAllDatasources(ctx context.Context) ([]Datasource, error) {
|
||||
var (
|
||||
raw []byte
|
||||
ds []Datasource
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, "api/datasources", nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if code != 200 {
|
||||
return nil, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &ds)
|
||||
return ds, err
|
||||
}
|
||||
|
||||
// GetDatasource gets an datasource by ID.
|
||||
// Reflects GET /api/datasources/:datasourceId API call.
|
||||
func (r *Client) GetDatasource(ctx context.Context, id uint) (Datasource, error) {
|
||||
var (
|
||||
raw []byte
|
||||
ds Datasource
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, fmt.Sprintf("api/datasources/%d", id), nil); err != nil {
|
||||
return ds, err
|
||||
}
|
||||
if code != 200 {
|
||||
return ds, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &ds)
|
||||
return ds, err
|
||||
}
|
||||
|
||||
// GetDatasourceByName gets an datasource by Name.
|
||||
// Reflects GET /api/datasources/name/:datasourceName API call.
|
||||
func (r *Client) GetDatasourceByName(ctx context.Context, name string) (Datasource, error) {
|
||||
var (
|
||||
raw []byte
|
||||
ds Datasource
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, fmt.Sprintf("api/datasources/name/%s", name), nil); err != nil {
|
||||
return ds, err
|
||||
}
|
||||
if code != 200 {
|
||||
return ds, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &ds)
|
||||
return ds, err
|
||||
}
|
||||
|
||||
// CreateDatasource creates a new datasource.
|
||||
// Reflects POST /api/datasources API call.
|
||||
func (r *Client) CreateDatasource(ctx context.Context, ds Datasource) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(ds); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.post(ctx, "api/datasources", nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// UpdateDatasource updates a datasource from data passed in argument.
|
||||
// Reflects PUT /api/datasources/:datasourceId API call.
|
||||
func (r *Client) UpdateDatasource(ctx context.Context, ds Datasource) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(ds); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.put(ctx, fmt.Sprintf("api/datasources/%d", ds.ID), nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// DeleteDatasource deletes an existing datasource by ID.
|
||||
// Reflects DELETE /api/datasources/:datasourceId API call.
|
||||
func (r *Client) DeleteDatasource(ctx context.Context, id uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
reply StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, _, err = r.delete(ctx, fmt.Sprintf("api/datasources/%d", id)); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
err = json.Unmarshal(raw, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
// DeleteDatasourceByName deletes an existing datasource by Name.
|
||||
// Reflects DELETE /api/datasources/name/:datasourceName API call.
|
||||
func (r *Client) DeleteDatasourceByName(ctx context.Context, name string) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
reply StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, _, err = r.delete(ctx, fmt.Sprintf("api/datasources/name/%s", name)); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
err = json.Unmarshal(raw, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
// GetDatasourceTypes gets all available plugins for the datasources.
|
||||
// Reflects GET /api/datasources/plugins API call.
|
||||
func (r *Client) GetDatasourceTypes(ctx context.Context) (map[string]DatasourceType, error) {
|
||||
var (
|
||||
raw []byte
|
||||
dsTypes = make(map[string]DatasourceType)
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, "api/datasources/plugins", nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if code != 200 {
|
||||
return nil, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &dsTypes)
|
||||
return dsTypes, err
|
||||
}
|
||||
167
vendor/github.com/grafana-tools/sdk/rest-folder.go
generated
vendored
Normal file
167
vendor/github.com/grafana-tools/sdk/rest-folder.go
generated
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// https://grafana.com/docs/grafana/latest/http_api/folder/
|
||||
|
||||
// GetAllFolders gets all folders.
|
||||
// Reflects GET /api/folders API call.
|
||||
func (r *Client) GetAllFolders(ctx context.Context, params ...GetFolderParams) ([]Folder, error) {
|
||||
var (
|
||||
raw []byte
|
||||
fs []Folder
|
||||
code int
|
||||
err error
|
||||
requestParams = make(url.Values)
|
||||
)
|
||||
for _, p := range params {
|
||||
p(requestParams)
|
||||
}
|
||||
if raw, code, err = r.get(ctx, "api/folders", requestParams); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if code != 200 {
|
||||
return nil, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &fs)
|
||||
return fs, err
|
||||
}
|
||||
|
||||
// GetFolderByUID gets folder by uid.
|
||||
// Reflects GET /api/folders/:uid API call.
|
||||
func (r *Client) GetFolderByUID(ctx context.Context, UID string) (Folder, error) {
|
||||
var (
|
||||
raw []byte
|
||||
f Folder
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, fmt.Sprintf("api/folders/%s", UID), nil); err != nil {
|
||||
return f, err
|
||||
}
|
||||
if code != 200 {
|
||||
return f, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &f)
|
||||
return f, err
|
||||
}
|
||||
|
||||
// CreateFolder create folders.
|
||||
// Reflects POST /api/folders API call.
|
||||
func (r *Client) CreateFolder(ctx context.Context, f Folder) (Folder, error) {
|
||||
var (
|
||||
raw []byte
|
||||
rf Folder
|
||||
code int
|
||||
err error
|
||||
)
|
||||
rf = Folder{}
|
||||
if raw, err = json.Marshal(f); err != nil {
|
||||
return rf, err
|
||||
}
|
||||
if raw, code, err = r.post(ctx, "api/folders", nil, raw); err != nil {
|
||||
return rf, err
|
||||
}
|
||||
if code != 200 {
|
||||
return rf, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &rf)
|
||||
return rf, err
|
||||
}
|
||||
|
||||
// UpdateFolderByUID update folder by uid
|
||||
// Reflects PUT /api/folders/:uid API call.
|
||||
func (r *Client) UpdateFolderByUID(ctx context.Context, f Folder) (Folder, error) {
|
||||
var (
|
||||
raw []byte
|
||||
rf Folder
|
||||
code int
|
||||
err error
|
||||
)
|
||||
rf = Folder{}
|
||||
if raw, err = json.Marshal(f); err != nil {
|
||||
return rf, err
|
||||
}
|
||||
if raw, code, err = r.put(ctx, fmt.Sprintf("api/folders/%s", f.UID), nil, raw); err != nil {
|
||||
return rf, err
|
||||
}
|
||||
if code != 200 {
|
||||
return f, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &rf)
|
||||
return rf, err
|
||||
}
|
||||
|
||||
// DeleteFolderByUID deletes an existing folder by uid.
|
||||
// Reflects DELETE /api/folders/:uid API call.
|
||||
func (r *Client) DeleteFolderByUID(ctx context.Context, UID string) (bool, error) {
|
||||
var (
|
||||
raw []byte
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.delete(ctx, fmt.Sprintf("api/folders/%s", UID)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if code != 200 {
|
||||
return false, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
return true, err
|
||||
}
|
||||
|
||||
// GetFolderByID gets folder by id.
|
||||
// Reflects GET /api/folders/id/:id API call.
|
||||
func (r *Client) GetFolderByID(ctx context.Context, ID int) (Folder, error) {
|
||||
var (
|
||||
raw []byte
|
||||
f Folder
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if ID <= 0 {
|
||||
return f, fmt.Errorf("ID cannot be less than zero")
|
||||
}
|
||||
if raw, code, err = r.get(ctx, fmt.Sprintf("api/folders/id/%d", ID), nil); err != nil {
|
||||
return f, err
|
||||
}
|
||||
if code != 200 {
|
||||
return f, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
err = json.Unmarshal(raw, &f)
|
||||
return f, err
|
||||
}
|
||||
|
||||
// GetFolderParams is the type for all options implementing query parameters
|
||||
type GetFolderParams func(values url.Values)
|
||||
|
||||
// Limit sets the max number of folders to return
|
||||
func Limit(limit uint) GetFolderParams {
|
||||
return func(v url.Values) {
|
||||
v.Set("limit", strconv.FormatUint(uint64(limit), 10))
|
||||
}
|
||||
}
|
||||
50
vendor/github.com/grafana-tools/sdk/rest-get_health.go
generated
vendored
Normal file
50
vendor/github.com/grafana-tools/sdk/rest-get_health.go
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// HealthResponse represents the health of grafana server
|
||||
type HealthResponse struct {
|
||||
Commit string `json:"commit"`
|
||||
Database string `json:"database"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// GetHealth retrieves the health of the grafana server
|
||||
// Reflects GET BaseURL API call.
|
||||
func (r *Client) GetHealth(ctx context.Context) (HealthResponse, error) {
|
||||
var (
|
||||
raw []byte
|
||||
err error
|
||||
)
|
||||
if raw, _, err = r.get(ctx, "/api/health", nil); err != nil {
|
||||
return HealthResponse{}, err
|
||||
}
|
||||
|
||||
health := HealthResponse{}
|
||||
if err := json.Unmarshal(raw, &health); err != nil {
|
||||
return HealthResponse{}, err
|
||||
}
|
||||
return health, nil
|
||||
}
|
||||
436
vendor/github.com/grafana-tools/sdk/rest-org.go
generated
vendored
Normal file
436
vendor/github.com/grafana-tools/sdk/rest-org.go
generated
vendored
Normal file
@@ -0,0 +1,436 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// CreateOrg creates a new organization.
|
||||
// It reflects POST /api/orgs API call.
|
||||
func (r *Client) CreateOrg(ctx context.Context, org Org) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(org); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.post(ctx, "api/orgs", nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetAllOrgs returns all organizations.
|
||||
// It reflects GET /api/orgs API call.
|
||||
func (r *Client) GetAllOrgs(ctx context.Context) ([]Org, error) {
|
||||
var (
|
||||
raw []byte
|
||||
orgs []Org
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, "api/orgs", nil); err != nil {
|
||||
return orgs, err
|
||||
}
|
||||
|
||||
if code != http.StatusOK {
|
||||
return orgs, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&orgs); err != nil {
|
||||
return orgs, fmt.Errorf("unmarshal orgs: %s\n%s", err, raw)
|
||||
}
|
||||
return orgs, err
|
||||
}
|
||||
|
||||
// GetActualOrg gets current organization.
|
||||
// It reflects GET /api/org API call.
|
||||
func (r *Client) GetActualOrg(ctx context.Context) (Org, error) {
|
||||
var (
|
||||
raw []byte
|
||||
org Org
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, "api/org", nil); err != nil {
|
||||
return org, err
|
||||
}
|
||||
if code != http.StatusOK {
|
||||
return org, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&org); err != nil {
|
||||
return org, fmt.Errorf("unmarshal org: %s\n%s", err, raw)
|
||||
}
|
||||
return org, err
|
||||
}
|
||||
|
||||
// GetOrgById gets organization by organization Id.
|
||||
// It reflects GET /api/orgs/:orgId API call.
|
||||
func (r *Client) GetOrgById(ctx context.Context, oid uint) (Org, error) {
|
||||
var (
|
||||
raw []byte
|
||||
org Org
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, fmt.Sprintf("api/orgs/%d", oid), nil); err != nil {
|
||||
return org, err
|
||||
}
|
||||
|
||||
if code != http.StatusOK {
|
||||
return org, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&org); err != nil {
|
||||
return org, fmt.Errorf("unmarshal org: %s\n%s", err, raw)
|
||||
}
|
||||
return org, err
|
||||
}
|
||||
|
||||
// GetOrgByOrgName gets organization by organization name.
|
||||
// It reflects GET /api/orgs/name/:orgName API call.
|
||||
func (r *Client) GetOrgByOrgName(ctx context.Context, name string) (Org, error) {
|
||||
var (
|
||||
raw []byte
|
||||
org Org
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, fmt.Sprintf("api/orgs/name/%s", name), nil); err != nil {
|
||||
return org, err
|
||||
}
|
||||
|
||||
if code != http.StatusOK {
|
||||
return org, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&org); err != nil {
|
||||
return org, fmt.Errorf("unmarshal org: %s\n%s", err, raw)
|
||||
}
|
||||
return org, err
|
||||
}
|
||||
|
||||
// UpdateActualOrg updates current organization.
|
||||
// It reflects PUT /api/org API call.
|
||||
func (r *Client) UpdateActualOrg(ctx context.Context, org Org) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(org); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.put(ctx, "api/org", nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// UpdateOrg updates the organization identified by oid.
|
||||
// It reflects PUT /api/orgs/:orgId API call.
|
||||
func (r *Client) UpdateOrg(ctx context.Context, org Org, oid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(org); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.put(ctx, fmt.Sprintf("api/orgs/%d", oid), nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// DeleteOrg deletes the organization identified by the oid.
|
||||
// Reflects DELETE /api/orgs/:orgId API call.
|
||||
func (r *Client) DeleteOrg(ctx context.Context, oid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, _, err = r.delete(ctx, fmt.Sprintf("api/orgs/%d", oid)); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetActualOrgUsers get all users within the actual organisation.
|
||||
// Reflects GET /api/org/users API call.
|
||||
func (r *Client) GetActualOrgUsers(ctx context.Context) ([]OrgUser, error) {
|
||||
var (
|
||||
raw []byte
|
||||
users []OrgUser
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, "api/org/users", nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if code != http.StatusOK {
|
||||
return nil, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&users); err != nil {
|
||||
return nil, fmt.Errorf("unmarshal org: %s\n%s", err, raw)
|
||||
}
|
||||
return users, err
|
||||
}
|
||||
|
||||
// GetOrgUsers gets the users for the organization specified by oid.
|
||||
// Reflects GET /api/orgs/:orgId/users API call.
|
||||
func (r *Client) GetOrgUsers(ctx context.Context, oid uint) ([]OrgUser, error) {
|
||||
var (
|
||||
raw []byte
|
||||
users []OrgUser
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, fmt.Sprintf("api/orgs/%d/users", oid), nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if code != http.StatusOK {
|
||||
return nil, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&users); err != nil {
|
||||
return nil, fmt.Errorf("unmarshal org: %s\n%s", err, raw)
|
||||
}
|
||||
return users, err
|
||||
}
|
||||
|
||||
// AddActualOrgUser adds a global user to the current organization.
|
||||
// Reflects POST /api/org/users API call.
|
||||
func (r *Client) AddActualOrgUser(ctx context.Context, userRole UserRole) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(userRole); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.post(ctx, "api/org/users", nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// UpdateActualOrgUser updates the existing user.
|
||||
// Reflects POST /api/org/users/:userId API call.
|
||||
func (r *Client) UpdateActualOrgUser(ctx context.Context, user UserRole, uid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(user); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.post(ctx, fmt.Sprintf("api/org/users/%d", uid), nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// DeleteActualOrgUser delete user in actual organization.
|
||||
// Reflects DELETE /api/org/users/:userId API call.
|
||||
func (r *Client) DeleteActualOrgUser(ctx context.Context, uid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
reply StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, _, err = r.delete(ctx, fmt.Sprintf("api/org/users/%d", uid)); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
err = json.Unmarshal(raw, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
// AddOrgUser add user to organization with oid.
|
||||
// Reflects POST /api/orgs/:orgId/users API call.
|
||||
func (r *Client) AddOrgUser(ctx context.Context, user UserRole, oid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
reply StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(user); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.post(ctx, fmt.Sprintf("api/orgs/%d/users", oid), nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
err = json.Unmarshal(raw, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
// UpdateOrgUser updates the user specified by uid within the organization specified by oid.
|
||||
// Reflects PATCH /api/orgs/:orgId/users/:userId API call.
|
||||
func (r *Client) UpdateOrgUser(ctx context.Context, user UserRole, oid, uid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
reply StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(user); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.patch(ctx, fmt.Sprintf("api/orgs/%d/users/%d", oid, uid), nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
err = json.Unmarshal(raw, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
// DeleteOrgUser deletes the user specified by uid within the organization specified by oid.
|
||||
// Reflects DELETE /api/orgs/:orgId/users/:userId API call.
|
||||
func (r *Client) DeleteOrgUser(ctx context.Context, oid, uid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
reply StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, _, err = r.delete(ctx, fmt.Sprintf("api/orgs/%d/users/%d", oid, uid)); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
err = json.Unmarshal(raw, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
// UpdateActualOrgPreferences updates preferences of the actual organization.
|
||||
// Reflects PUT /api/org/preferences API call.
|
||||
func (r *Client) UpdateActualOrgPreferences(ctx context.Context, prefs Preferences) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(prefs); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.put(ctx, "api/org/preferences/", nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetActualOrgPreferences gets preferences of the actual organization.
|
||||
// It reflects GET /api/org/preferences API call.
|
||||
func (r *Client) GetActualOrgPreferences(ctx context.Context) (Preferences, error) {
|
||||
var (
|
||||
raw []byte
|
||||
pref Preferences
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, "/api/org/preferences", nil); err != nil {
|
||||
return pref, err
|
||||
}
|
||||
|
||||
if code != http.StatusOK {
|
||||
return pref, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&pref); err != nil {
|
||||
return pref, fmt.Errorf("unmarshal prefs: %s\n%s", err, raw)
|
||||
}
|
||||
return pref, err
|
||||
}
|
||||
|
||||
// UpdateActualOrgAddress updates current organization's address.
|
||||
// It reflects PUT /api/org/address API call.
|
||||
func (r *Client) UpdateActualOrgAddress(ctx context.Context, address Address) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(address); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.put(ctx, "api/org/address", nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// UpdateOrgAddress updates the address of the organization identified by oid.
|
||||
// It reflects PUT /api/orgs/:orgId/address API call.
|
||||
func (r *Client) UpdateOrgAddress(ctx context.Context, address Address, oid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
if raw, err = json.Marshal(address); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if raw, _, err = r.put(ctx, fmt.Sprintf("api/orgs/%d/address", oid), nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
118
vendor/github.com/grafana-tools/sdk/rest-request.go
generated
vendored
Normal file
118
vendor/github.com/grafana-tools/sdk/rest-request.go
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DefaultHTTPClient initialized Grafana with appropriate conditions.
|
||||
// It allows you globally redefine HTTP client.
|
||||
var DefaultHTTPClient = http.DefaultClient
|
||||
|
||||
// Client uses Grafana REST API for interacting with Grafana server.
|
||||
type Client struct {
|
||||
baseURL string
|
||||
key string
|
||||
basicAuth bool
|
||||
client *http.Client
|
||||
}
|
||||
|
||||
// StatusMessage reflects status message as it returned by Grafana REST API.
|
||||
type StatusMessage struct {
|
||||
ID *uint `json:"id"`
|
||||
OrgID *uint `json:"orgId"`
|
||||
Message *string `json:"message"`
|
||||
Slug *string `json:"slug"`
|
||||
Version *int `json:"version"`
|
||||
Status *string `json:"status"`
|
||||
UID *string `json:"uid"`
|
||||
URL *string `json:"url"`
|
||||
}
|
||||
|
||||
// NewClient initializes client for interacting with an instance of Grafana server;
|
||||
// apiKeyOrBasicAuth accepts either 'username:password' basic authentication credentials,
|
||||
// or a Grafana API key
|
||||
func NewClient(apiURL, apiKeyOrBasicAuth string, client *http.Client) *Client {
|
||||
key := ""
|
||||
basicAuth := strings.Contains(apiKeyOrBasicAuth, ":")
|
||||
baseURL, _ := url.Parse(apiURL)
|
||||
if !basicAuth {
|
||||
key = fmt.Sprintf("Bearer %s", apiKeyOrBasicAuth)
|
||||
} else {
|
||||
parts := strings.Split(apiKeyOrBasicAuth, ":")
|
||||
baseURL.User = url.UserPassword(parts[0], parts[1])
|
||||
}
|
||||
return &Client{baseURL: baseURL.String(), basicAuth: basicAuth, key: key, client: client}
|
||||
}
|
||||
|
||||
func (r *Client) get(ctx context.Context, query string, params url.Values) ([]byte, int, error) {
|
||||
return r.doRequest(ctx, "GET", query, params, nil)
|
||||
}
|
||||
|
||||
func (r *Client) patch(ctx context.Context, query string, params url.Values, body []byte) ([]byte, int, error) {
|
||||
return r.doRequest(ctx, "PATCH", query, params, bytes.NewBuffer(body))
|
||||
}
|
||||
|
||||
func (r *Client) put(ctx context.Context, query string, params url.Values, body []byte) ([]byte, int, error) {
|
||||
return r.doRequest(ctx, "PUT", query, params, bytes.NewBuffer(body))
|
||||
}
|
||||
|
||||
func (r *Client) post(ctx context.Context, query string, params url.Values, body []byte) ([]byte, int, error) {
|
||||
return r.doRequest(ctx, "POST", query, params, bytes.NewBuffer(body))
|
||||
}
|
||||
|
||||
func (r *Client) delete(ctx context.Context, query string) ([]byte, int, error) {
|
||||
return r.doRequest(ctx, "DELETE", query, nil, nil)
|
||||
}
|
||||
|
||||
func (r *Client) doRequest(ctx context.Context, method, query string, params url.Values, buf io.Reader) ([]byte, int, error) {
|
||||
u, _ := url.Parse(r.baseURL)
|
||||
u.Path = path.Join(u.Path, query)
|
||||
if params != nil {
|
||||
u.RawQuery = params.Encode()
|
||||
}
|
||||
req, err := http.NewRequest(method, u.String(), buf)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
req = req.WithContext(ctx)
|
||||
if !r.basicAuth {
|
||||
req.Header.Set("Authorization", r.key)
|
||||
}
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("User-Agent", "autograf")
|
||||
resp, err := r.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
return data, resp.StatusCode, err
|
||||
}
|
||||
34
vendor/github.com/grafana-tools/sdk/rest-snapshot.go
generated
vendored
Normal file
34
vendor/github.com/grafana-tools/sdk/rest-snapshot.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// https://grafana.com/docs/grafana/latest/http_api/snapshot/
|
||||
|
||||
// CreateAnnotation creates a new snapshot.
|
||||
func (r *Client) CreateSnapshot(ctx context.Context, a CreateSnapshotRequest) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
code int
|
||||
)
|
||||
if raw, err = json.Marshal(a); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "marshal request")
|
||||
}
|
||||
if raw, code, err = r.post(ctx, "api/snapshots", nil, raw); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "create snapshot")
|
||||
}
|
||||
if code/100 != 2 {
|
||||
return StatusMessage{}, fmt.Errorf("bad response: %d", code)
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, errors.Wrap(err, "unmarshal response message")
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
164
vendor/github.com/grafana-tools/sdk/rest-user.go
generated
vendored
Normal file
164
vendor/github.com/grafana-tools/sdk/rest-user.go
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// GetActualUser gets an actual user.
|
||||
// Reflects GET /api/user API call.
|
||||
func (r *Client) GetActualUser(ctx context.Context) (User, error) {
|
||||
var (
|
||||
raw []byte
|
||||
user User
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, "api/user", nil); err != nil {
|
||||
return user, err
|
||||
}
|
||||
if code != 200 {
|
||||
return user, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&user); err != nil {
|
||||
return user, fmt.Errorf("unmarshal user: %s\n%s", err, raw)
|
||||
}
|
||||
return user, err
|
||||
}
|
||||
|
||||
// GetUser gets an user by ID.
|
||||
// Reflects GET /api/users/:id API call.
|
||||
func (r *Client) GetUser(ctx context.Context, id uint) (User, error) {
|
||||
var (
|
||||
raw []byte
|
||||
user User
|
||||
code int
|
||||
err error
|
||||
)
|
||||
if raw, code, err = r.get(ctx, fmt.Sprintf("api/users/%d", id), nil); err != nil {
|
||||
return user, err
|
||||
}
|
||||
if code != 200 {
|
||||
return user, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&user); err != nil {
|
||||
return user, fmt.Errorf("unmarshal user: %s\n%s", err, raw)
|
||||
}
|
||||
return user, err
|
||||
}
|
||||
|
||||
// GetAllUsers gets all users.
|
||||
// Reflects GET /api/users API call.
|
||||
func (r *Client) GetAllUsers(ctx context.Context) ([]User, error) {
|
||||
var (
|
||||
raw []byte
|
||||
users []User
|
||||
code int
|
||||
err error
|
||||
)
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("perpage", "99999")
|
||||
if raw, code, err = r.get(ctx, "api/users", params); err != nil {
|
||||
return users, err
|
||||
}
|
||||
if code != 200 {
|
||||
return users, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&users); err != nil {
|
||||
return users, fmt.Errorf("unmarshal users: %s\n%s", err, raw)
|
||||
}
|
||||
return users, err
|
||||
}
|
||||
|
||||
// SearchUsersWithPaging search users with paging.
|
||||
// query optional. query value is contained in one of the name, login or email fields. Query values with spaces need to be url encoded e.g. query=Jane%20Doe
|
||||
// perpage optional. default 1000
|
||||
// page optional. default 1
|
||||
// http://docs.grafana.org/http_api/user/#search-users
|
||||
// http://docs.grafana.org/http_api/user/#search-users-with-paging
|
||||
//
|
||||
// Reflects GET /api/users/search API call.
|
||||
func (r *Client) SearchUsersWithPaging(ctx context.Context, query *string, perpage, page *int) (PageUsers, error) {
|
||||
var (
|
||||
raw []byte
|
||||
pageUsers PageUsers
|
||||
code int
|
||||
err error
|
||||
)
|
||||
|
||||
var params url.Values = nil
|
||||
if perpage != nil && page != nil {
|
||||
if params == nil {
|
||||
params = url.Values{}
|
||||
}
|
||||
params["perpage"] = []string{fmt.Sprint(*perpage)}
|
||||
params["page"] = []string{fmt.Sprint(*page)}
|
||||
}
|
||||
|
||||
if query != nil {
|
||||
if params == nil {
|
||||
params = url.Values{}
|
||||
}
|
||||
params["query"] = []string{*query}
|
||||
}
|
||||
|
||||
if raw, code, err = r.get(ctx, "api/users/search", params); err != nil {
|
||||
return pageUsers, err
|
||||
}
|
||||
if code != 200 {
|
||||
return pageUsers, fmt.Errorf("HTTP error %d: returns %s", code, raw)
|
||||
}
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&pageUsers); err != nil {
|
||||
return pageUsers, fmt.Errorf("unmarshal users: %s\n%s", err, raw)
|
||||
}
|
||||
return pageUsers, err
|
||||
}
|
||||
|
||||
// SwitchActualUserContext switches current user context to the given organization.
|
||||
// Reflects POST /api/user/using/:organizationId API call.
|
||||
func (r *Client) SwitchActualUserContext(ctx context.Context, oid uint) (StatusMessage, error) {
|
||||
var (
|
||||
raw []byte
|
||||
resp StatusMessage
|
||||
err error
|
||||
)
|
||||
|
||||
if raw, _, err = r.post(ctx, fmt.Sprintf("/api/user/using/%d", oid), nil, raw); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resp); err != nil {
|
||||
return StatusMessage{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
95
vendor/github.com/grafana-tools/sdk/row.go
generated
vendored
Normal file
95
vendor/github.com/grafana-tools/sdk/row.go
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
// Row represents single row of Grafana dashboard.
|
||||
type Row struct {
|
||||
Title string `json:"title"`
|
||||
ShowTitle bool `json:"showTitle"`
|
||||
Collapse bool `json:"collapse"`
|
||||
Editable bool `json:"editable"`
|
||||
Height Height `json:"height"`
|
||||
Panels []Panel `json:"panels"`
|
||||
Repeat *string `json:"repeat"`
|
||||
}
|
||||
|
||||
var lastPanelID uint
|
||||
|
||||
func (r *Row) Add(panel *Panel) {
|
||||
lastPanelID++
|
||||
panel.ID = lastPanelID
|
||||
r.Panels = append(r.Panels, *panel)
|
||||
}
|
||||
|
||||
func (r *Row) AddDashlist(data *DashlistPanel) {
|
||||
lastPanelID++
|
||||
panel := NewDashlist("")
|
||||
panel.ID = lastPanelID
|
||||
panel.DashlistPanel = data
|
||||
r.Panels = append(r.Panels, *panel)
|
||||
}
|
||||
|
||||
func (r *Row) AddGraph(data *GraphPanel) {
|
||||
lastPanelID++
|
||||
panel := NewGraph("")
|
||||
panel.ID = lastPanelID
|
||||
panel.GraphPanel = data
|
||||
r.Panels = append(r.Panels, *panel)
|
||||
}
|
||||
|
||||
func (r *Row) AddTable(data *TablePanel) {
|
||||
lastPanelID++
|
||||
panel := NewTable("")
|
||||
panel.ID = lastPanelID
|
||||
panel.TablePanel = data
|
||||
r.Panels = append(r.Panels, *panel)
|
||||
}
|
||||
|
||||
func (r *Row) AddText(data *TextPanel) {
|
||||
lastPanelID++
|
||||
panel := NewText("")
|
||||
panel.ID = lastPanelID
|
||||
panel.TextPanel = data
|
||||
r.Panels = append(r.Panels, *panel)
|
||||
}
|
||||
|
||||
func (r *Row) AddStat(data *StatPanel) {
|
||||
lastPanelID++
|
||||
panel := NewStat("")
|
||||
panel.ID = lastPanelID
|
||||
panel.StatPanel = data
|
||||
r.Panels = append(r.Panels, *panel)
|
||||
}
|
||||
|
||||
func (r *Row) AddSinglestat(data *SinglestatPanel) {
|
||||
lastPanelID++
|
||||
panel := NewSinglestat("")
|
||||
panel.ID = lastPanelID
|
||||
panel.SinglestatPanel = data
|
||||
r.Panels = append(r.Panels, *panel)
|
||||
}
|
||||
|
||||
func (r *Row) AddCustom(data *CustomPanel) {
|
||||
lastPanelID++
|
||||
panel := NewCustom("")
|
||||
panel.ID = lastPanelID
|
||||
panel.CustomPanel = data
|
||||
r.Panels = append(r.Panels, *panel)
|
||||
}
|
||||
7
vendor/github.com/grafana-tools/sdk/snapshot.go
generated
vendored
Normal file
7
vendor/github.com/grafana-tools/sdk/snapshot.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package sdk
|
||||
|
||||
// CreateSnapshotRequest is representation of a snapshot request.
|
||||
type CreateSnapshotRequest struct {
|
||||
Expires uint `json:"expires"`
|
||||
Dashboard Board `json:"dashboard"`
|
||||
}
|
||||
51
vendor/github.com/grafana-tools/sdk/user.go
generated
vendored
Normal file
51
vendor/github.com/grafana-tools/sdk/user.go
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
package sdk
|
||||
|
||||
/*
|
||||
Copyright 2016 Alexander I.Grafov <grafov@gmail.com>
|
||||
Copyright 2016-2019 The Grafana SDK 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.
|
||||
|
||||
ॐ तारे तुत्तारे तुरे स्व
|
||||
*/
|
||||
|
||||
type User struct {
|
||||
ID uint `json:"id"`
|
||||
Login string `json:"login"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
OrgID uint `json:"orgId"`
|
||||
Theme string `json:"theme"`
|
||||
Password string `json:"password"`
|
||||
IsDisabled bool `json:"isDisabled"`
|
||||
AuthLabels []string `json:"authLabels"`
|
||||
IsGrafanaAdmin bool `json:"isGrafanaAdmin"`
|
||||
IsExternal bool `json:"isExternal"`
|
||||
IsAdmin bool `json:"isAdmin"` //Different value used for Search Endpoint
|
||||
}
|
||||
|
||||
type UserRole struct {
|
||||
LoginOrEmail string `json:"loginOrEmail"`
|
||||
Role string `json:"role"`
|
||||
}
|
||||
|
||||
type UserPermissions struct {
|
||||
IsGrafanaAdmin bool `json:"isGrafanaAdmin"`
|
||||
}
|
||||
|
||||
type PageUsers struct {
|
||||
TotalCount int `json:"totalCount"`
|
||||
Users []User `json:"users"`
|
||||
Page int `json:"page"`
|
||||
PerPage int `json:"perPage"`
|
||||
}
|
||||
23
vendor/github.com/rainycape/unidecode/.gitignore
generated
vendored
Normal file
23
vendor/github.com/rainycape/unidecode/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
203
vendor/github.com/rainycape/unidecode/LICENSE
generated
vendored
Normal file
203
vendor/github.com/rainycape/unidecode/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
Copyright 2014 Rainy Cape S.L. <hello@rainycape.com>
|
||||
|
||||
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.
|
||||
6
vendor/github.com/rainycape/unidecode/README.md
generated
vendored
Normal file
6
vendor/github.com/rainycape/unidecode/README.md
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
unidecode
|
||||
=========
|
||||
|
||||
Unicode transliterator in Golang - Replaces non-ASCII characters with their ASCII approximations.
|
||||
|
||||
[](https://godoc.org/github.com/rainycape/unidecode)
|
||||
41
vendor/github.com/rainycape/unidecode/decode.go
generated
vendored
Normal file
41
vendor/github.com/rainycape/unidecode/decode.go
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
package unidecode
|
||||
|
||||
import (
|
||||
"compress/zlib"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
transliterations [65536][]rune
|
||||
transCount = rune(len(transliterations))
|
||||
getUint16 = binary.LittleEndian.Uint16
|
||||
)
|
||||
|
||||
func decodeTransliterations() {
|
||||
r, err := zlib.NewReader(strings.NewReader(tableData))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer r.Close()
|
||||
tmp1 := make([]byte, 2)
|
||||
tmp2 := tmp1[:1]
|
||||
for {
|
||||
if _, err := io.ReadAtLeast(r, tmp1, 2); err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
chr := getUint16(tmp1)
|
||||
if _, err := io.ReadAtLeast(r, tmp2, 1); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
b := make([]byte, int(tmp2[0]))
|
||||
if _, err := io.ReadFull(r, b); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
transliterations[int(chr)] = []rune(string(b))
|
||||
}
|
||||
}
|
||||
71
vendor/github.com/rainycape/unidecode/make_table.go
generated
vendored
Normal file
71
vendor/github.com/rainycape/unidecode/make_table.go
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// +build none
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/zlib"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data, err := ioutil.ReadFile("table.txt")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
if strings.HasPrefix(line, "/*") || line == "" {
|
||||
continue
|
||||
}
|
||||
sep := strings.IndexByte(line, ':')
|
||||
if sep == -1 {
|
||||
panic(line)
|
||||
}
|
||||
val, err := strconv.ParseInt(line[:sep], 0, 32)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := strconv.Unquote(line[sep+2:])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if s == "" {
|
||||
continue
|
||||
}
|
||||
if err := binary.Write(&buf, binary.LittleEndian, uint16(val)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := binary.Write(&buf, binary.LittleEndian, uint8(len(s))); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
buf.WriteString(s)
|
||||
}
|
||||
var cbuf bytes.Buffer
|
||||
w, err := zlib.NewWriterLevel(&cbuf, zlib.BestCompression)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, err := w.Write(buf.Bytes()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := w.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
buf.Reset()
|
||||
buf.WriteString("package unidecode\n")
|
||||
buf.WriteString("// AUTOGENERATED - DO NOT EDIT!\n\n")
|
||||
fmt.Fprintf(&buf, "var tableData = %q;\n", cbuf.String())
|
||||
dst, err := format.Source(buf.Bytes())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := ioutil.WriteFile("table.go", dst, 0644); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
5
vendor/github.com/rainycape/unidecode/table.go
generated
vendored
Normal file
5
vendor/github.com/rainycape/unidecode/table.go
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
46731
vendor/github.com/rainycape/unidecode/table.txt
generated
vendored
Normal file
46731
vendor/github.com/rainycape/unidecode/table.txt
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
58
vendor/github.com/rainycape/unidecode/unidecode.go
generated
vendored
Normal file
58
vendor/github.com/rainycape/unidecode/unidecode.go
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
// Package unidecode implements a unicode transliterator
|
||||
// which replaces non-ASCII characters with their ASCII
|
||||
// approximations.
|
||||
package unidecode
|
||||
|
||||
//go:generate go run make_table.go
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
const pooledCapacity = 64
|
||||
|
||||
var (
|
||||
slicePool sync.Pool
|
||||
decodingOnce sync.Once
|
||||
)
|
||||
|
||||
// Unidecode implements a unicode transliterator, which
|
||||
// replaces non-ASCII characters with their ASCII
|
||||
// counterparts.
|
||||
// Given an unicode encoded string, returns
|
||||
// another string with non-ASCII characters replaced
|
||||
// with their closest ASCII counterparts.
|
||||
// e.g. Unicode("áéíóú") => "aeiou"
|
||||
func Unidecode(s string) string {
|
||||
decodingOnce.Do(decodeTransliterations)
|
||||
l := len(s)
|
||||
var r []rune
|
||||
if l > pooledCapacity {
|
||||
r = make([]rune, 0, len(s))
|
||||
} else {
|
||||
if x := slicePool.Get(); x != nil {
|
||||
r = x.([]rune)[:0]
|
||||
} else {
|
||||
r = make([]rune, 0, pooledCapacity)
|
||||
}
|
||||
}
|
||||
for _, c := range s {
|
||||
if c <= unicode.MaxASCII {
|
||||
r = append(r, c)
|
||||
continue
|
||||
}
|
||||
if c > unicode.MaxRune || c > transCount {
|
||||
/* Ignore reserved chars */
|
||||
continue
|
||||
}
|
||||
if d := transliterations[c]; d != nil {
|
||||
r = append(r, d...)
|
||||
}
|
||||
}
|
||||
res := string(r)
|
||||
if l <= pooledCapacity {
|
||||
slicePool.Put(r)
|
||||
}
|
||||
return res
|
||||
}
|
||||
1
vendor/kubesphere.io/api
generated
vendored
1
vendor/kubesphere.io/api
generated
vendored
@@ -1 +0,0 @@
|
||||
../../staging/src/kubesphere.io/api
|
||||
201
vendor/kubesphere.io/api/LICENSE
generated
vendored
Normal file
201
vendor/kubesphere.io/api/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
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.
|
||||
29
vendor/kubesphere.io/api/application/crdinstall/install.go
generated
vendored
Normal file
29
vendor/kubesphere.io/api/application/crdinstall/install.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Copyright 2020 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 crdinstall
|
||||
|
||||
import (
|
||||
k8sruntime "k8s.io/apimachinery/pkg/runtime"
|
||||
urlruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
|
||||
"kubesphere.io/api/application/v1alpha1"
|
||||
)
|
||||
|
||||
func Install(scheme *k8sruntime.Scheme) {
|
||||
urlruntime.Must(v1alpha1.AddToScheme(scheme))
|
||||
urlruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
|
||||
}
|
||||
63
vendor/kubesphere.io/api/application/v1alpha1/constants.go
generated
vendored
Normal file
63
vendor/kubesphere.io/api/application/v1alpha1/constants.go
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright 2020 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
|
||||
|
||||
const (
|
||||
MsgLen = 512
|
||||
HelmRepoSyncStateLen = 10
|
||||
|
||||
// app version state
|
||||
StateDraft = "draft"
|
||||
StateSubmitted = "submitted"
|
||||
StatePassed = "passed"
|
||||
StateRejected = "rejected"
|
||||
StateSuspended = "suspended"
|
||||
StateActive = "active"
|
||||
|
||||
// repo state
|
||||
RepoStateSuccessful = "successful"
|
||||
RepoStateFailed = "failed"
|
||||
RepoStateSyncing = "syncing"
|
||||
|
||||
// helm release state
|
||||
HelmStatusActive = "active"
|
||||
HelmStatusCreating = "creating"
|
||||
HelmStatusDeleting = "deleting"
|
||||
HelmStatusUpgrading = "upgrading"
|
||||
HelmStatusRollbacking = "rollbacking"
|
||||
HelmStatusFailed = "failed"
|
||||
HelmStatusCreated = "created"
|
||||
HelmStatusUpgraded = "upgraded"
|
||||
|
||||
AttachmentTypeScreenshot = "screenshot"
|
||||
AttachmentTypeIcon = "icon"
|
||||
|
||||
HelmApplicationAppStoreSuffix = "-store"
|
||||
HelmApplicationIdPrefix = "app-"
|
||||
HelmRepoIdPrefix = "repo-"
|
||||
HelmApplicationVersionIdPrefix = "appv-"
|
||||
HelmCategoryIdPrefix = "ctg-"
|
||||
HelmAttachmentPrefix = "att-"
|
||||
HelmReleasePrefix = "rls-"
|
||||
UncategorizedName = "uncategorized"
|
||||
UncategorizedId = "ctg-uncategorized"
|
||||
AppStoreRepoId = "repo-helm"
|
||||
|
||||
ApplicationInstance = "app.kubesphere.io/instance"
|
||||
|
||||
OriginWorkspaceLabelKey = "kubesphere.io/workspace-origin"
|
||||
)
|
||||
20
vendor/kubesphere.io/api/application/v1alpha1/doc.go
generated
vendored
Normal file
20
vendor/kubesphere.io/api/application/v1alpha1/doc.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright 2020 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.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +groupName=application.kubesphere.io
|
||||
|
||||
package v1alpha1
|
||||
136
vendor/kubesphere.io/api/application/v1alpha1/helmapplication_types.go
generated
vendored
Normal file
136
vendor/kubesphere.io/api/application/v1alpha1/helmapplication_types.go
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Copyright 2020 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 (
|
||||
"strings"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"kubesphere.io/api/constants"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindHelmApplication = "HelmApplication"
|
||||
ResourceSingularHelmApplication = "helmapplication"
|
||||
ResourcePluralHelmApplication = "helmapplications"
|
||||
)
|
||||
|
||||
// HelmApplicationSpec defines the desired state of HelmApplication
|
||||
type HelmApplicationSpec struct {
|
||||
// the name of the helm application
|
||||
Name string `json:"name"`
|
||||
// description from chart's description or frontend
|
||||
Description string `json:"description,omitempty"`
|
||||
// attachments id
|
||||
Attachments []string `json:"attachments,omitempty"`
|
||||
// info from frontend
|
||||
Abstraction string `json:"abstraction,omitempty"`
|
||||
AppHome string `json:"appHome,omitempty"`
|
||||
// The attachment id of the icon
|
||||
Icon string `json:"icon,omitempty"`
|
||||
}
|
||||
|
||||
// HelmApplicationStatus defines the observed state of HelmApplication
|
||||
type HelmApplicationStatus struct {
|
||||
// If this application belong to appStore, latestVersion is the the latest version of the active application version.
|
||||
// otherwise latestVersion is the latest version of all application version
|
||||
LatestVersion string `json:"latestVersion,omitempty"`
|
||||
// the state of the helm application: draft, submitted, passed, rejected, suspended, active
|
||||
State string `json:"state,omitempty"`
|
||||
UpdateTime *metav1.Time `json:"updateTime"`
|
||||
StatusTime *metav1.Time `json:"statusTime"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:resource:scope=Cluster,shortName=happ
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="application name",type=string,JSONPath=`.spec.name`
|
||||
// +kubebuilder:printcolumn:name="workspace",type="string",JSONPath=".metadata.labels.kubesphere\\.io/workspace"
|
||||
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmApplication is the Schema for the helmapplications API
|
||||
type HelmApplication struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec HelmApplicationSpec `json:"spec,omitempty"`
|
||||
Status HelmApplicationStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmApplicationList contains a list of HelmApplication
|
||||
type HelmApplicationList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []HelmApplication `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&HelmApplication{}, &HelmApplicationList{})
|
||||
}
|
||||
|
||||
func (in *HelmApplication) GetTrueName() string {
|
||||
return in.Spec.Name
|
||||
}
|
||||
|
||||
func (in *HelmApplication) GetHelmRepoId() string {
|
||||
return getValue(in.Labels, constants.ChartRepoIdLabelKey)
|
||||
}
|
||||
|
||||
func (in *HelmApplication) GetHelmApplicationId() string {
|
||||
return strings.TrimSuffix(in.Name, HelmApplicationAppStoreSuffix)
|
||||
}
|
||||
func (in *HelmApplication) GetHelmCategoryId() string {
|
||||
return getValue(in.Labels, constants.CategoryIdLabelKey)
|
||||
}
|
||||
|
||||
func (in *HelmApplication) GetWorkspace() string {
|
||||
ws := getValue(in.Labels, constants.WorkspaceLabelKey)
|
||||
if ws == "" {
|
||||
return getValue(in.Labels, OriginWorkspaceLabelKey)
|
||||
}
|
||||
return ws
|
||||
}
|
||||
|
||||
func getValue(m map[string]string, key string) string {
|
||||
if m == nil {
|
||||
return ""
|
||||
}
|
||||
return m[key]
|
||||
}
|
||||
|
||||
func (in *HelmApplication) GetCategoryId() string {
|
||||
return getValue(in.Labels, constants.CategoryIdLabelKey)
|
||||
}
|
||||
|
||||
func (in *HelmApplication) State() string {
|
||||
if in.Status.State == "" {
|
||||
return StateDraft
|
||||
}
|
||||
return in.Status.State
|
||||
}
|
||||
|
||||
func (in *HelmApplication) GetCreator() string {
|
||||
return getValue(in.Annotations, constants.CreatorAnnotationKey)
|
||||
}
|
||||
233
vendor/kubesphere.io/api/application/v1alpha1/helmapplicationversion_types.go
generated
vendored
Normal file
233
vendor/kubesphere.io/api/application/v1alpha1/helmapplicationversion_types.go
generated
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
Copyright 2020 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"
|
||||
"strings"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"kubesphere.io/api/constants"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindHelmApplicationVersion = "HelmApplicationVersion"
|
||||
ResourceSingularHelmApplicationVersion = "helmapplicationversion"
|
||||
ResourcePluralHelmApplicationVersion = "helmapplicationversions"
|
||||
)
|
||||
|
||||
// HelmApplicationVersionSpec defines the desired state of HelmApplicationVersion
|
||||
type HelmApplicationVersionSpec struct {
|
||||
// metadata from chart
|
||||
*Metadata `json:",inline"`
|
||||
// chart url
|
||||
URLs []string `json:"urls,omitempty"`
|
||||
// raw data of chart, it will !!!NOT!!! be save to etcd
|
||||
Data []byte `json:"data,omitempty"`
|
||||
|
||||
// dataKey in the storage
|
||||
DataKey string `json:"dataKey,omitempty"`
|
||||
|
||||
// chart create time
|
||||
Created *metav1.Time `json:"created,omitempty"`
|
||||
|
||||
// chart digest
|
||||
Digest string `json:"digest,omitempty"`
|
||||
}
|
||||
|
||||
// HelmApplicationVersionStatus defines the observed state of HelmApplicationVersion
|
||||
type HelmApplicationVersionStatus struct {
|
||||
State string `json:"state,omitempty"`
|
||||
Audit []Audit `json:"audit,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:resource:scope=Cluster,shortName=happver
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="application name",type=string,JSONPath=`.spec.name`
|
||||
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmApplicationVersion is the Schema for the helmapplicationversions API
|
||||
type HelmApplicationVersion struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec HelmApplicationVersionSpec `json:"spec,omitempty"`
|
||||
Status HelmApplicationVersionStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// Maintainer describes a Chart maintainer.
|
||||
type Maintainer struct {
|
||||
// Name is a user name or organization name
|
||||
Name string `json:"name,omitempty"`
|
||||
// Email is an optional email address to contact the named maintainer
|
||||
Email string `json:"email,omitempty"`
|
||||
// URL is an optional URL to an address for the named maintainer
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// Metadata for a Chart file. This models the structure of a Chart.yaml file.
|
||||
type Metadata struct {
|
||||
// The name of the chart
|
||||
Name string `json:"name,omitempty"`
|
||||
// The URL to a relevant project page, git repo, or contact person
|
||||
Home string `json:"home,omitempty"`
|
||||
// Source is the URL to the source code of this chart
|
||||
Sources []string `json:"sources,omitempty"`
|
||||
// A SemVer 2 conformant version string of the chart
|
||||
Version string `json:"version,omitempty"`
|
||||
// A one-sentence description of the chart
|
||||
Description string `json:"description,omitempty"`
|
||||
// A list of string keywords
|
||||
Keywords []string `json:"keywords,omitempty"`
|
||||
// A list of name and URL/email address combinations for the maintainer(s)
|
||||
Maintainers []*Maintainer `json:"maintainers,omitempty"`
|
||||
// The URL to an icon file.
|
||||
Icon string `json:"icon,omitempty"`
|
||||
// The API Version of this chart.
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
// The condition to check to enable chart
|
||||
Condition string `json:"condition,omitempty"`
|
||||
// The tags to check to enable chart
|
||||
Tags string `json:"tags,omitempty"`
|
||||
// The version of the application enclosed inside of this chart.
|
||||
AppVersion string `json:"appVersion,omitempty"`
|
||||
// Whether or not this chart is deprecated
|
||||
Deprecated bool `json:"deprecated,omitempty"`
|
||||
// Annotations are additional mappings uninterpreted by Helm,
|
||||
// made available for inspection by other applications.
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
// KubeVersion is a SemVer constraint specifying the version of Kubernetes required.
|
||||
KubeVersion string `json:"kubeVersion,omitempty"`
|
||||
// Dependencies are a list of dependencies for a chart.
|
||||
Dependencies []*Dependency `json:"dependencies,omitempty"`
|
||||
// Specifies the chart type: application or library
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
type Audit struct {
|
||||
// audit message
|
||||
Message string `json:"message,omitempty"`
|
||||
// audit state: submitted, passed, draft, active, rejected, suspended
|
||||
State string `json:"state,omitempty"`
|
||||
// audit time
|
||||
Time metav1.Time `json:"time"`
|
||||
// audit operator
|
||||
Operator string `json:"operator,omitempty"`
|
||||
OperatorType string `json:"operatorType,omitempty"`
|
||||
}
|
||||
|
||||
// Dependency describes a chart upon which another chart depends.
|
||||
// Dependencies can be used to express developer intent, or to capture the state
|
||||
// of a chart.
|
||||
type Dependency struct {
|
||||
// Name is the name of the dependency.
|
||||
// This must mach the name in the dependency's Chart.yaml.
|
||||
Name string `json:"name"`
|
||||
// Version is the version (range) of this chart.
|
||||
// A lock file will always produce a single version, while a dependency
|
||||
// may contain a semantic version range.
|
||||
Version string `json:"version,omitempty"`
|
||||
// The URL to the repository.
|
||||
// Appending `index.yaml` to this string should result in a URL that can be
|
||||
// used to fetch the repository index.
|
||||
Repository string `json:"repository"`
|
||||
// A yaml path that resolves to a boolean, used for enabling/disabling charts (e.g. subchart1.enabled )
|
||||
Condition string `json:"condition,omitempty"`
|
||||
// Tags can be used to group charts for enabling/disabling together
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
// Enabled bool determines if chart should be loaded
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
// ImportValues holds the mapping of source values to parent key to be imported. Each item can be a
|
||||
// string or pair of child/parent sublist items.
|
||||
// ImportValues []interface{} `json:"import_values,omitempty"`
|
||||
|
||||
// Alias usable alias to be used for the chart
|
||||
Alias string `json:"alias,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmApplicationVersionList contains a list of HelmApplicationVersion
|
||||
type HelmApplicationVersionList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []HelmApplicationVersion `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&HelmApplicationVersion{}, &HelmApplicationVersionList{})
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetCreator() string {
|
||||
return getValue(in.Annotations, constants.CreatorAnnotationKey)
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetHelmApplicationVersionId() string {
|
||||
return in.Name
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetWorkspace() string {
|
||||
return getValue(in.Labels, constants.WorkspaceLabelKey)
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetVersionName() string {
|
||||
appV := in.GetChartAppVersion()
|
||||
if appV != "" {
|
||||
return fmt.Sprintf("%s [%s]", in.GetChartVersion(), appV)
|
||||
} else {
|
||||
return in.GetChartVersion()
|
||||
}
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetHelmApplicationId() string {
|
||||
return getValue(in.Labels, constants.ChartApplicationIdLabelKey)
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetSemver() string {
|
||||
return strings.Split(in.GetVersionName(), " ")[0]
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetTrueName() string {
|
||||
return in.Spec.Name
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetChartVersion() string {
|
||||
return in.Spec.Version
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetChartAppVersion() string {
|
||||
return in.Spec.AppVersion
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) GetHelmRepoId() string {
|
||||
return getValue(in.Labels, constants.ChartRepoIdLabelKey)
|
||||
}
|
||||
|
||||
func (in *HelmApplicationVersion) State() string {
|
||||
if in.Status.State == "" {
|
||||
return StateDraft
|
||||
}
|
||||
|
||||
return in.Status.State
|
||||
}
|
||||
81
vendor/kubesphere.io/api/application/v1alpha1/helmcategory_types.go
generated
vendored
Normal file
81
vendor/kubesphere.io/api/application/v1alpha1/helmcategory_types.go
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Copyright 2020 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 (
|
||||
ResourceKindHelmCategory = "HelmCategory"
|
||||
ResourceSingularHelmCategory = "helmcategory"
|
||||
ResourcePluralHelmCategory = "helmcategories"
|
||||
)
|
||||
|
||||
// HelmCategorySpec defines the desired state of HelmRepo
|
||||
type HelmCategorySpec struct {
|
||||
// name of the category
|
||||
Name string `json:"name"`
|
||||
// info from frontend
|
||||
Description string `json:"description,omitempty"`
|
||||
Locale string `json:"locale,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:resource:scope=Cluster,shortName=hctg
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="name",type=string,JSONPath=`.spec.name`
|
||||
// +kubebuilder:printcolumn:name="total",type=string,JSONPath=`.status.total`
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmCategory is the Schema for the helmcategories API
|
||||
type HelmCategory struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec HelmCategorySpec `json:"spec,omitempty"`
|
||||
Status HelmCategoryStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type HelmCategoryStatus struct {
|
||||
// total helmapplications belong to this category
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmCategoryList contains a list of HelmCategory
|
||||
type HelmCategoryList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []HelmCategory `json:"items"`
|
||||
}
|
||||
|
||||
func (in *HelmCategory) GetTrueName() string {
|
||||
if in == nil {
|
||||
return ""
|
||||
}
|
||||
return in.Spec.Name
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&HelmCategory{}, &HelmCategoryList{})
|
||||
}
|
||||
154
vendor/kubesphere.io/api/application/v1alpha1/helmrelease_types.go
generated
vendored
Normal file
154
vendor/kubesphere.io/api/application/v1alpha1/helmrelease_types.go
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
Copyright 2020 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"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"kubesphere.io/api/constants"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindHelmRelease = "HelmRelease"
|
||||
ResourceSingularHelmRelease = "helmrelease"
|
||||
ResourcePluralHelmRelease = "helmreleases"
|
||||
)
|
||||
|
||||
// HelmReleaseSpec defines the desired state of HelmRelease
|
||||
type HelmReleaseSpec struct {
|
||||
// Name of the release
|
||||
Name string `json:"name"`
|
||||
// Message got from frontend
|
||||
Description string `json:"description,omitempty"`
|
||||
// helm release values.yaml
|
||||
Values []byte `json:"values,omitempty"`
|
||||
// The name of the chart which will be installed.
|
||||
ChartName string `json:"chartName"`
|
||||
// Specify the exact chart version to install. If this is not specified, the latest version is installed
|
||||
ChartVersion string `json:"chartVersion"`
|
||||
// appVersion from Chart.yaml
|
||||
ChartAppVersion string `json:"chartAppVer,omitempty"`
|
||||
// id of the repo
|
||||
RepoId string `json:"repoId,omitempty"`
|
||||
// id of the helmapplication
|
||||
ApplicationId string `json:"appId,omitempty"`
|
||||
// application version id
|
||||
ApplicationVersionId string `json:"appVerId,omitempty"`
|
||||
// expected release version, when this version is not equal status.version, the release need upgrade
|
||||
// this filed should be modified when any filed of the spec modified.
|
||||
Version int `json:"version"`
|
||||
}
|
||||
|
||||
type HelmReleaseDeployStatus struct {
|
||||
// A human readable message indicating details about why the release is in this state.
|
||||
Message string `json:"message,omitempty"`
|
||||
// current state of the release
|
||||
State string `json:"state"`
|
||||
// deploy time, upgrade time or check status time
|
||||
Time metav1.Time `json:"deployTime"`
|
||||
}
|
||||
|
||||
// HelmReleaseStatus defines the observed state of HelmRelease
|
||||
type HelmReleaseStatus struct {
|
||||
// current state
|
||||
State string `json:"state"`
|
||||
// A human readable message indicating details about why the release is in this state.
|
||||
Message string `json:"message,omitempty"`
|
||||
// current release version
|
||||
Version int `json:"version,omitempty"`
|
||||
// deploy status list of history, which will store at most 10 state
|
||||
DeployStatus []HelmReleaseDeployStatus `json:"deployStatus,omitempty"`
|
||||
// last update time
|
||||
LastUpdate metav1.Time `json:"lastUpdate,omitempty"`
|
||||
// last deploy time or upgrade time
|
||||
LastDeployed *metav1.Time `json:"lastDeployed,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:resource:scope=Cluster,shortName=hrls
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="Release Name",type=string,JSONPath=".spec.name"
|
||||
// +kubebuilder:printcolumn:name="Workspace",type="string",JSONPath=".metadata.labels.kubesphere\\.io/workspace"
|
||||
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.kubesphere\\.io/cluster"
|
||||
// +kubebuilder:printcolumn:name="Namespace",type="string",JSONPath=".metadata.labels.kubesphere\\.io/namespace"
|
||||
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmRelease is the Schema for the helmreleases API
|
||||
type HelmRelease struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec HelmReleaseSpec `json:"spec,omitempty"`
|
||||
Status HelmReleaseStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmReleaseList contains a list of HelmRelease
|
||||
type HelmReleaseList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []HelmRelease `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&HelmRelease{}, &HelmReleaseList{})
|
||||
}
|
||||
|
||||
func (in *HelmRelease) GetCreator() string {
|
||||
return getValue(in.Annotations, constants.CreatorAnnotationKey)
|
||||
}
|
||||
|
||||
func (in *HelmRelease) GetTrueName() string {
|
||||
return in.Spec.Name
|
||||
}
|
||||
|
||||
func (in *HelmRelease) GetChartVersionName() string {
|
||||
appV := in.GetChartAppVersion()
|
||||
if appV != "" {
|
||||
return fmt.Sprintf("%s [%s]", in.GetChartVersion(), appV)
|
||||
} else {
|
||||
return in.GetChartVersion()
|
||||
}
|
||||
}
|
||||
|
||||
func (in *HelmRelease) GetChartAppVersion() string {
|
||||
return in.Spec.ChartAppVersion
|
||||
}
|
||||
|
||||
func (in *HelmRelease) GetChartVersion() string {
|
||||
return in.Spec.ChartVersion
|
||||
}
|
||||
|
||||
func (in *HelmRelease) GetRlsCluster() string {
|
||||
return getValue(in.Labels, constants.ClusterNameLabelKey)
|
||||
}
|
||||
|
||||
func (in *HelmRelease) GetWorkspace() string {
|
||||
return getValue(in.Labels, constants.WorkspaceLabelKey)
|
||||
}
|
||||
|
||||
func (in *HelmRelease) GetRlsNamespace() string {
|
||||
return getValue(in.Labels, constants.NamespaceLabelKey)
|
||||
}
|
||||
141
vendor/kubesphere.io/api/application/v1alpha1/helmrepo_types.go
generated
vendored
Normal file
141
vendor/kubesphere.io/api/application/v1alpha1/helmrepo_types.go
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
Copyright 2020 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"
|
||||
|
||||
"kubesphere.io/api/constants"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindHelmRepo = "HelmRepo"
|
||||
ResourceSingularHelmRepo = "helmrepo"
|
||||
ResourcePluralHelmRepo = "helmrepos"
|
||||
)
|
||||
|
||||
type HelmRepoCredential struct {
|
||||
// chart repository username
|
||||
Username string `json:"username,omitempty"`
|
||||
// chart repository password
|
||||
Password string `json:"password,omitempty"`
|
||||
// identify HTTPS client using this SSL certificate file
|
||||
CertFile string `json:"certFile,omitempty"`
|
||||
// identify HTTPS client using this SSL key file
|
||||
KeyFile string `json:"keyFile,omitempty"`
|
||||
// verify certificates of HTTPS-enabled servers using this CA bundle
|
||||
CAFile string `json:"caFile,omitempty"`
|
||||
// skip tls certificate checks for the repository, default is ture
|
||||
InsecureSkipTLSVerify *bool `json:"insecureSkipTLSVerify,omitempty"`
|
||||
|
||||
S3Config `json:",inline"`
|
||||
}
|
||||
|
||||
type S3Config struct {
|
||||
AccessKeyID string `json:"accessKeyID,omitempty"`
|
||||
SecretAccessKey string `json:"secretAccessKey,omitempty"`
|
||||
}
|
||||
|
||||
// HelmRepoSpec defines the desired state of HelmRepo
|
||||
type HelmRepoSpec struct {
|
||||
// name of the repo
|
||||
Name string `json:"name"`
|
||||
// helm repo url
|
||||
Url string `json:"url"`
|
||||
// helm repo credential
|
||||
Credential HelmRepoCredential `json:"credential,omitempty"`
|
||||
// chart repo description from frontend
|
||||
Description string `json:"description,omitempty"`
|
||||
// sync period in seconds, no sync when SyncPeriod=0, the minimum SyncPeriod is 180s
|
||||
SyncPeriod int `json:"syncPeriod,omitempty"`
|
||||
// expected repo version, when this version is not equal status.version, the repo need upgrade
|
||||
// this filed should be modified when any filed of the spec modified.
|
||||
Version int `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
type HelmRepoSyncState struct {
|
||||
// last sync state, valid state are: "failed", "success", and ""
|
||||
State string `json:"state,omitempty"`
|
||||
// A human readable message indicating details about why the repo is in this state.
|
||||
Message string `json:"message,omitempty"`
|
||||
SyncTime *metav1.Time `json:"syncTime"`
|
||||
}
|
||||
|
||||
// HelmRepoStatus defines the observed state of HelmRepo
|
||||
type HelmRepoStatus struct {
|
||||
// repo index
|
||||
Data string `json:"data,omitempty"`
|
||||
// status last update time
|
||||
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
|
||||
// current state of the repo, successful, failed or syncing
|
||||
State string `json:"state,omitempty"`
|
||||
// sync state list of history, which will store at most 10 state
|
||||
SyncState []HelmRepoSyncState `json:"syncState,omitempty"`
|
||||
// if status.version!=spec.Version, we need sync the repo now
|
||||
Version int `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:resource:scope=Cluster,path=helmrepos,shortName=hrepo
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="name",type=string,JSONPath=`.spec.name`
|
||||
// +kubebuilder:printcolumn:name="Workspace",type="string",JSONPath=".metadata.labels.kubesphere\\.io/workspace"
|
||||
// +kubebuilder:printcolumn:name="url",type=string,JSONPath=`.spec.url`
|
||||
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmRepo is the Schema for the helmrepoes API
|
||||
type HelmRepo struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec HelmRepoSpec `json:"spec,omitempty"`
|
||||
Status HelmRepoStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// HelmRepoList contains a list of HelmRepo
|
||||
type HelmRepoList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []HelmRepo `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&HelmRepo{}, &HelmRepoList{})
|
||||
}
|
||||
|
||||
func (in *HelmRepo) GetTrueName() string {
|
||||
return in.Spec.Name
|
||||
}
|
||||
|
||||
func (in *HelmRepo) GetHelmRepoId() string {
|
||||
return in.Name
|
||||
}
|
||||
|
||||
func (in *HelmRepo) GetWorkspace() string {
|
||||
return getValue(in.Labels, constants.WorkspaceLabelKey)
|
||||
}
|
||||
|
||||
func (in *HelmRepo) GetCreator() string {
|
||||
return getValue(in.Annotations, constants.CreatorAnnotationKey)
|
||||
}
|
||||
40
vendor/kubesphere.io/api/application/v1alpha1/register.go
generated
vendored
Normal file
40
vendor/kubesphere.io/api/application/v1alpha1/register.go
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright 2020 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 application v1alpha1 API group
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=application.kubesphere.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: "application.kubesphere.io", Version: "v1alpha1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
|
||||
|
||||
// AddToScheme adds the types in this group-version to the given scheme.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
742
vendor/kubesphere.io/api/application/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
742
vendor/kubesphere.io/api/application/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
@@ -0,0 +1,742 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2020 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 deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Audit) DeepCopyInto(out *Audit) {
|
||||
*out = *in
|
||||
in.Time.DeepCopyInto(&out.Time)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Audit.
|
||||
func (in *Audit) DeepCopy() *Audit {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Audit)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Dependency) DeepCopyInto(out *Dependency) {
|
||||
*out = *in
|
||||
if in.Tags != nil {
|
||||
in, out := &in.Tags, &out.Tags
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Dependency.
|
||||
func (in *Dependency) DeepCopy() *Dependency {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Dependency)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmApplication) DeepCopyInto(out *HelmApplication) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmApplication.
|
||||
func (in *HelmApplication) DeepCopy() *HelmApplication {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmApplication)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmApplication) 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 *HelmApplicationList) DeepCopyInto(out *HelmApplicationList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]HelmApplication, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmApplicationList.
|
||||
func (in *HelmApplicationList) DeepCopy() *HelmApplicationList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmApplicationList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmApplicationList) 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 *HelmApplicationSpec) DeepCopyInto(out *HelmApplicationSpec) {
|
||||
*out = *in
|
||||
if in.Attachments != nil {
|
||||
in, out := &in.Attachments, &out.Attachments
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmApplicationSpec.
|
||||
func (in *HelmApplicationSpec) DeepCopy() *HelmApplicationSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmApplicationSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmApplicationStatus) DeepCopyInto(out *HelmApplicationStatus) {
|
||||
*out = *in
|
||||
if in.UpdateTime != nil {
|
||||
in, out := &in.UpdateTime, &out.UpdateTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
if in.StatusTime != nil {
|
||||
in, out := &in.StatusTime, &out.StatusTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmApplicationStatus.
|
||||
func (in *HelmApplicationStatus) DeepCopy() *HelmApplicationStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmApplicationStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmApplicationVersion) DeepCopyInto(out *HelmApplicationVersion) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmApplicationVersion.
|
||||
func (in *HelmApplicationVersion) DeepCopy() *HelmApplicationVersion {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmApplicationVersion)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmApplicationVersion) 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 *HelmApplicationVersionList) DeepCopyInto(out *HelmApplicationVersionList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]HelmApplicationVersion, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmApplicationVersionList.
|
||||
func (in *HelmApplicationVersionList) DeepCopy() *HelmApplicationVersionList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmApplicationVersionList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmApplicationVersionList) 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 *HelmApplicationVersionSpec) DeepCopyInto(out *HelmApplicationVersionSpec) {
|
||||
*out = *in
|
||||
if in.Metadata != nil {
|
||||
in, out := &in.Metadata, &out.Metadata
|
||||
*out = new(Metadata)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.URLs != nil {
|
||||
in, out := &in.URLs, &out.URLs
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Data != nil {
|
||||
in, out := &in.Data, &out.Data
|
||||
*out = make([]byte, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Created != nil {
|
||||
in, out := &in.Created, &out.Created
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmApplicationVersionSpec.
|
||||
func (in *HelmApplicationVersionSpec) DeepCopy() *HelmApplicationVersionSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmApplicationVersionSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmApplicationVersionStatus) DeepCopyInto(out *HelmApplicationVersionStatus) {
|
||||
*out = *in
|
||||
if in.Audit != nil {
|
||||
in, out := &in.Audit, &out.Audit
|
||||
*out = make([]Audit, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmApplicationVersionStatus.
|
||||
func (in *HelmApplicationVersionStatus) DeepCopy() *HelmApplicationVersionStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmApplicationVersionStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmCategory) DeepCopyInto(out *HelmCategory) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
out.Status = in.Status
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmCategory.
|
||||
func (in *HelmCategory) DeepCopy() *HelmCategory {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmCategory)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmCategory) 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 *HelmCategoryList) DeepCopyInto(out *HelmCategoryList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]HelmCategory, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmCategoryList.
|
||||
func (in *HelmCategoryList) DeepCopy() *HelmCategoryList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmCategoryList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmCategoryList) 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 *HelmCategorySpec) DeepCopyInto(out *HelmCategorySpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmCategorySpec.
|
||||
func (in *HelmCategorySpec) DeepCopy() *HelmCategorySpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmCategorySpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmCategoryStatus) DeepCopyInto(out *HelmCategoryStatus) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmCategoryStatus.
|
||||
func (in *HelmCategoryStatus) DeepCopy() *HelmCategoryStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmCategoryStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmRelease) DeepCopyInto(out *HelmRelease) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRelease.
|
||||
func (in *HelmRelease) DeepCopy() *HelmRelease {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmRelease)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmRelease) 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 *HelmReleaseDeployStatus) DeepCopyInto(out *HelmReleaseDeployStatus) {
|
||||
*out = *in
|
||||
in.Time.DeepCopyInto(&out.Time)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmReleaseDeployStatus.
|
||||
func (in *HelmReleaseDeployStatus) DeepCopy() *HelmReleaseDeployStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmReleaseDeployStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmReleaseList) DeepCopyInto(out *HelmReleaseList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]HelmRelease, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmReleaseList.
|
||||
func (in *HelmReleaseList) DeepCopy() *HelmReleaseList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmReleaseList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmReleaseList) 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 *HelmReleaseSpec) DeepCopyInto(out *HelmReleaseSpec) {
|
||||
*out = *in
|
||||
if in.Values != nil {
|
||||
in, out := &in.Values, &out.Values
|
||||
*out = make([]byte, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmReleaseSpec.
|
||||
func (in *HelmReleaseSpec) DeepCopy() *HelmReleaseSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmReleaseSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmReleaseStatus) DeepCopyInto(out *HelmReleaseStatus) {
|
||||
*out = *in
|
||||
if in.DeployStatus != nil {
|
||||
in, out := &in.DeployStatus, &out.DeployStatus
|
||||
*out = make([]HelmReleaseDeployStatus, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
in.LastUpdate.DeepCopyInto(&out.LastUpdate)
|
||||
if in.LastDeployed != nil {
|
||||
in, out := &in.LastDeployed, &out.LastDeployed
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmReleaseStatus.
|
||||
func (in *HelmReleaseStatus) DeepCopy() *HelmReleaseStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmReleaseStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmRepo) DeepCopyInto(out *HelmRepo) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRepo.
|
||||
func (in *HelmRepo) DeepCopy() *HelmRepo {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmRepo)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmRepo) 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 *HelmRepoCredential) DeepCopyInto(out *HelmRepoCredential) {
|
||||
*out = *in
|
||||
if in.InsecureSkipTLSVerify != nil {
|
||||
in, out := &in.InsecureSkipTLSVerify, &out.InsecureSkipTLSVerify
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
out.S3Config = in.S3Config
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRepoCredential.
|
||||
func (in *HelmRepoCredential) DeepCopy() *HelmRepoCredential {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmRepoCredential)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmRepoList) DeepCopyInto(out *HelmRepoList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]HelmRepo, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRepoList.
|
||||
func (in *HelmRepoList) DeepCopy() *HelmRepoList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmRepoList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmRepoList) 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 *HelmRepoSpec) DeepCopyInto(out *HelmRepoSpec) {
|
||||
*out = *in
|
||||
in.Credential.DeepCopyInto(&out.Credential)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRepoSpec.
|
||||
func (in *HelmRepoSpec) DeepCopy() *HelmRepoSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmRepoSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmRepoStatus) DeepCopyInto(out *HelmRepoStatus) {
|
||||
*out = *in
|
||||
if in.LastUpdateTime != nil {
|
||||
in, out := &in.LastUpdateTime, &out.LastUpdateTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
if in.SyncState != nil {
|
||||
in, out := &in.SyncState, &out.SyncState
|
||||
*out = make([]HelmRepoSyncState, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRepoStatus.
|
||||
func (in *HelmRepoStatus) DeepCopy() *HelmRepoStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmRepoStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmRepoSyncState) DeepCopyInto(out *HelmRepoSyncState) {
|
||||
*out = *in
|
||||
if in.SyncTime != nil {
|
||||
in, out := &in.SyncTime, &out.SyncTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRepoSyncState.
|
||||
func (in *HelmRepoSyncState) DeepCopy() *HelmRepoSyncState {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmRepoSyncState)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Maintainer) DeepCopyInto(out *Maintainer) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Maintainer.
|
||||
func (in *Maintainer) DeepCopy() *Maintainer {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Maintainer)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Metadata) DeepCopyInto(out *Metadata) {
|
||||
*out = *in
|
||||
if in.Sources != nil {
|
||||
in, out := &in.Sources, &out.Sources
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Keywords != nil {
|
||||
in, out := &in.Keywords, &out.Keywords
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Maintainers != nil {
|
||||
in, out := &in.Maintainers, &out.Maintainers
|
||||
*out = make([]*Maintainer, len(*in))
|
||||
for i := range *in {
|
||||
if (*in)[i] != nil {
|
||||
in, out := &(*in)[i], &(*out)[i]
|
||||
*out = new(Maintainer)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
}
|
||||
if in.Annotations != nil {
|
||||
in, out := &in.Annotations, &out.Annotations
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.Dependencies != nil {
|
||||
in, out := &in.Dependencies, &out.Dependencies
|
||||
*out = make([]*Dependency, len(*in))
|
||||
for i := range *in {
|
||||
if (*in)[i] != nil {
|
||||
in, out := &(*in)[i], &(*out)[i]
|
||||
*out = new(Dependency)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metadata.
|
||||
func (in *Metadata) DeepCopy() *Metadata {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Metadata)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S3Config) DeepCopyInto(out *S3Config) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S3Config.
|
||||
func (in *S3Config) DeepCopy() *S3Config {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S3Config)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
19
vendor/kubesphere.io/api/auditing/v1alpha1/doc.go
generated
vendored
Normal file
19
vendor/kubesphere.io/api/auditing/v1alpha1/doc.go
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Copyright 2020 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 audit v1alpha1 API group
|
||||
// +groupName=auditing.kubesphere.io
|
||||
package v1alpha1
|
||||
41
vendor/kubesphere.io/api/auditing/v1alpha1/register.go
generated
vendored
Normal file
41
vendor/kubesphere.io/api/auditing/v1alpha1/register.go
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2020 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 audit v1alpha1 API group
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +groupName=auditing.kubesphere.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: "auditing.kubesphere.io", Version: "v1alpha1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
|
||||
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
91
vendor/kubesphere.io/api/auditing/v1alpha1/rule_types.go
generated
vendored
Normal file
91
vendor/kubesphere.io/api/auditing/v1alpha1/rule_types.go
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright 2020 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.
|
||||
|
||||
type PolicyRule struct {
|
||||
// Rule name
|
||||
Name string `json:"name,omitempty" protobuf:"bytes,8,opt,name=name"`
|
||||
// Rule type, rule, macro,list,alias
|
||||
Type string `json:"type,omitempty" protobuf:"bytes,8,opt,name=type"`
|
||||
// Rule describe
|
||||
Desc string `json:"desc,omitempty" protobuf:"bytes,8,opt,name=desc"`
|
||||
// Rule condition
|
||||
// This effective When the rule type is rule
|
||||
Condition string `json:"condition,omitempty" protobuf:"bytes,8,opt,name=condition"`
|
||||
// This effective When the rule type is macro
|
||||
Macro string `json:"macro,omitempty" protobuf:"bytes,8,opt,name=macro"`
|
||||
// This effective When the rule type is alias
|
||||
Alias string `json:"alias,omitempty" protobuf:"bytes,8,opt,name=alias"`
|
||||
// This effective When the rule type is list
|
||||
List []string `json:"list,omitempty" protobuf:"bytes,8,opt,name=list"`
|
||||
// Is the rule enable
|
||||
Enable bool `json:"enable" protobuf:"bytes,8,opt,name=enable"`
|
||||
// The output formater of message which send to user
|
||||
Output string `json:"output,omitempty" protobuf:"bytes,8,opt,name=output"`
|
||||
// Rule priority, DEBUG, INFO, WARNING
|
||||
Priority string `json:"priority,omitempty" protobuf:"bytes,8,opt,name=priority"`
|
||||
}
|
||||
|
||||
// AuditRuleSpec defines the desired state of Rule
|
||||
type RuleSpec struct {
|
||||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
|
||||
PolicyRules []PolicyRule `json:"rules,omitempty" protobuf:"bytes,8,opt,name=rules"`
|
||||
}
|
||||
|
||||
// AuditRuleStatus defines the observed state of Rule
|
||||
type RuleStatus struct {
|
||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:noStatus
|
||||
// +genclient:nonNamespaced
|
||||
// +kubebuilder:object:root=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// Rule is the Schema for the rules API
|
||||
type Rule struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec RuleSpec `json:"spec,omitempty"`
|
||||
Status RuleStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// AuditRuleList contains a list of Rule
|
||||
type RuleList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []Rule `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&Rule{}, &RuleList{})
|
||||
}
|
||||
261
vendor/kubesphere.io/api/auditing/v1alpha1/webhook_types.go
generated
vendored
Normal file
261
vendor/kubesphere.io/api/auditing/v1alpha1/webhook_types.go
generated
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
Copyright 2020 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 (
|
||||
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.
|
||||
|
||||
// Receiver config which received the audit alert
|
||||
type Receiver struct {
|
||||
// Receiver name
|
||||
// +optional
|
||||
ReceicerName string `json:"name,omitempty" protobuf:"bytes,8,opt,name=name"`
|
||||
// Receiver type, alertmanager or webhook
|
||||
// +optional
|
||||
ReceiverType string `json:"type,omitempty" protobuf:"bytes,8,opt,name=type"`
|
||||
// ClientConfig holds the connection parameters for the webhook
|
||||
// +optional
|
||||
ReceiverConfig *WebhookClientConfig `json:"config,omitempty" protobuf:"bytes,8,opt,name=config"`
|
||||
}
|
||||
|
||||
type AuditSinkPolicy struct {
|
||||
ArchivingRuleSelector *metav1.LabelSelector `json:"archivingRuleSelector,omitempty" protobuf:"bytes,8,opt,name=archivingRuleSelector"`
|
||||
AlertingRuleSelector *metav1.LabelSelector `json:"alertingRuleSelector,omitempty" protobuf:"bytes,8,opt,name=alertingRuleSelector"`
|
||||
}
|
||||
|
||||
type DynamicAuditConfig struct {
|
||||
// Throttle holds the options for throttling the webhook
|
||||
// +optional
|
||||
Throttle *WebhookThrottleConfig `json:"throttle,omitempty" protobuf:"bytes,18,opt,name=throttle"`
|
||||
// Policy defines the policy for selecting which events should be sent to the webhook
|
||||
// +optional
|
||||
Policy *Policy `json:"policy,omitempty" protobuf:"bytes,18,opt,name=policy"`
|
||||
}
|
||||
|
||||
type Policy struct {
|
||||
// The Level that all requests are recorded at.
|
||||
// available options: None, Metadata, Request, RequestResponse
|
||||
// required
|
||||
Level Level `json:"level" protobuf:"bytes,1,opt,name=level"`
|
||||
|
||||
// Stages is a list of stages for which events are created.
|
||||
// +optional
|
||||
Stages []Stage `json:"stages" protobuf:"bytes,2,opt,name=stages"`
|
||||
}
|
||||
|
||||
type Stage string
|
||||
|
||||
type Level string
|
||||
|
||||
type WebhookThrottleConfig struct {
|
||||
// ThrottleQPS maximum number of batches per second
|
||||
// default 10 QPS
|
||||
// +optional
|
||||
QPS *int64 `json:"qps,omitempty" protobuf:"bytes,1,opt,name=qps"`
|
||||
|
||||
// ThrottleBurst is the maximum number of events sent at the same moment
|
||||
// default 15 QPS
|
||||
// +optional
|
||||
Burst *int64 `json:"burst,omitempty" protobuf:"bytes,2,opt,name=burst"`
|
||||
}
|
||||
|
||||
// WebhookSpec defines the desired state of Webhook
|
||||
type WebhookSpec struct {
|
||||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
|
||||
// Number of desired pods. This is a pointer to distinguish between explicit
|
||||
// zero and not specified. Defaults to 1.
|
||||
// +optional
|
||||
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
|
||||
// The webhook docker image name.
|
||||
// +optional
|
||||
Image string `json:"image,omitempty" protobuf:"bytes,2,opt,name=image"`
|
||||
// Image pull policy.
|
||||
// One of Always, Never, IfNotPresent.
|
||||
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
|
||||
// Cannot be updated.
|
||||
// More info: https://kubernetes.io/docs/concepts/containers/images#updating-images
|
||||
// +optional
|
||||
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty" protobuf:"bytes,14,opt,name=imagePullPolicy,casttype=PullPolicy"`
|
||||
// ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec.
|
||||
// If specified, these secrets will be passed to individual puller implementations for them to use. For example,
|
||||
// in the case of docker, only DockerConfig type secrets are honored.
|
||||
// More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod
|
||||
// +optional
|
||||
// +patchMergeKey=name
|
||||
// +patchStrategy=merge
|
||||
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,15,rep,name=imagePullSecrets"`
|
||||
// Arguments to the entrypoint..
|
||||
// It will be appended to the args and replace the default value.
|
||||
// +optional
|
||||
Args []string `json:"args,omitempty" protobuf:"bytes,3,rep,name=args"`
|
||||
// NodeSelector is a selector which must be true for the pod to fit on a node.
|
||||
// Selector which must match a node's labels for the pod to be scheduled on that node.
|
||||
// More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
|
||||
// +optional
|
||||
NodeSelector map[string]string `json:"nodeSelector,omitempty" protobuf:"bytes,7,rep,name=nodeSelector"`
|
||||
// If specified, the pod's scheduling constraints
|
||||
// +optional
|
||||
Affinity *corev1.Affinity `json:"affinity,omitempty" protobuf:"bytes,18,opt,name=affinity"`
|
||||
// If specified, the pod's tolerations.
|
||||
// +optional
|
||||
Tolerations []corev1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,22,opt,name=tolerations"`
|
||||
// Compute Resources required by this container.
|
||||
// Cannot be updated.
|
||||
// More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
|
||||
// +optional
|
||||
Resources *corev1.ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,8,opt,name=resources"`
|
||||
// Receiver contains the information to make a connection with the alertmanager
|
||||
// +optional
|
||||
Receivers []Receiver `json:"receivers,omitempty" protobuf:"bytes,8,opt,name=receivers"`
|
||||
|
||||
// AuditSinkPolicy is a rule selector, only the rule matched this selector will be taked effect.
|
||||
// +optional
|
||||
*AuditSinkPolicy `json:"auditSinkPolicy,omitempty" protobuf:"bytes,8,opt,name=auditSinkPolicy"`
|
||||
// Rule priority, DEBUG < INFO < WARNING
|
||||
//Audit events will be stored only when the priority of the audit rule
|
||||
// matching the audit event is greater than this.
|
||||
Priority string `json:"priority,omitempty" protobuf:"bytes,8,opt,name=priority"`
|
||||
// Audit type, static or dynamic.
|
||||
AuditType string `json:"auditType,omitempty" protobuf:"bytes,8,opt,name=auditType"`
|
||||
// The Level that all requests are recorded at.
|
||||
// available options: None, Metadata, Request, RequestResponse
|
||||
// default: Metadata
|
||||
// +optional
|
||||
AuditLevel Level `json:"auditLevel" protobuf:"bytes,1,opt,name=auditLevel"`
|
||||
// K8s auditing is enabled or not.
|
||||
K8sAuditingEnabled bool `json:"k8sAuditingEnabled,omitempty" protobuf:"bytes,8,opt,name=priority"`
|
||||
}
|
||||
|
||||
type WebhookClientConfig struct {
|
||||
// `url` gives the location of the webhook, in standard URL form
|
||||
// (`scheme://host:port/path`). Exactly one of `url` or `service`
|
||||
// must be specified.
|
||||
//
|
||||
// The `host` should not refer to a service running in the cluster; use
|
||||
// the `service` field instead. The host might be resolved via external
|
||||
// DNS in some apiservers (e.g., `kube-apiserver` cannot resolve
|
||||
// in-cluster DNS as that would be a layering violation). `host` may
|
||||
// also be an IP address.
|
||||
//
|
||||
// Please note that using `localhost` or `127.0.0.1` as a `host` is
|
||||
// risky unless you take great care to run this webhook on all hosts
|
||||
// which run an apiserver which might need to make calls to this
|
||||
// webhook. Such installs are likely to be non-portable, i.e., not easy
|
||||
// to turn up in a new cluster.
|
||||
//
|
||||
// The scheme must be "https"; the URL must begin with "https://".
|
||||
//
|
||||
// A path is optional, and if present may be any string permissible in
|
||||
// a URL. You may use the path to pass an arbitrary string to the
|
||||
// webhook, for example, a cluster identifier.
|
||||
//
|
||||
// Attempting to use a user or basic auth e.g. "user:password@" is not
|
||||
// allowed. Fragments ("#...") and query parameters ("?...") are not
|
||||
// allowed, either.
|
||||
//
|
||||
// +optional
|
||||
URL *string `json:"url,omitempty" protobuf:"bytes,1,opt,name=url"`
|
||||
|
||||
// `service` is a reference to the service for this webhook. Either
|
||||
// `service` or `url` must be specified.
|
||||
//
|
||||
// If the webhook is running within the cluster, then you should use `service`.
|
||||
//
|
||||
// +optional
|
||||
Service *ServiceReference `json:"service,omitempty" protobuf:"bytes,2,opt,name=service"`
|
||||
|
||||
// `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate.
|
||||
// If unspecified, system trust roots on the apiserver are used.
|
||||
// +optional
|
||||
CABundle []byte `json:"caBundle,omitempty" protobuf:"bytes,3,opt,name=caBundle"`
|
||||
}
|
||||
|
||||
// WebhookStatus defines the observed state of Webhook
|
||||
type WebhookStatus struct {
|
||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:noStatus
|
||||
// +genclient:nonNamespaced
|
||||
// +kubebuilder:object:root=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// Webhook is the Schema for the webhooks API
|
||||
type Webhook struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec WebhookSpec `json:"spec,omitempty"`
|
||||
Status WebhookStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// WebhookList contains a list of Webhook
|
||||
type WebhookList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []Webhook `json:"items"`
|
||||
}
|
||||
|
||||
type ServiceReference struct {
|
||||
// `namespace` is the namespace of the service.
|
||||
// Required
|
||||
Namespace string `json:"namespace" protobuf:"bytes,1,opt,name=namespace"`
|
||||
|
||||
// `name` is the name of the service.
|
||||
// Required
|
||||
Name string `json:"name" protobuf:"bytes,2,opt,name=name"`
|
||||
|
||||
// `path` is an optional URL path which will be sent in any request to
|
||||
// this service.
|
||||
// +optional
|
||||
Path *string `json:"path,omitempty" protobuf:"bytes,3,opt,name=path"`
|
||||
|
||||
// If specified, the port on the service that hosting webhook.
|
||||
// Default to 443 for backward compatibility.
|
||||
// `port` should be a valid port number (1-65535, inclusive).
|
||||
// +optional
|
||||
Port *int32 `json:"port,omitempty" protobuf:"varint,4,opt,name=port"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&Webhook{}, &WebhookList{})
|
||||
}
|
||||
|
||||
const (
|
||||
// LevelNone disables auditing
|
||||
LevelNone Level = "None"
|
||||
// LevelMetadata provides the basic level of auditing.
|
||||
LevelMetadata Level = "Metadata"
|
||||
// LevelRequest provides Metadata level of auditing, and additionally
|
||||
// logs the request object (does not apply for non-resource requests).
|
||||
LevelRequest Level = "Request"
|
||||
// LevelRequestResponse provides Request level of auditing, and additionally
|
||||
// logs the response object (does not apply for non-resource requests and watches).
|
||||
LevelRequestResponse Level = "RequestResponse"
|
||||
)
|
||||
454
vendor/kubesphere.io/api/auditing/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
454
vendor/kubesphere.io/api/auditing/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
@@ -0,0 +1,454 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2020 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 (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AuditSinkPolicy) DeepCopyInto(out *AuditSinkPolicy) {
|
||||
*out = *in
|
||||
if in.ArchivingRuleSelector != nil {
|
||||
in, out := &in.ArchivingRuleSelector, &out.ArchivingRuleSelector
|
||||
*out = new(v1.LabelSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.AlertingRuleSelector != nil {
|
||||
in, out := &in.AlertingRuleSelector, &out.AlertingRuleSelector
|
||||
*out = new(v1.LabelSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuditSinkPolicy.
|
||||
func (in *AuditSinkPolicy) DeepCopy() *AuditSinkPolicy {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(AuditSinkPolicy)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DynamicAuditConfig) DeepCopyInto(out *DynamicAuditConfig) {
|
||||
*out = *in
|
||||
if in.Throttle != nil {
|
||||
in, out := &in.Throttle, &out.Throttle
|
||||
*out = new(WebhookThrottleConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Policy != nil {
|
||||
in, out := &in.Policy, &out.Policy
|
||||
*out = new(Policy)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DynamicAuditConfig.
|
||||
func (in *DynamicAuditConfig) DeepCopy() *DynamicAuditConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DynamicAuditConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PolicyRule) DeepCopyInto(out *PolicyRule) {
|
||||
*out = *in
|
||||
if in.List != nil {
|
||||
in, out := &in.List, &out.List
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicyRule.
|
||||
func (in *PolicyRule) DeepCopy() *PolicyRule {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PolicyRule)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Receiver) DeepCopyInto(out *Receiver) {
|
||||
*out = *in
|
||||
in.ReceiverConfig.DeepCopyInto(out.ReceiverConfig)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Receiver.
|
||||
func (in *Receiver) DeepCopy() *Receiver {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Receiver)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Rule) DeepCopyInto(out *Rule) {
|
||||
*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 Rule.
|
||||
func (in *Rule) DeepCopy() *Rule {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Rule)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *Rule) 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 *RuleList) DeepCopyInto(out *RuleList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Rule, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleList.
|
||||
func (in *RuleList) DeepCopy() *RuleList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RuleList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *RuleList) 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 *RuleSpec) DeepCopyInto(out *RuleSpec) {
|
||||
*out = *in
|
||||
if in.PolicyRules != nil {
|
||||
in, out := &in.PolicyRules, &out.PolicyRules
|
||||
*out = make([]PolicyRule, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleSpec.
|
||||
func (in *RuleSpec) DeepCopy() *RuleSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RuleSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RuleStatus) DeepCopyInto(out *RuleStatus) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleStatus.
|
||||
func (in *RuleStatus) DeepCopy() *RuleStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RuleStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Webhook) DeepCopyInto(out *Webhook) {
|
||||
*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 Webhook.
|
||||
func (in *Webhook) DeepCopy() *Webhook {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Webhook)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *Webhook) 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 *WebhookList) DeepCopyInto(out *WebhookList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Webhook, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookList.
|
||||
func (in *WebhookList) DeepCopy() *WebhookList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(WebhookList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *WebhookList) 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 *WebhookSpec) DeepCopyInto(out *WebhookSpec) {
|
||||
*out = *in
|
||||
if in.Replicas != nil {
|
||||
in, out := &in.Replicas, &out.Replicas
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
if in.ImagePullSecrets != nil {
|
||||
in, out := &in.ImagePullSecrets, &out.ImagePullSecrets
|
||||
*out = make([]corev1.LocalObjectReference, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Args != nil {
|
||||
in, out := &in.Args, &out.Args
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.NodeSelector != nil {
|
||||
in, out := &in.NodeSelector, &out.NodeSelector
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.Affinity != nil {
|
||||
in, out := &in.Affinity, &out.Affinity
|
||||
*out = new(corev1.Affinity)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Tolerations != nil {
|
||||
in, out := &in.Tolerations, &out.Tolerations
|
||||
*out = make([]corev1.Toleration, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.Resources != nil {
|
||||
in, out := &in.Resources, &out.Resources
|
||||
*out = new(corev1.ResourceRequirements)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Receivers != nil {
|
||||
in, out := &in.Receivers, &out.Receivers
|
||||
*out = make([]Receiver, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.AuditSinkPolicy != nil {
|
||||
in, out := &in.AuditSinkPolicy, &out.AuditSinkPolicy
|
||||
*out = new(AuditSinkPolicy)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookSpec.
|
||||
func (in *WebhookSpec) DeepCopy() *WebhookSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(WebhookSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *WebhookStatus) DeepCopyInto(out *WebhookStatus) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookStatus.
|
||||
func (in *WebhookStatus) DeepCopy() *WebhookStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(WebhookStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *WebhookThrottleConfig) DeepCopyInto(out *WebhookThrottleConfig) {
|
||||
*out = *in
|
||||
if in.QPS != nil {
|
||||
in, out := &in.QPS, &out.QPS
|
||||
*out = new(int64)
|
||||
**out = **in
|
||||
}
|
||||
if in.Burst != nil {
|
||||
in, out := &in.Burst, &out.Burst
|
||||
*out = new(int64)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookThrottleConfig.
|
||||
func (in *WebhookThrottleConfig) DeepCopy() *WebhookThrottleConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(WebhookThrottleConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Policy) DeepCopyInto(out *Policy) {
|
||||
*out = *in
|
||||
if in.Stages != nil {
|
||||
in, out := &in.Stages, &out.Stages
|
||||
*out = make([]Stage, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Policy.
|
||||
func (in *Policy) DeepCopy() *Policy {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Policy)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *WebhookClientConfig) DeepCopyInto(out *WebhookClientConfig) {
|
||||
*out = *in
|
||||
if in.URL != nil {
|
||||
in, out := &in.URL, &out.URL
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.Service != nil {
|
||||
in, out := &in.Service, &out.Service
|
||||
*out = new(ServiceReference)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.CABundle != nil {
|
||||
in, out := &in.CABundle, &out.CABundle
|
||||
*out = make([]byte, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookClientConfig.
|
||||
func (in *WebhookClientConfig) DeepCopy() *WebhookClientConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(WebhookClientConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ServiceReference) DeepCopyInto(out *ServiceReference) {
|
||||
*out = *in
|
||||
if in.Path != nil {
|
||||
|
||||
in, out := &in.Path, &out.Path
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.Port != nil {
|
||||
in, out := &in.Port, &out.Port
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceReference.
|
||||
func (in *ServiceReference) DeepCopy() *ServiceReference {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ServiceReference)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
189
vendor/kubesphere.io/api/cluster/v1alpha1/cluster_types.go
generated
vendored
Normal file
189
vendor/kubesphere.io/api/cluster/v1alpha1/cluster_types.go
generated
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
Copyright 2020 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 (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindCluster = "Cluster"
|
||||
ResourcesSingularCluster = "cluster"
|
||||
ResourcesPluralCluster = "clusters"
|
||||
|
||||
HostCluster = "cluster-role.kubesphere.io/host"
|
||||
// Description of which region the cluster been placed
|
||||
ClusterRegion = "cluster.kubesphere.io/region"
|
||||
// Name of the cluster group
|
||||
ClusterGroup = "cluster.kubesphere.io/group"
|
||||
|
||||
Finalizer = "finalizer.cluster.kubesphere.io"
|
||||
)
|
||||
|
||||
type ClusterSpec struct {
|
||||
|
||||
// Join cluster as a kubefed cluster
|
||||
JoinFederation bool `json:"joinFederation,omitempty"`
|
||||
|
||||
// Desired state of the cluster
|
||||
Enable bool `json:"enable,omitempty"`
|
||||
|
||||
// Provider of the cluster, this field is just for description
|
||||
Provider string `json:"provider,omitempty"`
|
||||
|
||||
// Connection holds info to connect to the member cluster
|
||||
Connection Connection `json:"connection,omitempty"`
|
||||
}
|
||||
|
||||
type ConnectionType string
|
||||
|
||||
const (
|
||||
ConnectionTypeDirect ConnectionType = "direct"
|
||||
ConnectionTypeProxy ConnectionType = "proxy"
|
||||
)
|
||||
|
||||
type Connection struct {
|
||||
|
||||
// type defines how host cluster will connect to host cluster
|
||||
// ConnectionTypeDirect means direct connection, this requires
|
||||
// kubeconfig and kubesphere apiserver endpoint provided
|
||||
// ConnectionTypeProxy means using kubesphere proxy, no kubeconfig
|
||||
// or kubesphere apiserver endpoint required
|
||||
Type ConnectionType `json:"type,omitempty"`
|
||||
|
||||
// KubeSphere API Server endpoint. Example: http://10.10.0.11:8080
|
||||
// Should provide this field explicitly if connection type is direct.
|
||||
// Will be populated by ks-apiserver if connection type is proxy.
|
||||
KubeSphereAPIEndpoint string `json:"kubesphereAPIEndpoint,omitempty"`
|
||||
|
||||
// Kubernetes API Server endpoint. Example: https://10.10.0.1:6443
|
||||
// Should provide this field explicitly if connection type is direct.
|
||||
// Will be populated by ks-apiserver if connection type is proxy.
|
||||
KubernetesAPIEndpoint string `json:"kubernetesAPIEndpoint,omitempty"`
|
||||
|
||||
// KubeConfig content used to connect to cluster api server
|
||||
// Should provide this field explicitly if connection type is direct.
|
||||
// Will be populated by ks-proxy if connection type is proxy.
|
||||
KubeConfig []byte `json:"kubeconfig,omitempty"`
|
||||
|
||||
// Token used by agents of member cluster to connect to host cluster proxy.
|
||||
// This field is populated by apiserver only if connection type is proxy.
|
||||
Token string `json:"token,omitempty"`
|
||||
|
||||
// KubeAPIServerPort is the port which listens for forwarding kube-apiserver traffic
|
||||
// Only applicable when connection type is proxy.
|
||||
KubernetesAPIServerPort uint16 `json:"kubernetesAPIServerPort,omitempty"`
|
||||
|
||||
// KubeSphereAPIServerPort is the port which listens for forwarding kubesphere apigateway traffic
|
||||
// Only applicable when connection type is proxy.
|
||||
KubeSphereAPIServerPort uint16 `json:"kubesphereAPIServerPort,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterConditionType string
|
||||
|
||||
const (
|
||||
// Cluster agent is initialized and waiting for connecting
|
||||
ClusterInitialized ClusterConditionType = "Initialized"
|
||||
|
||||
// Cluster agent is available
|
||||
ClusterAgentAvailable ClusterConditionType = "AgentAvailable"
|
||||
|
||||
// Cluster has been one of federated clusters
|
||||
ClusterFederated ClusterConditionType = "Federated"
|
||||
|
||||
// Cluster is all available for requests
|
||||
ClusterReady ClusterConditionType = "Ready"
|
||||
|
||||
// Openpitrix runtime is created
|
||||
ClusterOpenPitrixRuntimeReady ClusterConditionType = "OpenPitrixRuntimeReady"
|
||||
)
|
||||
|
||||
type ClusterCondition struct {
|
||||
// Type of the condition
|
||||
Type ClusterConditionType `json:"type"`
|
||||
// Status of the condition, one of True, False, Unknown.
|
||||
Status v1.ConditionStatus `json:"status"`
|
||||
// The last time this condition was updated.
|
||||
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
|
||||
// Last time the condition transitioned from one status to another.
|
||||
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
|
||||
// The reason for the condition's last transition.
|
||||
Reason string `json:"reason,omitempty"`
|
||||
// A human readable message indicating details about the transition.
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterStatus struct {
|
||||
|
||||
// Represents the latest available observations of a cluster's current state.
|
||||
Conditions []ClusterCondition `json:"conditions,omitempty"`
|
||||
|
||||
// GitVersion of the kubernetes cluster, this field is populated by cluster controller
|
||||
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
|
||||
|
||||
// GitVersion of the /kapis/version api response, this field is populated by cluster controller
|
||||
KubeSphereVersion string `json:"kubeSphereVersion,omitempty"`
|
||||
|
||||
// Count of the kubernetes cluster nodes
|
||||
// This field may not reflect the instant status of the cluster.
|
||||
NodeCount int `json:"nodeCount,omitempty"`
|
||||
|
||||
// Zones are the names of availability zones in which the nodes of the cluster exist, e.g. 'us-east1-a'.
|
||||
// +optional
|
||||
Zones []string `json:"zones,omitempty"`
|
||||
|
||||
// Region is the name of the region in which all of the nodes in the cluster exist. e.g. 'us-east1'.
|
||||
// +optional
|
||||
Region *string `json:"region,omitempty"`
|
||||
|
||||
// Configz is status of components enabled in the member cluster. This is synchronized with member cluster
|
||||
// every amount of time, like 5 minutes.
|
||||
// +optional
|
||||
Configz map[string]bool `json:"configz,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +k8s:openapi-gen=true
|
||||
// +genclient:nonNamespaced
|
||||
// +kubebuilder:printcolumn:name="Federated",type="boolean",JSONPath=".spec.joinFederation"
|
||||
// +kubebuilder:printcolumn:name="Provider",type="string",JSONPath=".spec.provider"
|
||||
// +kubebuilder:printcolumn:name="Active",type="boolean",JSONPath=".spec.enable"
|
||||
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.kubernetesVersion"
|
||||
// +kubebuilder:resource:scope=Cluster
|
||||
|
||||
// Cluster is the schema for the clusters API
|
||||
type Cluster struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ClusterSpec `json:"spec,omitempty"`
|
||||
Status ClusterStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type ClusterList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []Cluster `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&Cluster{}, &ClusterList{})
|
||||
}
|
||||
24
vendor/kubesphere.io/api/cluster/v1alpha1/doc.go
generated
vendored
Normal file
24
vendor/kubesphere.io/api/cluster/v1alpha1/doc.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2020 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 tower v1alpha1 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=kubesphere.io/api/cluster
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=cluster.kubesphere.io
|
||||
|
||||
package v1alpha1
|
||||
14502
vendor/kubesphere.io/api/cluster/v1alpha1/openapi_generated.go
generated
vendored
Normal file
14502
vendor/kubesphere.io/api/cluster/v1alpha1/openapi_generated.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
57
vendor/kubesphere.io/api/cluster/v1alpha1/register.go
generated
vendored
Normal file
57
vendor/kubesphere.io/api/cluster/v1alpha1/register.go
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright 2020 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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 tower v1alpha1 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=cluster.kubesphere.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// GroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: "cluster.kubesphere.io", Version: "v1alpha1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
|
||||
|
||||
// AddToScheme adds the types in this group-version to the given scheme.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
182
vendor/kubesphere.io/api/cluster/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
182
vendor/kubesphere.io/api/cluster/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2020 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 deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Cluster) DeepCopyInto(out *Cluster) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Cluster.
|
||||
func (in *Cluster) DeepCopy() *Cluster {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Cluster)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *Cluster) 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 *ClusterCondition) DeepCopyInto(out *ClusterCondition) {
|
||||
*out = *in
|
||||
in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime)
|
||||
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterCondition.
|
||||
func (in *ClusterCondition) DeepCopy() *ClusterCondition {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterCondition)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterList) DeepCopyInto(out *ClusterList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Cluster, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterList.
|
||||
func (in *ClusterList) DeepCopy() *ClusterList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ClusterList) 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 *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
|
||||
*out = *in
|
||||
in.Connection.DeepCopyInto(&out.Connection)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSpec.
|
||||
func (in *ClusterSpec) DeepCopy() *ClusterSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) {
|
||||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]ClusterCondition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.Zones != nil {
|
||||
in, out := &in.Zones, &out.Zones
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Region != nil {
|
||||
in, out := &in.Region, &out.Region
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.Configz != nil {
|
||||
in, out := &in.Configz, &out.Configz
|
||||
*out = make(map[string]bool, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStatus.
|
||||
func (in *ClusterStatus) DeepCopy() *ClusterStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Connection) DeepCopyInto(out *Connection) {
|
||||
*out = *in
|
||||
if in.KubeConfig != nil {
|
||||
in, out := &in.KubeConfig, &out.KubeConfig
|
||||
*out = make([]byte, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Connection.
|
||||
func (in *Connection) DeepCopy() *Connection {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Connection)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
29
vendor/kubesphere.io/api/constants/constants.go
generated
vendored
Normal file
29
vendor/kubesphere.io/api/constants/constants.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
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 constants
|
||||
|
||||
const (
|
||||
WorkspaceLabelKey = "kubesphere.io/workspace"
|
||||
NameLabelKey = "kubesphere.io/name"
|
||||
NamespaceLabelKey = "kubesphere.io/namespace"
|
||||
CreatorAnnotationKey = "kubesphere.io/creator"
|
||||
ClusterNameLabelKey = "kubesphere.io/cluster"
|
||||
ChartRepoIdLabelKey = "application.kubesphere.io/repo-id"
|
||||
ChartApplicationIdLabelKey = "application.kubesphere.io/app-id"
|
||||
ChartApplicationVersionIdLabelKey = "application.kubesphere.io/app-version-id"
|
||||
CategoryIdLabelKey = "application.kubesphere.io/app-category-id"
|
||||
)
|
||||
31
vendor/kubesphere.io/api/devops/crdinstall/install.go
generated
vendored
Normal file
31
vendor/kubesphere.io/api/devops/crdinstall/install.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2020 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 install
|
||||
|
||||
import (
|
||||
k8sruntime "k8s.io/apimachinery/pkg/runtime"
|
||||
urlruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
|
||||
devopsv1alpha1 "kubesphere.io/api/devops/v1alpha1"
|
||||
devopsv1alpha3 "kubesphere.io/api/devops/v1alpha3"
|
||||
)
|
||||
|
||||
func Install(scheme *k8sruntime.Scheme) {
|
||||
urlruntime.Must(devopsv1alpha1.AddToScheme(scheme))
|
||||
urlruntime.Must(devopsv1alpha3.AddToScheme(scheme))
|
||||
urlruntime.Must(scheme.SetVersionPriority(devopsv1alpha3.SchemeGroupVersion, devopsv1alpha1.SchemeGroupVersion))
|
||||
}
|
||||
23
vendor/kubesphere.io/api/devops/v1alpha1/doc.go
generated
vendored
Normal file
23
vendor/kubesphere.io/api/devops/v1alpha1/doc.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
Copyright 2020 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=kubesphere.io/api/devops
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=devops.kubesphere.io
|
||||
package v1alpha1
|
||||
16124
vendor/kubesphere.io/api/devops/v1alpha1/openapi_generated.go
generated
vendored
Normal file
16124
vendor/kubesphere.io/api/devops/v1alpha1/openapi_generated.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
46
vendor/kubesphere.io/api/devops/v1alpha1/register.go
generated
vendored
Normal file
46
vendor/kubesphere.io/api/devops/v1alpha1/register.go
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2020 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=kubesphere.io/api/devops
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=devops.kubesphere.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/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()
|
||||
}
|
||||
91
vendor/kubesphere.io/api/devops/v1alpha1/s2ibinary_types.go
generated
vendored
Normal file
91
vendor/kubesphere.io/api/devops/v1alpha1/s2ibinary_types.go
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright 2020 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 (
|
||||
ResourceKindS2iBinary = "S2iBinary"
|
||||
ResourceSingularS2iBinary = "s2ibinary"
|
||||
ResourcePluralS2iBinary = "s2ibinaries"
|
||||
)
|
||||
|
||||
const (
|
||||
StatusUploading = "Uploading"
|
||||
StatusReady = "Ready"
|
||||
StatusUploadFailed = "UploadFailed"
|
||||
)
|
||||
|
||||
const (
|
||||
S2iBinaryFinalizerName = "s2ibinary.finalizers.kubesphere.io"
|
||||
S2iBinaryLabelKey = "s2ibinary-name.kubesphere.io"
|
||||
)
|
||||
|
||||
// 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.
|
||||
|
||||
// S2iBinarySpec defines the desired state of S2iBinary
|
||||
type S2iBinarySpec struct {
|
||||
//FileName is filename of binary
|
||||
FileName string `json:"fileName,omitempty"`
|
||||
//MD5 is Binary's MD5 Hash
|
||||
MD5 string `json:"md5,omitempty"`
|
||||
//Size is the file size of file
|
||||
Size string `json:"size,omitempty"`
|
||||
//DownloadURL in KubeSphere
|
||||
DownloadURL string `json:"downloadURL,omitempty"`
|
||||
// UploadTime is last upload time
|
||||
UploadTimeStamp *metav1.Time `json:"uploadTimeStamp,omitempty"`
|
||||
}
|
||||
|
||||
// S2iBinaryStatus defines the observed state of S2iBinary
|
||||
type S2iBinaryStatus struct {
|
||||
//Phase is status of S2iBinary . Possible value is "Ready","UnableToDownload"
|
||||
Phase string `json:"phase,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// S2iBinary is the Schema for the s2ibinaries API
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:printcolumn:name="FileName",type="string",JSONPath=".spec.fileName"
|
||||
// +kubebuilder:printcolumn:name="MD5",type="string",JSONPath=".spec.md5"
|
||||
// +kubebuilder:printcolumn:name="Size",type="string",JSONPath=".spec.size"
|
||||
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"
|
||||
type S2iBinary struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec S2iBinarySpec `json:"spec,omitempty"`
|
||||
Status S2iBinaryStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// S2iBinaryList contains a list of S2iBinary
|
||||
type S2iBinaryList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []S2iBinary `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&S2iBinary{}, &S2iBinaryList{})
|
||||
}
|
||||
516
vendor/kubesphere.io/api/devops/v1alpha1/s2ibuilder_types.go
generated
vendored
Normal file
516
vendor/kubesphere.io/api/devops/v1alpha1/s2ibuilder_types.go
generated
vendored
Normal file
@@ -0,0 +1,516 @@
|
||||
/*
|
||||
Copyright 2020 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 RunState = "Successful"
|
||||
Failed RunState = "Failed"
|
||||
Unknown RunState = "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,multiple 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"`
|
||||
|
||||
// Regular expressions, ignoring names that do not match the provided regular expression
|
||||
BranchExpression string `json:"branchExpression,omitempty"`
|
||||
|
||||
// SecretCode
|
||||
SecretCode string `json:"secretCode,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{})
|
||||
}
|
||||
126
vendor/kubesphere.io/api/devops/v1alpha1/s2ibuildertemplate_types.go
generated
vendored
Normal file
126
vendor/kubesphere.io/api/devops/v1alpha1/s2ibuildertemplate_types.go
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
Copyright 2020 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"`
|
||||
}
|
||||
|
||||
type CodeFramework string
|
||||
|
||||
const (
|
||||
Ruby CodeFramework = "ruby"
|
||||
Go CodeFramework = "go"
|
||||
Java CodeFramework = "Java"
|
||||
JavaTomcat CodeFramework = "JavaTomcat"
|
||||
Nodejs CodeFramework = "Nodejs"
|
||||
Python CodeFramework = "python"
|
||||
)
|
||||
|
||||
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{})
|
||||
}
|
||||
141
vendor/kubesphere.io/api/devops/v1alpha1/s2irun_types.go
generated
vendored
Normal file
141
vendor/kubesphere.io/api/devops/v1alpha1/s2irun_types.go
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
Copyright 2020 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{})
|
||||
}
|
||||
879
vendor/kubesphere.io/api/devops/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
879
vendor/kubesphere.io/api/devops/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
@@ -0,0 +1,879 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2020 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 deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AuthConfig) DeepCopyInto(out *AuthConfig) {
|
||||
*out = *in
|
||||
if in.SecretRef != nil {
|
||||
in, out := &in.SecretRef, &out.SecretRef
|
||||
*out = new(v1.LocalObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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 *S2iBinary) DeepCopyInto(out *S2iBinary) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBinary.
|
||||
func (in *S2iBinary) DeepCopy() *S2iBinary {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBinary)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *S2iBinary) 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 *S2iBinaryList) DeepCopyInto(out *S2iBinaryList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]S2iBinary, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBinaryList.
|
||||
func (in *S2iBinaryList) DeepCopy() *S2iBinaryList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBinaryList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *S2iBinaryList) 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 *S2iBinarySpec) DeepCopyInto(out *S2iBinarySpec) {
|
||||
*out = *in
|
||||
if in.UploadTimeStamp != nil {
|
||||
in, out := &in.UploadTimeStamp, &out.UploadTimeStamp
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBinarySpec.
|
||||
func (in *S2iBinarySpec) DeepCopy() *S2iBinarySpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBinarySpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *S2iBinaryStatus) DeepCopyInto(out *S2iBinaryStatus) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBinaryStatus.
|
||||
func (in *S2iBinaryStatus) DeepCopy() *S2iBinaryStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(S2iBinaryStatus)
|
||||
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)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
||||
// 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])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
||||
// 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])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
76
vendor/kubesphere.io/api/devops/v1alpha3/credential_types.go
generated
vendored
Normal file
76
vendor/kubesphere.io/api/devops/v1alpha3/credential_types.go
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright 2020 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 v1alpha3
|
||||
|
||||
import v1 "k8s.io/api/core/v1"
|
||||
|
||||
/**
|
||||
We use a special type of secret as a credential for DevOps.
|
||||
This file will not contain CRD, but the credential type constants and their fields.
|
||||
*/
|
||||
const (
|
||||
CredentialFinalizerName = "finalizers.kubesphere.io/credential"
|
||||
DevOpsCredentialPrefix = "credential.devops.kubesphere.io/"
|
||||
DevOpsCredentialDataHash = DevOpsCredentialPrefix + "datahash"
|
||||
// SecretTypeBasicAuth contains data needed for basic authentication.
|
||||
//
|
||||
// Required at least one of fields:
|
||||
// - Secret.Data["username"] - username used for authentication
|
||||
// - Secret.Data["password"] - password or token needed for authentication
|
||||
SecretTypeBasicAuth v1.SecretType = DevOpsCredentialPrefix + "basic-auth"
|
||||
// BasicAuthUsernameKey is the key of the username for SecretTypeBasicAuth secrets
|
||||
BasicAuthUsernameKey = "username"
|
||||
// BasicAuthPasswordKey is the key of the password or token for SecretTypeBasicAuth secrets
|
||||
BasicAuthPasswordKey = "password"
|
||||
|
||||
// SecretTypeSSHAuth contains data needed for ssh authentication.
|
||||
//
|
||||
// Required at least one of fields:
|
||||
// - Secret.Data["username"] - username used for authentication
|
||||
// - Secret.Data["passphrase"] - passphrase needed for authentication
|
||||
// - Secret.Data["privatekey"] - privatekey needed for authentication
|
||||
SecretTypeSSHAuth v1.SecretType = DevOpsCredentialPrefix + "ssh-auth"
|
||||
// SSHAuthUsernameKey is the key of the username for SecretTypeSSHAuth secrets
|
||||
SSHAuthUsernameKey = "username"
|
||||
// SSHAuthPrivateKey is the key of the passphrase for SecretTypeSSHAuth secrets
|
||||
SSHAuthPassphraseKey = "passphrase"
|
||||
// SSHAuthPrivateKey is the key of the privatekey for SecretTypeSSHAuth secrets
|
||||
SSHAuthPrivateKey = "private_key"
|
||||
|
||||
// SecretTypeSecretText contains data.
|
||||
//
|
||||
// Required at least one of fields:
|
||||
// - Secret.Data["secret"] - secret
|
||||
SecretTypeSecretText v1.SecretType = DevOpsCredentialPrefix + "secret-text"
|
||||
// SecretTextSecretKey is the key of the secret for SecretTypeSecretText secrets
|
||||
SecretTextSecretKey = "secret"
|
||||
|
||||
// SecretTypeKubeConfig contains data.
|
||||
//
|
||||
// Required at least one of fields:
|
||||
// - Secret.Data["secret"] - secret
|
||||
SecretTypeKubeConfig v1.SecretType = DevOpsCredentialPrefix + "kubeconfig"
|
||||
// KubeConfigSecretKey is the key of the secret for SecretTypeKubeConfig secrets
|
||||
KubeConfigSecretKey = "content"
|
||||
// CredentialAutoSyncAnnoKey is used to indicate whether the secret is automatically synchronized to devops.
|
||||
// In the old version, the credential is stored in jenkins and cannot be obtained.
|
||||
// This field is set to ensure that the secret is not overwritten by a nil value.
|
||||
CredentialAutoSyncAnnoKey = DevOpsCredentialPrefix + "autosync"
|
||||
CredentialSyncStatusAnnoKey = DevOpsCredentialPrefix + "syncstatus"
|
||||
CredentialSyncTimeAnnoKey = DevOpsCredentialPrefix + "synctime"
|
||||
CredentialSyncMsgAnnoKey = DevOpsCredentialPrefix + "syncmsg"
|
||||
)
|
||||
78
vendor/kubesphere.io/api/devops/v1alpha3/devopsproject_types.go
generated
vendored
Normal file
78
vendor/kubesphere.io/api/devops/v1alpha3/devopsproject_types.go
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright 2020 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 v1alpha3
|
||||
|
||||
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 DevOpsProjectFinalizerName = "devopsproject.finalizers.kubesphere.io"
|
||||
|
||||
const (
|
||||
ResourceKindDevOpsProject = "DevOpsProject"
|
||||
ResourceSingularDevOpsProject = "devopsproject"
|
||||
ResourcePluralDevOpsProject = "devopsprojects"
|
||||
DevOpsProjectPrefix = "devopsproject.devops.kubesphere.io/"
|
||||
DevOpeProjectSyncStatusAnnoKey = DevOpsProjectPrefix + "syncstatus"
|
||||
DevOpeProjectSyncTimeAnnoKey = DevOpsProjectPrefix + "synctime"
|
||||
DevOpeProjectSyncMsgAnnoKey = DevOpsProjectPrefix + "syncmsg"
|
||||
)
|
||||
|
||||
// DevOpsProjectSpec defines the desired state of DevOpsProject
|
||||
type DevOpsProjectSpec struct {
|
||||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
|
||||
}
|
||||
|
||||
// DevOpsProjectStatus defines the observed state of DevOpsProject
|
||||
type DevOpsProjectStatus struct {
|
||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
AdminNamespace string `json:"adminNamespace,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// DevOpsProject is the Schema for the devopsprojects API
|
||||
// +kubebuilder:resource:categories="devops",scope="Cluster"
|
||||
// +k8s:openapi-gen=true
|
||||
type DevOpsProject struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec DevOpsProjectSpec `json:"spec,omitempty"`
|
||||
Status DevOpsProjectStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// DevOpsProjectList contains a list of DevOpsProject
|
||||
type DevOpsProjectList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []DevOpsProject `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&DevOpsProject{}, &DevOpsProjectList{})
|
||||
}
|
||||
23
vendor/kubesphere.io/api/devops/v1alpha3/doc.go
generated
vendored
Normal file
23
vendor/kubesphere.io/api/devops/v1alpha3/doc.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
Copyright 2020 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 v1alpha3 contains API Schema definitions for the devops v1alpha3 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=kubesphere.io/api/devops
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=devops.kubesphere.io
|
||||
package v1alpha3
|
||||
3411
vendor/kubesphere.io/api/devops/v1alpha3/openapi_generated.go
generated
vendored
Normal file
3411
vendor/kubesphere.io/api/devops/v1alpha3/openapi_generated.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
230
vendor/kubesphere.io/api/devops/v1alpha3/pipeline_types.go
generated
vendored
Normal file
230
vendor/kubesphere.io/api/devops/v1alpha3/pipeline_types.go
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
Copyright 2020 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 v1alpha3
|
||||
|
||||
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 PipelineFinalizerName = "pipeline.finalizers.kubesphere.io"
|
||||
|
||||
const (
|
||||
ResourceKindPipeline = "Pipeline"
|
||||
ResourceSingularPipeline = "pipeline"
|
||||
ResourcePluralPipeline = "pipelines"
|
||||
PipelinePrefix = "pipeline.devops.kubesphere.io/"
|
||||
PipelineSpecHash = PipelinePrefix + "spechash"
|
||||
PipelineSyncStatusAnnoKey = PipelinePrefix + "syncstatus"
|
||||
PipelineSyncTimeAnnoKey = PipelinePrefix + "synctime"
|
||||
PipelineSyncMsgAnnoKey = PipelinePrefix + "syncmsg"
|
||||
)
|
||||
|
||||
// PipelineSpec defines the desired state of Pipeline
|
||||
type PipelineSpec struct {
|
||||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
Type string `json:"type" description:"type of devops pipeline, in scm or no scm"`
|
||||
Pipeline *NoScmPipeline `json:"pipeline,omitempty" description:"no scm pipeline structs"`
|
||||
MultiBranchPipeline *MultiBranchPipeline `json:"multi_branch_pipeline,omitempty" description:"in scm pipeline structs"`
|
||||
}
|
||||
|
||||
// PipelineStatus defines the observed state of Pipeline
|
||||
type PipelineStatus struct {
|
||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// Pipeline is the Schema for the pipelines API
|
||||
// +k8s:openapi-gen=true
|
||||
type Pipeline struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec PipelineSpec `json:"spec,omitempty"`
|
||||
Status PipelineStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// PipelineList contains a list of Pipeline
|
||||
type PipelineList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []Pipeline `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&Pipeline{}, &PipelineList{})
|
||||
}
|
||||
|
||||
const (
|
||||
NoScmPipelineType = "pipeline"
|
||||
MultiBranchPipelineType = "multi-branch-pipeline"
|
||||
)
|
||||
|
||||
const (
|
||||
SourceTypeSVN = "svn"
|
||||
SourceTypeGit = "git"
|
||||
SourceTypeSingleSVN = "single_svn"
|
||||
SourceTypeGitlab = "gitlab"
|
||||
SourceTypeGithub = "github"
|
||||
SourceTypeBitbucket = "bitbucket_server"
|
||||
)
|
||||
|
||||
type NoScmPipeline struct {
|
||||
Name string `json:"name" description:"name of pipeline"`
|
||||
Description string `json:"description,omitempty" description:"description of pipeline"`
|
||||
Discarder *DiscarderProperty `json:"discarder,omitempty" description:"Discarder of pipeline, managing when to drop a pipeline"`
|
||||
Parameters []Parameter `json:"parameters,omitempty" description:"Parameters define of pipeline,user could pass param when run pipeline"`
|
||||
DisableConcurrent bool `json:"disable_concurrent,omitempty" mapstructure:"disable_concurrent" description:"Whether to prohibit the pipeline from running in parallel"`
|
||||
TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger" description:"Timer to trigger pipeline run"`
|
||||
RemoteTrigger *RemoteTrigger `json:"remote_trigger,omitempty" mapstructure:"remote_trigger" description:"Remote api define to trigger pipeline run"`
|
||||
Jenkinsfile string `json:"jenkinsfile,omitempty" description:"Jenkinsfile's content'"`
|
||||
}
|
||||
|
||||
type MultiBranchPipeline struct {
|
||||
Name string `json:"name" description:"name of pipeline"`
|
||||
Description string `json:"description,omitempty" description:"description of pipeline"`
|
||||
Discarder *DiscarderProperty `json:"discarder,omitempty" description:"Discarder of pipeline, managing when to drop a pipeline"`
|
||||
TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger" description:"Timer to trigger pipeline run"`
|
||||
SourceType string `json:"source_type" description:"type of scm, such as github/git/svn"`
|
||||
GitSource *GitSource `json:"git_source,omitempty" description:"git scm define"`
|
||||
GitHubSource *GithubSource `json:"github_source,omitempty" description:"github scm define"`
|
||||
GitlabSource *GitlabSource `json:"gitlab_source,omitempty" description:"gitlab scm define"`
|
||||
SvnSource *SvnSource `json:"svn_source,omitempty" description:"multi branch svn scm define"`
|
||||
SingleSvnSource *SingleSvnSource `json:"single_svn_source,omitempty" description:"single branch svn scm define"`
|
||||
BitbucketServerSource *BitbucketServerSource `json:"bitbucket_server_source,omitempty" description:"bitbucket server scm defile"`
|
||||
ScriptPath string `json:"script_path" mapstructure:"script_path" description:"script path in scm"`
|
||||
MultiBranchJobTrigger *MultiBranchJobTrigger `json:"multibranch_job_trigger,omitempty" mapstructure:"multibranch_job_trigger" description:"Pipeline tasks that need to be triggered when branch creation/deletion"`
|
||||
}
|
||||
|
||||
type GitSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Url string `json:"url,omitempty" mapstructure:"url" description:"url of git source"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access git source"`
|
||||
DiscoverBranches bool `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Whether to discover a branch"`
|
||||
DiscoverTags bool `json:"discover_tags,omitempty" mapstructure:"discover_tags" description:"Discover tags configuration"`
|
||||
CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option" description:"advavced git clone options"`
|
||||
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"`
|
||||
}
|
||||
|
||||
// GithubSource and BitbucketServerSource have the same structure, but we don't use one due to crd errors
|
||||
type GithubSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Owner string `json:"owner,omitempty" mapstructure:"owner" description:"owner of github repo"`
|
||||
Repo string `json:"repo,omitempty" mapstructure:"repo" description:"repo name of github repo"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access github source"`
|
||||
ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri" description:"The api url can specify the location of the github apiserver.For private cloud configuration"`
|
||||
DiscoverBranches int `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Discover branch configuration"`
|
||||
DiscoverPRFromOrigin int `json:"discover_pr_from_origin,omitempty" mapstructure:"discover_pr_from_origin" description:"Discover origin PR configuration"`
|
||||
DiscoverPRFromForks *DiscoverPRFromForks `json:"discover_pr_from_forks,omitempty" mapstructure:"discover_pr_from_forks" description:"Discover fork PR configuration"`
|
||||
DiscoverTags bool `json:"discover_tags,omitempty" mapstructure:"discover_tags" description:"Discover tag configuration"`
|
||||
CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option" description:"advavced git clone options"`
|
||||
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"`
|
||||
}
|
||||
|
||||
type GitlabSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Owner string `json:"owner,omitempty" mapstructure:"owner" description:"owner of gitlab repo"`
|
||||
Repo string `json:"repo,omitempty" mapstructure:"repo" description:"repo name of gitlab repo"`
|
||||
ServerName string `json:"server_name,omitempty" description:"the name of gitlab server which was configured in jenkins"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access gitlab source"`
|
||||
ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri" description:"The api url can specify the location of the gitlab apiserver.For private cloud configuration"`
|
||||
DiscoverBranches int `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Discover branch configuration"`
|
||||
DiscoverPRFromOrigin int `json:"discover_pr_from_origin,omitempty" mapstructure:"discover_pr_from_origin" description:"Discover origin PR configuration"`
|
||||
DiscoverPRFromForks *DiscoverPRFromForks `json:"discover_pr_from_forks,omitempty" mapstructure:"discover_pr_from_forks" description:"Discover fork PR configuration"`
|
||||
DiscoverTags bool `json:"discover_tags,omitempty" mapstructure:"discover_tags" description:"Discover tags configuration"`
|
||||
CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option" description:"advavced git clone options"`
|
||||
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"`
|
||||
}
|
||||
|
||||
type BitbucketServerSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Owner string `json:"owner,omitempty" mapstructure:"owner" description:"owner of github repo"`
|
||||
Repo string `json:"repo,omitempty" mapstructure:"repo" description:"repo name of github repo"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access github source"`
|
||||
ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri" description:"The api url can specify the location of the github apiserver.For private cloud configuration"`
|
||||
DiscoverBranches int `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Discover branch configuration"`
|
||||
DiscoverPRFromOrigin int `json:"discover_pr_from_origin,omitempty" mapstructure:"discover_pr_from_origin" description:"Discover origin PR configuration"`
|
||||
DiscoverPRFromForks *DiscoverPRFromForks `json:"discover_pr_from_forks,omitempty" mapstructure:"discover_pr_from_forks" description:"Discover fork PR configuration"`
|
||||
DiscoverTags bool `json:"discover_tags,omitempty" mapstructure:"discover_tags" description:"Discover tag configuration"`
|
||||
CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option" description:"advavced git clone options"`
|
||||
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"`
|
||||
}
|
||||
|
||||
type MultiBranchJobTrigger struct {
|
||||
CreateActionJobsToTrigger string `json:"create_action_job_to_trigger,omitempty" description:"pipeline name to trigger"`
|
||||
DeleteActionJobsToTrigger string `json:"delete_action_job_to_trigger,omitempty" description:"pipeline name to trigger"`
|
||||
}
|
||||
|
||||
type GitCloneOption struct {
|
||||
Shallow bool `json:"shallow,omitempty" mapstructure:"shallow" description:"Whether to use git shallow clone"`
|
||||
Timeout int `json:"timeout,omitempty" mapstructure:"timeout" description:"git clone timeout mins"`
|
||||
Depth int `json:"depth,omitempty" mapstructure:"depth" description:"git clone depth"`
|
||||
}
|
||||
|
||||
type SvnSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Remote string `json:"remote,omitempty" description:"remote address url"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access svn source"`
|
||||
Includes string `json:"includes,omitempty" description:"branches to run pipeline"`
|
||||
Excludes string `json:"excludes,omitempty" description:"branches do not run pipeline"`
|
||||
}
|
||||
type SingleSvnSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Remote string `json:"remote,omitempty" description:"remote address url"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access svn source"`
|
||||
}
|
||||
|
||||
type DiscoverPRFromForks struct {
|
||||
Strategy int `json:"strategy,omitempty" mapstructure:"strategy" description:"github discover strategy"`
|
||||
Trust int `json:"trust,omitempty" mapstructure:"trust" description:"trust user type"`
|
||||
}
|
||||
|
||||
type DiscarderProperty struct {
|
||||
DaysToKeep string `json:"days_to_keep,omitempty" mapstructure:"days_to_keep" description:"days to keep pipeline"`
|
||||
NumToKeep string `json:"num_to_keep,omitempty" mapstructure:"num_to_keep" description:"nums to keep pipeline"`
|
||||
}
|
||||
|
||||
type Parameter struct {
|
||||
Name string `json:"name" description:"name of param"`
|
||||
DefaultValue string `json:"default_value,omitempty" mapstructure:"default_value" description:"default value of param"`
|
||||
Type string `json:"type" description:"type of param"`
|
||||
Description string `json:"description,omitempty" description:"description of pipeline"`
|
||||
}
|
||||
|
||||
type TimerTrigger struct {
|
||||
// user in no scm job
|
||||
Cron string `json:"cron,omitempty" description:"jenkins cron script"`
|
||||
|
||||
// use in multi-branch job
|
||||
Interval string `json:"interval,omitempty" description:"interval ms"`
|
||||
}
|
||||
|
||||
type RemoteTrigger struct {
|
||||
Token string `json:"token,omitempty" description:"remote trigger token"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&Pipeline{}, &PipelineList{})
|
||||
}
|
||||
46
vendor/kubesphere.io/api/devops/v1alpha3/register.go
generated
vendored
Normal file
46
vendor/kubesphere.io/api/devops/v1alpha3/register.go
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2020 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 v1alpha3 contains API Schema definitions for the devops v1alpha3 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=kubesphere.io/api/devops
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=devops.kubesphere.io
|
||||
package v1alpha3
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: "devops.kubesphere.io", Version: "v1alpha3"}
|
||||
|
||||
// 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()
|
||||
}
|
||||
561
vendor/kubesphere.io/api/devops/v1alpha3/zz_generated.deepcopy.go
generated
vendored
Normal file
561
vendor/kubesphere.io/api/devops/v1alpha3/zz_generated.deepcopy.go
generated
vendored
Normal file
@@ -0,0 +1,561 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2020 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 deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha3
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *BitbucketServerSource) DeepCopyInto(out *BitbucketServerSource) {
|
||||
*out = *in
|
||||
if in.DiscoverPRFromForks != nil {
|
||||
in, out := &in.DiscoverPRFromForks, &out.DiscoverPRFromForks
|
||||
*out = new(DiscoverPRFromForks)
|
||||
**out = **in
|
||||
}
|
||||
if in.CloneOption != nil {
|
||||
in, out := &in.CloneOption, &out.CloneOption
|
||||
*out = new(GitCloneOption)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BitbucketServerSource.
|
||||
func (in *BitbucketServerSource) DeepCopy() *BitbucketServerSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(BitbucketServerSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DevOpsProject) DeepCopyInto(out *DevOpsProject) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
out.Status = in.Status
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevOpsProject.
|
||||
func (in *DevOpsProject) DeepCopy() *DevOpsProject {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DevOpsProject)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *DevOpsProject) 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 *DevOpsProjectList) DeepCopyInto(out *DevOpsProjectList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]DevOpsProject, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevOpsProjectList.
|
||||
func (in *DevOpsProjectList) DeepCopy() *DevOpsProjectList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DevOpsProjectList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *DevOpsProjectList) 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 *DevOpsProjectSpec) DeepCopyInto(out *DevOpsProjectSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevOpsProjectSpec.
|
||||
func (in *DevOpsProjectSpec) DeepCopy() *DevOpsProjectSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DevOpsProjectSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DevOpsProjectStatus) DeepCopyInto(out *DevOpsProjectStatus) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevOpsProjectStatus.
|
||||
func (in *DevOpsProjectStatus) DeepCopy() *DevOpsProjectStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DevOpsProjectStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DiscarderProperty) DeepCopyInto(out *DiscarderProperty) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscarderProperty.
|
||||
func (in *DiscarderProperty) DeepCopy() *DiscarderProperty {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DiscarderProperty)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DiscoverPRFromForks) DeepCopyInto(out *DiscoverPRFromForks) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoverPRFromForks.
|
||||
func (in *DiscoverPRFromForks) DeepCopy() *DiscoverPRFromForks {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DiscoverPRFromForks)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GitCloneOption) DeepCopyInto(out *GitCloneOption) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitCloneOption.
|
||||
func (in *GitCloneOption) DeepCopy() *GitCloneOption {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GitCloneOption)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GitSource) DeepCopyInto(out *GitSource) {
|
||||
*out = *in
|
||||
if in.CloneOption != nil {
|
||||
in, out := &in.CloneOption, &out.CloneOption
|
||||
*out = new(GitCloneOption)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitSource.
|
||||
func (in *GitSource) DeepCopy() *GitSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GitSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GithubSource) DeepCopyInto(out *GithubSource) {
|
||||
*out = *in
|
||||
if in.DiscoverPRFromForks != nil {
|
||||
in, out := &in.DiscoverPRFromForks, &out.DiscoverPRFromForks
|
||||
*out = new(DiscoverPRFromForks)
|
||||
**out = **in
|
||||
}
|
||||
if in.CloneOption != nil {
|
||||
in, out := &in.CloneOption, &out.CloneOption
|
||||
*out = new(GitCloneOption)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GithubSource.
|
||||
func (in *GithubSource) DeepCopy() *GithubSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GithubSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GitlabSource) DeepCopyInto(out *GitlabSource) {
|
||||
*out = *in
|
||||
if in.DiscoverPRFromForks != nil {
|
||||
in, out := &in.DiscoverPRFromForks, &out.DiscoverPRFromForks
|
||||
*out = new(DiscoverPRFromForks)
|
||||
**out = **in
|
||||
}
|
||||
if in.CloneOption != nil {
|
||||
in, out := &in.CloneOption, &out.CloneOption
|
||||
*out = new(GitCloneOption)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabSource.
|
||||
func (in *GitlabSource) DeepCopy() *GitlabSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GitlabSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *MultiBranchJobTrigger) DeepCopyInto(out *MultiBranchJobTrigger) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiBranchJobTrigger.
|
||||
func (in *MultiBranchJobTrigger) DeepCopy() *MultiBranchJobTrigger {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MultiBranchJobTrigger)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *MultiBranchPipeline) DeepCopyInto(out *MultiBranchPipeline) {
|
||||
*out = *in
|
||||
if in.Discarder != nil {
|
||||
in, out := &in.Discarder, &out.Discarder
|
||||
*out = new(DiscarderProperty)
|
||||
**out = **in
|
||||
}
|
||||
if in.TimerTrigger != nil {
|
||||
in, out := &in.TimerTrigger, &out.TimerTrigger
|
||||
*out = new(TimerTrigger)
|
||||
**out = **in
|
||||
}
|
||||
if in.GitSource != nil {
|
||||
in, out := &in.GitSource, &out.GitSource
|
||||
*out = new(GitSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.GitHubSource != nil {
|
||||
in, out := &in.GitHubSource, &out.GitHubSource
|
||||
*out = new(GithubSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.GitlabSource != nil {
|
||||
in, out := &in.GitlabSource, &out.GitlabSource
|
||||
*out = new(GitlabSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.SvnSource != nil {
|
||||
in, out := &in.SvnSource, &out.SvnSource
|
||||
*out = new(SvnSource)
|
||||
**out = **in
|
||||
}
|
||||
if in.SingleSvnSource != nil {
|
||||
in, out := &in.SingleSvnSource, &out.SingleSvnSource
|
||||
*out = new(SingleSvnSource)
|
||||
**out = **in
|
||||
}
|
||||
if in.BitbucketServerSource != nil {
|
||||
in, out := &in.BitbucketServerSource, &out.BitbucketServerSource
|
||||
*out = new(BitbucketServerSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.MultiBranchJobTrigger != nil {
|
||||
in, out := &in.MultiBranchJobTrigger, &out.MultiBranchJobTrigger
|
||||
*out = new(MultiBranchJobTrigger)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiBranchPipeline.
|
||||
func (in *MultiBranchPipeline) DeepCopy() *MultiBranchPipeline {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MultiBranchPipeline)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NoScmPipeline) DeepCopyInto(out *NoScmPipeline) {
|
||||
*out = *in
|
||||
if in.Discarder != nil {
|
||||
in, out := &in.Discarder, &out.Discarder
|
||||
*out = new(DiscarderProperty)
|
||||
**out = **in
|
||||
}
|
||||
if in.Parameters != nil {
|
||||
in, out := &in.Parameters, &out.Parameters
|
||||
*out = make([]Parameter, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.TimerTrigger != nil {
|
||||
in, out := &in.TimerTrigger, &out.TimerTrigger
|
||||
*out = new(TimerTrigger)
|
||||
**out = **in
|
||||
}
|
||||
if in.RemoteTrigger != nil {
|
||||
in, out := &in.RemoteTrigger, &out.RemoteTrigger
|
||||
*out = new(RemoteTrigger)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NoScmPipeline.
|
||||
func (in *NoScmPipeline) DeepCopy() *NoScmPipeline {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NoScmPipeline)
|
||||
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
|
||||
return
|
||||
}
|
||||
|
||||
// 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 *Pipeline) DeepCopyInto(out *Pipeline) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Pipeline.
|
||||
func (in *Pipeline) DeepCopy() *Pipeline {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Pipeline)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *Pipeline) 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 *PipelineList) DeepCopyInto(out *PipelineList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Pipeline, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineList.
|
||||
func (in *PipelineList) DeepCopy() *PipelineList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PipelineList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *PipelineList) 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 *PipelineSpec) DeepCopyInto(out *PipelineSpec) {
|
||||
*out = *in
|
||||
if in.Pipeline != nil {
|
||||
in, out := &in.Pipeline, &out.Pipeline
|
||||
*out = new(NoScmPipeline)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.MultiBranchPipeline != nil {
|
||||
in, out := &in.MultiBranchPipeline, &out.MultiBranchPipeline
|
||||
*out = new(MultiBranchPipeline)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineSpec.
|
||||
func (in *PipelineSpec) DeepCopy() *PipelineSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PipelineSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PipelineStatus) DeepCopyInto(out *PipelineStatus) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineStatus.
|
||||
func (in *PipelineStatus) DeepCopy() *PipelineStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PipelineStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RemoteTrigger) DeepCopyInto(out *RemoteTrigger) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteTrigger.
|
||||
func (in *RemoteTrigger) DeepCopy() *RemoteTrigger {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RemoteTrigger)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *SingleSvnSource) DeepCopyInto(out *SingleSvnSource) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SingleSvnSource.
|
||||
func (in *SingleSvnSource) DeepCopy() *SingleSvnSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SingleSvnSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *SvnSource) DeepCopyInto(out *SvnSource) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SvnSource.
|
||||
func (in *SvnSource) DeepCopy() *SvnSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SvnSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TimerTrigger) DeepCopyInto(out *TimerTrigger) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TimerTrigger.
|
||||
func (in *TimerTrigger) DeepCopy() *TimerTrigger {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(TimerTrigger)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
23
vendor/kubesphere.io/api/iam/v1alpha2/doc.go
generated
vendored
Normal file
23
vendor/kubesphere.io/api/iam/v1alpha2/doc.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
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 v1alpha2 contains API Schema definitions for the iam v1alpha2 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=kubesphere.io/api/iam
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=iam.kubesphere.io
|
||||
package v1alpha2
|
||||
174
vendor/kubesphere.io/api/iam/v1alpha2/federated_types.go
generated
vendored
Normal file
174
vendor/kubesphere.io/api/iam/v1alpha2/federated_types.go
generated
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 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 v1alpha2
|
||||
|
||||
import (
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourcesSingularFedUser = "federateduser"
|
||||
ResourcesSingularFedGlobalRoleBinding = "federatedglobalrolebinding"
|
||||
ResourcesSingularFedWorkspaceRoleBinding = "federatedworkspacerolebinding"
|
||||
ResourcesSingularFedGlobalRole = "federatedglobalrole"
|
||||
ResourcesSingularFedWorkspaceRole = "federatedworkspacerole"
|
||||
ResourcesPluralFedUser = "federatedusers"
|
||||
ResourcesPluralFedGlobalRoleBinding = "federatedglobalrolebindings"
|
||||
ResourcesPluralFedWorkspaceRoleBinding = "federatedworkspacerolebindings"
|
||||
ResourcesPluralFedGlobalRole = "federatedglobalroles"
|
||||
ResourcesPluralFedWorkspaceRole = "federatedworkspaceroles"
|
||||
FedClusterRoleBindingKind = "FederatedClusterRoleBinding"
|
||||
FedClusterRoleKind = "FederatedClusterRole"
|
||||
FedGlobalRoleKind = "FederatedGlobalRole"
|
||||
FedWorkspaceRoleKind = "FederatedWorkspaceRole"
|
||||
FedGlobalRoleBindingKind = "FederatedGlobalRoleBinding"
|
||||
FedWorkspaceRoleBindingKind = "FederatedWorkspaceRoleBinding"
|
||||
fedResourceGroup = "types.kubefed.io"
|
||||
fedResourceVersion = "v1beta1"
|
||||
FedUserKind = "FederatedUser"
|
||||
)
|
||||
|
||||
var (
|
||||
FedUserResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedUser,
|
||||
SingularName: ResourcesSingularFedUser,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedUserKind,
|
||||
}
|
||||
FedGlobalRoleBindingResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedGlobalRoleBinding,
|
||||
SingularName: ResourcesSingularFedGlobalRoleBinding,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedGlobalRoleBindingKind,
|
||||
}
|
||||
FedWorkspaceRoleBindingResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedWorkspaceRoleBinding,
|
||||
SingularName: ResourcesSingularFedWorkspaceRoleBinding,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedWorkspaceRoleBindingKind,
|
||||
}
|
||||
FedGlobalRoleResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedGlobalRole,
|
||||
SingularName: ResourcesSingularFedGlobalRole,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedGlobalRoleKind,
|
||||
}
|
||||
|
||||
FedWorkspaceRoleResource = metav1.APIResource{
|
||||
Name: ResourcesPluralFedWorkspaceRole,
|
||||
SingularName: ResourcesSingularFedWorkspaceRole,
|
||||
Namespaced: false,
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Kind: FedWorkspaceRoleKind,
|
||||
}
|
||||
|
||||
FederatedClusterRoleBindingResource = schema.GroupVersionResource{
|
||||
Group: fedResourceGroup,
|
||||
Version: fedResourceVersion,
|
||||
Resource: "federatedclusterrolebindings",
|
||||
}
|
||||
)
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type FederatedRoleBinding struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec FederatedRoleBindingSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type FederatedRoleBindingSpec struct {
|
||||
Template RoleBindingTemplate `json:"template"`
|
||||
Placement Placement `json:"placement"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type RoleBindingTemplate struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Subjects []rbacv1.Subject `json:"subjects,omitempty"`
|
||||
RoleRef rbacv1.RoleRef `json:"roleRef"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type FederatedRole struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec FederatedRoleSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type FederatedRoleSpec struct {
|
||||
Template RoleTemplate `json:"template"`
|
||||
Placement Placement `json:"placement"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type RoleTemplate struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
// +optional
|
||||
Rules []rbacv1.PolicyRule `json:"rules" protobuf:"bytes,2,rep,name=rules"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type FederatedUser struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec FederatedUserSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type FederatedUserSpec struct {
|
||||
Template UserTemplate `json:"template"`
|
||||
Placement Placement `json:"placement"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type UserTemplate struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec UserSpec `json:"spec"`
|
||||
// +optional
|
||||
Status UserStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type Placement struct {
|
||||
Clusters []Cluster `json:"clusters,omitempty"`
|
||||
ClusterSelector ClusterSelector `json:"clusterSelector,omitempty"`
|
||||
}
|
||||
|
||||
//+kubebuilder:object:generate=true
|
||||
type ClusterSelector struct {
|
||||
MatchLabels map[string]string `json:"matchLabels,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:generate=false
|
||||
type Cluster struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
63
vendor/kubesphere.io/api/iam/v1alpha2/group_types.go
generated
vendored
Normal file
63
vendor/kubesphere.io/api/iam/v1alpha2/group_types.go
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright 2020 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 v1alpha2
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourcePluralGroup = "groups"
|
||||
GroupReferenceLabel = "iam.kubesphere.io/group-ref"
|
||||
GroupParent = "iam.kubesphere.io/group-parent"
|
||||
)
|
||||
|
||||
// GroupSpec defines the desired state of Group
|
||||
type GroupSpec struct {
|
||||
}
|
||||
|
||||
// GroupStatus defines the observed state of Group
|
||||
type GroupStatus struct {
|
||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
}
|
||||
|
||||
// +genclient:nonNamespaced
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:printcolumn:name="Workspace",type="string",JSONPath=".metadata.labels.kubesphere\\.io/workspace"
|
||||
// +kubebuilder:resource:categories="group",scope="Cluster"
|
||||
|
||||
// Group is the Schema for the groups API
|
||||
type Group struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec GroupSpec `json:"spec,omitempty"`
|
||||
Status GroupStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +genclient:nonNamespaced
|
||||
|
||||
// GroupList contains a list of Group
|
||||
type GroupList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []Group `json:"items"`
|
||||
}
|
||||
59
vendor/kubesphere.io/api/iam/v1alpha2/groupbinding_types.go
generated
vendored
Normal file
59
vendor/kubesphere.io/api/iam/v1alpha2/groupbinding_types.go
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright 2020 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 v1alpha2
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourcePluralGroupBinding = "groupbindings"
|
||||
)
|
||||
|
||||
// GroupRef defines the desired relation of GroupBinding
|
||||
type GroupRef struct {
|
||||
APIGroup string `json:"apiGroup,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient:nonNamespaced
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:printcolumn:name="Group",type="string",JSONPath=".groupRef.name"
|
||||
// +kubebuilder:printcolumn:name="Users",type="string",JSONPath=".users"
|
||||
// +kubebuilder:resource:categories="group",scope="Cluster"
|
||||
|
||||
// GroupBinding is the Schema for the groupbindings API
|
||||
type GroupBinding struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
GroupRef GroupRef `json:"groupRef,omitempty"`
|
||||
Users []string `json:"users,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +genclient:nonNamespaced
|
||||
|
||||
// GroupBindingList contains a list of GroupBinding
|
||||
type GroupBindingList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []GroupBinding `json:"items"`
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user