mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Merge pull request #184 from ibuildthecloud/default-ns
Assign default namespace if not set in manifests
This commit is contained in:
commit
2771ae1ba9
@ -68,6 +68,7 @@ type watcher struct {
|
|||||||
restConfig rest.Config
|
restConfig rest.Config
|
||||||
discovery discovery.DiscoveryInterface
|
discovery discovery.DiscoveryInterface
|
||||||
clients map[schema.GroupVersionKind]*objectclient.ObjectClient
|
clients map[schema.GroupVersionKind]*objectclient.ObjectClient
|
||||||
|
namespaced map[schema.GroupVersionKind]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *watcher) start(ctx context.Context) {
|
func (w *watcher) start(ctx context.Context) {
|
||||||
@ -201,15 +202,25 @@ func (w *watcher) apply(addon v1.Addon, set *objectset.ObjectSet) (map[schema.Gr
|
|||||||
ds := op.NewDesiredSet(nil, set)
|
ds := op.NewDesiredSet(nil, set)
|
||||||
|
|
||||||
for _, gvk := range addon.Status.GVKs {
|
for _, gvk := range addon.Status.GVKs {
|
||||||
|
var (
|
||||||
|
namespaced bool
|
||||||
|
)
|
||||||
|
|
||||||
client, ok := w.clients[gvk]
|
client, ok := w.clients[gvk]
|
||||||
if !ok {
|
if ok {
|
||||||
client, err = objectset.NewDiscoveredClient(gvk, w.restConfig, w.discovery)
|
namespaced = w.namespaced[gvk]
|
||||||
|
} else {
|
||||||
|
client, namespaced, err = objectset.NewDiscoveredClient(gvk, w.restConfig, w.discovery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if w.namespaced == nil {
|
||||||
|
w.namespaced = map[schema.GroupVersionKind]bool{}
|
||||||
|
}
|
||||||
|
w.namespaced[gvk] = namespaced
|
||||||
}
|
}
|
||||||
|
|
||||||
ds.AddDiscoveredClient(gvk, client)
|
ds.AddDiscoveredClient(gvk, client, namespaced)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ds.Apply(); err != nil {
|
if err := ds.Apply(); err != nil {
|
||||||
|
234
trash.lock
234
trash.lock
@ -111,7 +111,7 @@ import:
|
|||||||
- package: github.com/pkg/errors
|
- package: github.com/pkg/errors
|
||||||
version: v0.8.0
|
version: v0.8.0
|
||||||
- package: github.com/rancher/norman
|
- package: github.com/rancher/norman
|
||||||
version: 816007443daf04e96c7806c2a637dfab8ede9429
|
version: f75e3607e96e1a5d3cbaf4ee7cea1459cc727f61
|
||||||
repo: https://github.com/ibuildthecloud/norman.git
|
repo: https://github.com/ibuildthecloud/norman.git
|
||||||
- package: github.com/seccomp/libseccomp-golang
|
- package: github.com/seccomp/libseccomp-golang
|
||||||
version: 32f571b70023028bd57d9288c20efbcb237f3ce0
|
version: 32f571b70023028bd57d9288c20efbcb237f3ce0
|
||||||
@ -159,141 +159,141 @@ import:
|
|||||||
repo: https://github.com/rancher/k3s.git
|
repo: https://github.com/rancher/k3s.git
|
||||||
transitive: true
|
transitive: true
|
||||||
staging: true
|
staging: true
|
||||||
- package: github.com/euank/go-kmsg-parser
|
|
||||||
version: v2.0.0
|
|
||||||
- package: github.com/shurcooL/sanitized_anchor_name
|
|
||||||
version: 10ef21a441db47d8b13ebcc5fd2310f636973c77
|
|
||||||
- package: vbom.ml/util
|
|
||||||
version: db5cfe13f5cc80a4990d98e2e1b0707a4d1a5394
|
|
||||||
- package: github.com/MakeNowJust/heredoc
|
|
||||||
version: bb23615498cded5e105af4ce27de75b089cbe851
|
|
||||||
- package: github.com/exponent-io/jsonpath
|
|
||||||
version: d6023ce2651d8eafb5c75bb0c7167536102ec9f5
|
|
||||||
- package: github.com/ibuildthecloud/kvsql
|
|
||||||
version: c649f12fe5250718e4e024b8b40e7de796ab095e
|
|
||||||
- package: github.com/prometheus/client_golang
|
|
||||||
version: v0.8.0-83-ge7e903064f5e9e
|
|
||||||
- package: github.com/spf13/pflag
|
|
||||||
version: v1.0.1
|
|
||||||
- package: github.com/googleapis/gnostic
|
|
||||||
version: 0c5108395e2debce0d731cf0287ddf7242066aba
|
|
||||||
- package: github.com/fatih/camelcase
|
|
||||||
version: f6a740d52f961c60348ebb109adde9f4635d7540
|
|
||||||
- package: github.com/mxk/go-flowrate
|
- package: github.com/mxk/go-flowrate
|
||||||
version: cca7078d478f8520f85629ad7c68962d31ed7682
|
version: cca7078d478f8520f85629ad7c68962d31ed7682
|
||||||
- package: github.com/coreos/go-semver
|
|
||||||
version: v0.2.0-9-ge214231b295a8e
|
|
||||||
- package: github.com/docker/docker
|
|
||||||
version: docs-v1.12.0-rc4-2016-07-15-9510-ga9fbbdc8dd8794
|
|
||||||
- package: github.com/JeffAshton/win_pdh
|
- package: github.com/JeffAshton/win_pdh
|
||||||
version: 76bb4ee9f0ab50f77826f2a2ee7fb9d3880d6ec2
|
version: 76bb4ee9f0ab50f77826f2a2ee7fb9d3880d6ec2
|
||||||
- package: github.com/miekg/dns
|
- package: github.com/inconshreveable/mousetrap
|
||||||
version: 5d001d020961ae1c184f9f8152fdc73810481677
|
version: v1.0
|
||||||
- package: github.com/prometheus/procfs
|
- package: github.com/mistifyio/go-zfs
|
||||||
version: 65c1f6f8f0fc1e2185eb9863a3bc751496404259
|
version: v2.1.1-5-g1b4ae6fb4e77b0
|
||||||
- package: github.com/Azure/go-ansiterm
|
- package: github.com/Azure/go-ansiterm
|
||||||
version: d6e3b3328b783f23731bc4d058875b0371ff8109
|
version: d6e3b3328b783f23731bc4d058875b0371ff8109
|
||||||
- package: k8s.io/klog
|
- package: github.com/docker/go-connections
|
||||||
version: 8139d8cb77af419532b33dfa7dd09fbc5f1d344f
|
version: v0.3.0
|
||||||
- package: github.com/gregjones/httpcache
|
- package: k8s.io/gengo
|
||||||
version: 787624de3eb7bd915c329cba748687a3b22666a6
|
version: 51747d6e00da1fc578d5a333a93bb2abcbce7a95
|
||||||
- package: github.com/coreos/pkg
|
|
||||||
version: v4
|
|
||||||
- package: github.com/daviddengcn/go-colortext
|
|
||||||
version: 511bcaf42ccd42c38aba7427b6673277bf19e2a1
|
|
||||||
- package: github.com/robfig/cron
|
- package: github.com/robfig/cron
|
||||||
version: v1-53-gdf38d32658d878
|
version: v1-53-gdf38d32658d878
|
||||||
- package: github.com/hashicorp/golang-lru
|
|
||||||
version: a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
|
|
||||||
- package: github.com/jonboulle/clockwork
|
|
||||||
version: 72f9bd7c4e0c2a40055ab3d0f09654f730cce982
|
|
||||||
- package: github.com/prometheus/client_model
|
|
||||||
version: model-0.0.2-12-gfa8ad6fec33561
|
|
||||||
- package: gopkg.in/natefinch/lumberjack.v2
|
|
||||||
version: v1.0-16-g20b71e5b60d756
|
|
||||||
- package: github.com/mrunalp/fileutils
|
|
||||||
version: 4ee1cc9a80582a0c75febdd5cfa779ee4361cbca
|
|
||||||
- package: github.com/vishvananda/netlink
|
|
||||||
version: b2de5d10e38ecce8607e6b438b6d174f389a004e
|
|
||||||
- package: github.com/russross/blackfriday
|
|
||||||
version: v1.4-2-g300106c228d52c
|
|
||||||
- package: github.com/cyphar/filepath-securejoin
|
|
||||||
version: v0.2.1-1-gae69057f2299fb
|
|
||||||
- package: github.com/chai2010/gettext-go
|
- package: github.com/chai2010/gettext-go
|
||||||
version: c6fed771bfd517099caf0f7a961671fa8ed08723
|
version: c6fed771bfd517099caf0f7a961671fa8ed08723
|
||||||
- package: github.com/coreos/etcd
|
- package: github.com/russross/blackfriday
|
||||||
version: v3.3.10
|
version: v1.4-2-g300106c228d52c
|
||||||
- package: github.com/docker/libnetwork
|
- package: bitbucket.org/ww/goautoneg
|
||||||
version: v0.8.0-dev.2-1265-ga9cd636e378982
|
version: a547fc61f48d567d5b4ec6f8aee5573d8efce11d
|
||||||
- package: github.com/google/cadvisor
|
repo: https://github.com/rancher/goautoneg.git
|
||||||
version: 87e237ff35b9d752ba58860a06e0ebe57816cbb7
|
- package: github.com/coreos/go-semver
|
||||||
repo: https://github.com/ibuildthecloud/cadvisor.git
|
version: v0.2.0-9-ge214231b295a8e
|
||||||
|
- package: github.com/mindprince/gonvml
|
||||||
|
version: fee913ce8fb235edf54739d259ca0ecc226c7b8a
|
||||||
|
- package: github.com/spf13/pflag
|
||||||
|
version: v1.0.1
|
||||||
|
- package: github.com/euank/go-kmsg-parser
|
||||||
|
version: v2.0.0
|
||||||
|
- package: github.com/fsnotify/fsnotify
|
||||||
|
version: v1.3.1-1-gf12c6236fe7b5c
|
||||||
|
- package: github.com/prometheus/common
|
||||||
|
version: 13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207
|
||||||
- package: github.com/google/certificate-transparency-go
|
- package: github.com/google/certificate-transparency-go
|
||||||
version: v1.0.21
|
version: v1.0.21
|
||||||
- package: golang.org/x/tools
|
- package: golang.org/x/tools
|
||||||
version: 2382e3994d48b1d22acc2c86bcad0a2aff028e32
|
version: 2382e3994d48b1d22acc2c86bcad0a2aff028e32
|
||||||
- package: github.com/docker/go-units
|
- package: vbom.ml/util
|
||||||
version: v0.3.1-11-g9e638d38cf6977
|
version: db5cfe13f5cc80a4990d98e2e1b0707a4d1a5394
|
||||||
- package: github.com/armon/circbuf
|
- package: github.com/google/cadvisor
|
||||||
version: bbbad097214e2918d8543d5201d12bfd7bca254d
|
version: 87e237ff35b9d752ba58860a06e0ebe57816cbb7
|
||||||
- package: github.com/spf13/cobra
|
repo: https://github.com/ibuildthecloud/cadvisor.git
|
||||||
version: v0.0.1-34-gc439c4fa093711
|
- package: github.com/hashicorp/golang-lru
|
||||||
- package: github.com/docker/go-connections
|
version: a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
|
||||||
version: v0.3.0
|
|
||||||
- package: github.com/golang/groupcache
|
|
||||||
version: 02826c3e79038b59d737d3b1c0a1d937f71a4433
|
|
||||||
- package: github.com/google/btree
|
|
||||||
version: 7d79101e329e5a3adf994758c578dab82b90c017
|
|
||||||
- package: github.com/sigma/go-inotify
|
|
||||||
version: c87b6cf5033d2c6486046f045eeebdc3d910fd38
|
|
||||||
- package: bitbucket.org/ww/goautoneg
|
|
||||||
version: a547fc61f48d567d5b4ec6f8aee5573d8efce11d
|
|
||||||
repo: https://github.com/rancher/goautoneg.git
|
|
||||||
- package: github.com/mitchellh/go-wordwrap
|
|
||||||
version: ad45545899c7b13c020ea92b2072220eefad42b8
|
|
||||||
- package: k8s.io/utils
|
|
||||||
version: 66066c83e385e385ccc3c964b44fd7dcd413d0ed
|
|
||||||
- package: sigs.k8s.io/yaml
|
|
||||||
version: v1.1.0
|
|
||||||
- package: github.com/inconshreveable/mousetrap
|
|
||||||
version: v1.0
|
|
||||||
- package: github.com/cloudflare/cfssl
|
- package: github.com/cloudflare/cfssl
|
||||||
version: 1.3.2-21-g56268a613adfed
|
version: 1.3.2-21-g56268a613adfed
|
||||||
- package: github.com/renstrom/dedent
|
- package: github.com/docker/libnetwork
|
||||||
version: v1.0.0-3-g020d11c3b9c0c7
|
version: v0.8.0-dev.2-1265-ga9cd636e378982
|
||||||
- package: k8s.io/heapster
|
- package: github.com/prometheus/client_golang
|
||||||
version: v1.2.0-beta.1
|
version: v0.8.0-83-ge7e903064f5e9e
|
||||||
- package: github.com/mistifyio/go-zfs
|
- package: sigs.k8s.io/yaml
|
||||||
version: v2.1.1-5-g1b4ae6fb4e77b0
|
version: v1.1.0
|
||||||
- package: github.com/pborman/uuid
|
|
||||||
version: ca53cad383cad2479bbba7f7a1a05797ec1386e4
|
|
||||||
- package: github.com/prometheus/common
|
|
||||||
version: 13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207
|
|
||||||
- package: gopkg.in/square/go-jose.v2
|
|
||||||
version: v2.1.6-4-g89060dee6a84df
|
|
||||||
- package: github.com/container-storage-interface/spec
|
|
||||||
version: v1.0.0
|
|
||||||
- package: github.com/fsnotify/fsnotify
|
|
||||||
version: v1.3.1-1-gf12c6236fe7b5c
|
|
||||||
- package: github.com/evanphx/json-patch
|
|
||||||
version: v4.1.0-19-g5858425f75500d
|
|
||||||
- package: github.com/peterbourgon/diskv
|
|
||||||
version: v2.0.1
|
|
||||||
- package: github.com/ugorji/go
|
|
||||||
version: bdcc60b419d136a85cdf2e7cbcac34b3f1cd6e57
|
|
||||||
- package: github.com/imdario/mergo
|
|
||||||
version: v0.3.5
|
|
||||||
- package: github.com/karrick/godirwalk
|
|
||||||
version: v1.7.5
|
|
||||||
- package: github.com/mindprince/gonvml
|
|
||||||
version: fee913ce8fb235edf54739d259ca0ecc226c7b8a
|
|
||||||
- package: github.com/vishvananda/netns
|
|
||||||
version: be1fbeda19366dea804f00efff2dd73a1642fdcc
|
|
||||||
- package: k8s.io/gengo
|
|
||||||
version: 51747d6e00da1fc578d5a333a93bb2abcbce7a95
|
|
||||||
- package: github.com/Nvveen/Gotty
|
- package: github.com/Nvveen/Gotty
|
||||||
version: cd527374f1e5bff4938207604a14f2e38a9cf512
|
version: cd527374f1e5bff4938207604a14f2e38a9cf512
|
||||||
- package: github.com/mattn/go-shellwords
|
- package: github.com/mattn/go-shellwords
|
||||||
version: v1.0.3-20-gf8471b0a71ded0
|
version: v1.0.3-20-gf8471b0a71ded0
|
||||||
|
- package: github.com/gregjones/httpcache
|
||||||
|
version: 787624de3eb7bd915c329cba748687a3b22666a6
|
||||||
|
- package: github.com/imdario/mergo
|
||||||
|
version: v0.3.5
|
||||||
|
- package: github.com/karrick/godirwalk
|
||||||
|
version: v1.7.5
|
||||||
|
- package: github.com/mitchellh/go-wordwrap
|
||||||
|
version: ad45545899c7b13c020ea92b2072220eefad42b8
|
||||||
|
- package: github.com/google/btree
|
||||||
|
version: 7d79101e329e5a3adf994758c578dab82b90c017
|
||||||
|
- package: github.com/armon/circbuf
|
||||||
|
version: bbbad097214e2918d8543d5201d12bfd7bca254d
|
||||||
|
- package: github.com/prometheus/procfs
|
||||||
|
version: 65c1f6f8f0fc1e2185eb9863a3bc751496404259
|
||||||
|
- package: github.com/googleapis/gnostic
|
||||||
|
version: 0c5108395e2debce0d731cf0287ddf7242066aba
|
||||||
|
- package: github.com/peterbourgon/diskv
|
||||||
|
version: v2.0.1
|
||||||
|
- package: github.com/vishvananda/netns
|
||||||
|
version: be1fbeda19366dea804f00efff2dd73a1642fdcc
|
||||||
|
- package: github.com/evanphx/json-patch
|
||||||
|
version: v4.1.0-19-g5858425f75500d
|
||||||
|
- package: github.com/spf13/cobra
|
||||||
|
version: v0.0.1-34-gc439c4fa093711
|
||||||
|
- package: github.com/ugorji/go
|
||||||
|
version: bdcc60b419d136a85cdf2e7cbcac34b3f1cd6e57
|
||||||
|
- package: github.com/miekg/dns
|
||||||
|
version: 5d001d020961ae1c184f9f8152fdc73810481677
|
||||||
|
- package: github.com/vishvananda/netlink
|
||||||
|
version: b2de5d10e38ecce8607e6b438b6d174f389a004e
|
||||||
|
- package: github.com/container-storage-interface/spec
|
||||||
|
version: v1.0.0
|
||||||
- package: github.com/jteeuwen/go-bindata
|
- package: github.com/jteeuwen/go-bindata
|
||||||
version: v3.0.7-72-ga0ff2567cfb709
|
version: v3.0.7-72-ga0ff2567cfb709
|
||||||
|
- package: github.com/shurcooL/sanitized_anchor_name
|
||||||
|
version: 10ef21a441db47d8b13ebcc5fd2310f636973c77
|
||||||
|
- package: github.com/golang/groupcache
|
||||||
|
version: 02826c3e79038b59d737d3b1c0a1d937f71a4433
|
||||||
|
- package: github.com/mrunalp/fileutils
|
||||||
|
version: 4ee1cc9a80582a0c75febdd5cfa779ee4361cbca
|
||||||
|
- package: github.com/prometheus/client_model
|
||||||
|
version: model-0.0.2-12-gfa8ad6fec33561
|
||||||
|
- package: github.com/exponent-io/jsonpath
|
||||||
|
version: d6023ce2651d8eafb5c75bb0c7167536102ec9f5
|
||||||
|
- package: github.com/MakeNowJust/heredoc
|
||||||
|
version: bb23615498cded5e105af4ce27de75b089cbe851
|
||||||
|
- package: github.com/coreos/etcd
|
||||||
|
version: v3.3.10
|
||||||
|
- package: github.com/fatih/camelcase
|
||||||
|
version: f6a740d52f961c60348ebb109adde9f4635d7540
|
||||||
|
- package: github.com/docker/docker
|
||||||
|
version: docs-v1.12.0-rc4-2016-07-15-9510-ga9fbbdc8dd8794
|
||||||
|
- package: gopkg.in/natefinch/lumberjack.v2
|
||||||
|
version: v1.0-16-g20b71e5b60d756
|
||||||
|
- package: gopkg.in/square/go-jose.v2
|
||||||
|
version: v2.1.6-4-g89060dee6a84df
|
||||||
|
- package: github.com/coreos/pkg
|
||||||
|
version: v4
|
||||||
|
- package: github.com/sigma/go-inotify
|
||||||
|
version: c87b6cf5033d2c6486046f045eeebdc3d910fd38
|
||||||
|
- package: github.com/cyphar/filepath-securejoin
|
||||||
|
version: v0.2.1-1-gae69057f2299fb
|
||||||
|
- package: github.com/renstrom/dedent
|
||||||
|
version: v1.0.0-3-g020d11c3b9c0c7
|
||||||
|
- package: k8s.io/heapster
|
||||||
|
version: v1.2.0-beta.1
|
||||||
|
- package: github.com/docker/go-units
|
||||||
|
version: v0.3.1-11-g9e638d38cf6977
|
||||||
|
- package: github.com/ibuildthecloud/kvsql
|
||||||
|
version: c649f12fe5250718e4e024b8b40e7de796ab095e
|
||||||
|
- package: github.com/jonboulle/clockwork
|
||||||
|
version: 72f9bd7c4e0c2a40055ab3d0f09654f730cce982
|
||||||
|
- package: k8s.io/klog
|
||||||
|
version: 8139d8cb77af419532b33dfa7dd09fbc5f1d344f
|
||||||
|
- package: github.com/daviddengcn/go-colortext
|
||||||
|
version: 511bcaf42ccd42c38aba7427b6673277bf19e2a1
|
||||||
|
- package: k8s.io/utils
|
||||||
|
version: 66066c83e385e385ccc3c964b44fd7dcd413d0ed
|
||||||
|
- package: github.com/pborman/uuid
|
||||||
|
version: ca53cad383cad2479bbba7f7a1a05797ec1386e4
|
||||||
|
@ -11,7 +11,7 @@ package=github.com/opencontainers/runc/contrib/cmd/recvtty
|
|||||||
|
|
||||||
k8s.io/kubernetes v1.13.4-k3s.1 https://github.com/rancher/k3s.git transitive=true,staging=true
|
k8s.io/kubernetes v1.13.4-k3s.1 https://github.com/rancher/k3s.git transitive=true,staging=true
|
||||||
|
|
||||||
github.com/rancher/norman 816007443daf04e96c7806c2a637dfab8ede9429 https://github.com/ibuildthecloud/norman.git
|
github.com/rancher/norman f75e3607e96e1a5d3cbaf4ee7cea1459cc727f61 https://github.com/ibuildthecloud/norman.git
|
||||||
github.com/coreos/flannel 823afe66b2266bf71f5bec24e6e28b26d70cfc7c https://github.com/ibuildthecloud/flannel.git
|
github.com/coreos/flannel 823afe66b2266bf71f5bec24e6e28b26d70cfc7c https://github.com/ibuildthecloud/flannel.git
|
||||||
github.com/natefinch/lumberjack aee4629129445bbdfb69aa565537dcfa16544311
|
github.com/natefinch/lumberjack aee4629129445bbdfb69aa565537dcfa16544311
|
||||||
github.com/gorilla/mux v1.6.2
|
github.com/gorilla/mux v1.6.2
|
||||||
|
5
vendor/github.com/rancher/norman/build.go
generated
vendored
5
vendor/github.com/rancher/norman/build.go
generated
vendored
@ -82,10 +82,6 @@ func (c *Config) Build(ctx context.Context, opts *Options) (context.Context, *Se
|
|||||||
return ctx, nil, err
|
return ctx, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !opts.DisableControllers {
|
|
||||||
go c.masterControllers(ctx, starters, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.EnableAPI {
|
if c.EnableAPI {
|
||||||
if err := c.apiServer(ctx, r); err != nil {
|
if err := c.apiServer(ctx, r); err != nil {
|
||||||
return ctx, nil, err
|
return ctx, nil, err
|
||||||
@ -100,6 +96,7 @@ func (c *Config) Build(ctx context.Context, opts *Options) (context.Context, *Se
|
|||||||
|
|
||||||
if !opts.DisableControllers {
|
if !opts.DisableControllers {
|
||||||
err = controller.SyncThenStart(ctx, c.Threadiness, starters...)
|
err = controller.SyncThenStart(ctx, c.Threadiness, starters...)
|
||||||
|
go c.masterControllers(ctx, starters, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx, server, err
|
return ctx, server, err
|
||||||
|
1
vendor/github.com/rancher/norman/objectclient/object_client.go
generated
vendored
1
vendor/github.com/rancher/norman/objectclient/object_client.go
generated
vendored
@ -293,6 +293,7 @@ func (p *ObjectClient) Patch(name string, o runtime.Object, patchType types.Patc
|
|||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
return result, errors.New("object missing name")
|
return result, errors.New("object missing name")
|
||||||
}
|
}
|
||||||
|
logrus.Debugf("REST PATCH %s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, p.ns, name)
|
||||||
err := p.restClient.Patch(patchType).
|
err := p.restClient.Patch(patchType).
|
||||||
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(ns, p.resource.Namespaced).
|
NamespaceIfScoped(ns, p.resource.Namespaced).
|
||||||
|
7
vendor/github.com/rancher/norman/pkg/objectset/desiredset.go
generated
vendored
7
vendor/github.com/rancher/norman/pkg/objectset/desiredset.go
generated
vendored
@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
type DesiredSet struct {
|
type DesiredSet struct {
|
||||||
discoveredClients map[schema.GroupVersionKind]*objectclient.ObjectClient
|
discoveredClients map[schema.GroupVersionKind]*objectclient.ObjectClient
|
||||||
|
namespaced map[schema.GroupVersionKind]bool
|
||||||
discovery discovery.DiscoveryInterface
|
discovery discovery.DiscoveryInterface
|
||||||
restConfig rest.Config
|
restConfig rest.Config
|
||||||
remove bool
|
remove bool
|
||||||
@ -25,11 +26,15 @@ type DesiredSet struct {
|
|||||||
errs []error
|
errs []error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *DesiredSet) AddDiscoveredClient(gvk schema.GroupVersionKind, client *objectclient.ObjectClient) {
|
func (o *DesiredSet) AddDiscoveredClient(gvk schema.GroupVersionKind, client *objectclient.ObjectClient, namespaced bool) {
|
||||||
if o.discoveredClients == nil {
|
if o.discoveredClients == nil {
|
||||||
o.discoveredClients = map[schema.GroupVersionKind]*objectclient.ObjectClient{}
|
o.discoveredClients = map[schema.GroupVersionKind]*objectclient.ObjectClient{}
|
||||||
}
|
}
|
||||||
o.discoveredClients[gvk] = client
|
o.discoveredClients[gvk] = client
|
||||||
|
if o.namespaced == nil {
|
||||||
|
o.namespaced = map[schema.GroupVersionKind]bool{}
|
||||||
|
}
|
||||||
|
o.namespaced[gvk] = namespaced
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *DesiredSet) DiscoveredClients() map[schema.GroupVersionKind]*objectclient.ObjectClient {
|
func (o *DesiredSet) DiscoveredClients() map[schema.GroupVersionKind]*objectclient.ObjectClient {
|
||||||
|
50
vendor/github.com/rancher/norman/pkg/objectset/desiredset_process.go
generated
vendored
50
vendor/github.com/rancher/norman/pkg/objectset/desiredset_process.go
generated
vendored
@ -25,6 +25,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
defaultNamespace = "default"
|
||||||
deletePolicy = v1.DeletePropagationBackground
|
deletePolicy = v1.DeletePropagationBackground
|
||||||
ErrReplace = errors.New("replace object with changes")
|
ErrReplace = errors.New("replace object with changes")
|
||||||
ReplaceOnChange = func(name string, o runtime.Object, patchType types2.PatchType, data []byte, subresources ...string) (runtime.Object, error) {
|
ReplaceOnChange = func(name string, o runtime.Object, patchType types2.PatchType, data []byte, subresources ...string) (runtime.Object, error) {
|
||||||
@ -32,10 +33,10 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewDiscoveredClient(gvk schema.GroupVersionKind, restConfig rest.Config, discovery discovery.DiscoveryInterface) (*objectclient.ObjectClient, error) {
|
func NewDiscoveredClient(gvk schema.GroupVersionKind, restConfig rest.Config, discovery discovery.DiscoveryInterface) (*objectclient.ObjectClient, bool, error) {
|
||||||
resources, err := discovery.ServerResourcesForGroupVersion(gvk.GroupVersion().String())
|
resources, err := discovery.ServerResourcesForGroupVersion(gvk.GroupVersion().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, resource := range resources.APIResources {
|
for _, resource := range resources.APIResources {
|
||||||
@ -49,14 +50,14 @@ func NewDiscoveredClient(gvk schema.GroupVersionKind, restConfig rest.Config, di
|
|||||||
|
|
||||||
restClient, err := restwatch.UnversionedRESTClientFor(&restConfig)
|
restClient, err := restwatch.UnversionedRESTClientFor(&restConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
objectClient := objectclient.NewObjectClient("", restClient, &resource, gvk, &objectclient.UnstructuredObjectFactory{})
|
objectClient := objectclient.NewObjectClient("", restClient, &resource, gvk, &objectclient.UnstructuredObjectFactory{})
|
||||||
return objectClient, nil
|
return objectClient, resource.Namespaced, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("failed to discover client for %s", gvk)
|
return nil, false, fmt.Errorf("failed to discover client for %s", gvk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *DesiredSet) getControllerAndObjectClient(debugID string, gvk schema.GroupVersionKind) (controller.GenericController, *objectclient.ObjectClient, error) {
|
func (o *DesiredSet) getControllerAndObjectClient(debugID string, gvk schema.GroupVersionKind) (controller.GenericController, *objectclient.ObjectClient, error) {
|
||||||
@ -74,15 +75,42 @@ func (o *DesiredSet) getControllerAndObjectClient(debugID string, gvk schema.Gro
|
|||||||
return nil, objectClient, nil
|
return nil, objectClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
objectClient, err := NewDiscoveredClient(gvk, o.restConfig, o.discovery)
|
objectClient, namespaced, err := NewDiscoveredClient(gvk, o.restConfig, o.discovery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrapf(err, "failed to find client for %s for %s", gvk, debugID)
|
return nil, nil, errors.Wrapf(err, "failed to find client for %s for %s", gvk, debugID)
|
||||||
}
|
}
|
||||||
|
|
||||||
o.AddDiscoveredClient(gvk, objectClient)
|
o.AddDiscoveredClient(gvk, objectClient, namespaced)
|
||||||
return nil, objectClient, nil
|
return nil, objectClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *DesiredSet) adjustNamespace(gvk schema.GroupVersionKind, objs map[objectKey]runtime.Object) error {
|
||||||
|
namespaced, ok := o.namespaced[gvk]
|
||||||
|
if !ok || !namespaced {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range objs {
|
||||||
|
if k.namespace != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
v = v.DeepCopyObject()
|
||||||
|
meta, err := meta.Accessor(v)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
meta.SetNamespace(defaultNamespace)
|
||||||
|
|
||||||
|
delete(objs, k)
|
||||||
|
k.namespace = defaultNamespace
|
||||||
|
objs[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (o *DesiredSet) process(inputID, debugID string, set labels.Selector, gvk schema.GroupVersionKind, objs map[objectKey]runtime.Object) {
|
func (o *DesiredSet) process(inputID, debugID string, set labels.Selector, gvk schema.GroupVersionKind, objs map[objectKey]runtime.Object) {
|
||||||
controller, objectClient, err := o.getControllerAndObjectClient(debugID, gvk)
|
controller, objectClient, err := o.getControllerAndObjectClient(debugID, gvk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -90,6 +118,11 @@ func (o *DesiredSet) process(inputID, debugID string, set labels.Selector, gvk s
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := o.adjustNamespace(gvk, objs); err != nil {
|
||||||
|
o.err(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
patcher, ok := o.patchers[gvk]
|
patcher, ok := o.patchers[gvk]
|
||||||
if !ok {
|
if !ok {
|
||||||
patcher = objectClient.Patch
|
patcher = objectClient.Patch
|
||||||
@ -224,7 +257,8 @@ func list(controller controller.GenericController, objectClient *objectclient.Ob
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, obj := range list.Items {
|
for _, obj := range list.Items {
|
||||||
if err := addObjectToMap(objs, &obj); err != nil {
|
copy := obj
|
||||||
|
if err := addObjectToMap(objs, ©); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user