id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
131,700
weaveworks/flux
remote/rpc/compat.go
listServicesRolloutStatus
func listServicesRolloutStatus(ss []v6.ControllerStatus) { for i := range ss { // Polyfill for daemons that list pod information in status ('X out of N updated') if n, _ := fmt.Sscanf(ss[i].Status, "%d out of %d updated", &ss[i].Rollout.Updated, &ss[i].Rollout.Desired); n == 2 { // Daemons on an earlier version...
go
func listServicesRolloutStatus(ss []v6.ControllerStatus) { for i := range ss { // Polyfill for daemons that list pod information in status ('X out of N updated') if n, _ := fmt.Sscanf(ss[i].Status, "%d out of %d updated", &ss[i].Rollout.Updated, &ss[i].Rollout.Desired); n == 2 { // Daemons on an earlier version...
[ "func", "listServicesRolloutStatus", "(", "ss", "[", "]", "v6", ".", "ControllerStatus", ")", "{", "for", "i", ":=", "range", "ss", "{", "// Polyfill for daemons that list pod information in status ('X out of N updated')", "if", "n", ",", "_", ":=", "fmt", ".", "Ssc...
// listServicesRolloutStatus polyfills the rollout status.
[ "listServicesRolloutStatus", "polyfills", "the", "rollout", "status", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/remote/rpc/compat.go#L76-L92
131,701
weaveworks/flux
daemon/images.go
getAllowedAutomatedResources
func (d *Daemon) getAllowedAutomatedResources(ctx context.Context) (resources, error) { resources, _, err := d.getResources(ctx) if err != nil { return nil, err } result := map[flux.ResourceID]resource.Resource{} for _, resource := range resources { policies := resource.Policies() if policies.Has(policy.Aut...
go
func (d *Daemon) getAllowedAutomatedResources(ctx context.Context) (resources, error) { resources, _, err := d.getResources(ctx) if err != nil { return nil, err } result := map[flux.ResourceID]resource.Resource{} for _, resource := range resources { policies := resource.Policies() if policies.Has(policy.Aut...
[ "func", "(", "d", "*", "Daemon", ")", "getAllowedAutomatedResources", "(", "ctx", "context", ".", "Context", ")", "(", "resources", ",", "error", ")", "{", "resources", ",", "_", ",", "err", ":=", "d", ".", "getResources", "(", "ctx", ")", "\n", "if", ...
// getAllowedAutomatedResources returns all the resources that are // automated but do not have policies set to restrain them from // getting updated.
[ "getAllowedAutomatedResources", "returns", "all", "the", "resources", "that", "are", "automated", "but", "do", "not", "have", "policies", "set", "to", "restrain", "them", "from", "getting", "updated", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/images.go#L63-L77
131,702
weaveworks/flux
integrations/helm/helm.go
newClient
func newClient(kubeClient *kubernetes.Clientset, opts TillerOptions) (*k8shelm.Client, string, error) { host, err := tillerHost(kubeClient, opts) if err != nil { return &k8shelm.Client{}, "", err } //host = "tiller-deploy.kube-system:44134" options := []k8shelm.Option{k8shelm.Host(host)} if opts.TLSVerify || ...
go
func newClient(kubeClient *kubernetes.Clientset, opts TillerOptions) (*k8shelm.Client, string, error) { host, err := tillerHost(kubeClient, opts) if err != nil { return &k8shelm.Client{}, "", err } //host = "tiller-deploy.kube-system:44134" options := []k8shelm.Option{k8shelm.Host(host)} if opts.TLSVerify || ...
[ "func", "newClient", "(", "kubeClient", "*", "kubernetes", ".", "Clientset", ",", "opts", "TillerOptions", ")", "(", "*", "k8shelm", ".", "Client", ",", "string", ",", "error", ")", "{", "host", ",", "err", ":=", "tillerHost", "(", "kubeClient", ",", "op...
// newClient creates a new helm client
[ "newClient", "creates", "a", "new", "helm", "client" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/helm.go#L39-L69
131,703
weaveworks/flux
integrations/helm/helm.go
GetTillerVersion
func GetTillerVersion(cl *k8shelm.Client, h string) (string, error) { var v *rls.GetVersionResponse var err error voption := k8shelm.VersionOption(k8shelm.Host(h)) if v, err = cl.GetVersion(voption); err != nil { return "", fmt.Errorf("error getting tiller version: %v", err) } return v.GetVersion().String(), n...
go
func GetTillerVersion(cl *k8shelm.Client, h string) (string, error) { var v *rls.GetVersionResponse var err error voption := k8shelm.VersionOption(k8shelm.Host(h)) if v, err = cl.GetVersion(voption); err != nil { return "", fmt.Errorf("error getting tiller version: %v", err) } return v.GetVersion().String(), n...
[ "func", "GetTillerVersion", "(", "cl", "*", "k8shelm", ".", "Client", ",", "h", "string", ")", "(", "string", ",", "error", ")", "{", "var", "v", "*", "rls", ".", "GetVersionResponse", "\n", "var", "err", "error", "\n", "voption", ":=", "k8shelm", ".",...
// GetTillerVersion retrieves tiller version
[ "GetTillerVersion", "retrieves", "tiller", "version" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/helm.go#L95-L104
131,704
weaveworks/flux
integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go
V1alpha2
func (g *group) V1alpha2() v1alpha2.Interface { return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) }
go
func (g *group) V1alpha2() v1alpha2.Interface { return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) }
[ "func", "(", "g", "*", "group", ")", "V1alpha2", "(", ")", "v1alpha2", ".", "Interface", "{", "return", "v1alpha2", ".", "New", "(", "g", ".", "factory", ",", "g", ".", "namespace", ",", "g", ".", "tweakListOptions", ")", "\n", "}" ]
// V1alpha2 returns a new v1alpha2.Interface.
[ "V1alpha2", "returns", "a", "new", "v1alpha2", ".", "Interface", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go#L44-L46
131,705
weaveworks/flux
integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go
NewHelmReleaseInformer
func NewHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { return NewFilteredHelmReleaseInformer(client, namespace, resyncPeriod, indexers, nil) }
go
func NewHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { return NewFilteredHelmReleaseInformer(client, namespace, resyncPeriod, indexers, nil) }
[ "func", "NewHelmReleaseInformer", "(", "client", "versioned", ".", "Interface", ",", "namespace", "string", ",", "resyncPeriod", "time", ".", "Duration", ",", "indexers", "cache", ".", "Indexers", ")", "cache", ".", "SharedIndexInformer", "{", "return", "NewFilter...
// NewHelmReleaseInformer constructs a new informer for HelmRelease type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server.
[ "NewHelmReleaseInformer", "constructs", "a", "new", "informer", "for", "HelmRelease", "type", ".", "Always", "prefer", "using", "an", "informer", "factory", "to", "get", "a", "shared", "informer", "instead", "of", "getting", "an", "independent", "one", ".", "Thi...
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go#L50-L52
131,706
weaveworks/flux
integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go
NewFilteredHelmReleaseInformer
func NewFilteredHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options v1.ListOptions)...
go
func NewFilteredHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options v1.ListOptions)...
[ "func", "NewFilteredHelmReleaseInformer", "(", "client", "versioned", ".", "Interface", ",", "namespace", "string", ",", "resyncPeriod", "time", ".", "Duration", ",", "indexers", "cache", ".", "Indexers", ",", "tweakListOptions", "internalinterfaces", ".", "TweakListO...
// NewFilteredHelmReleaseInformer constructs a new informer for HelmRelease type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server.
[ "NewFilteredHelmReleaseInformer", "constructs", "a", "new", "informer", "for", "HelmRelease", "type", ".", "Always", "prefer", "using", "an", "informer", "factory", "to", "get", "a", "shared", "informer", "instead", "of", "getting", "an", "independent", "one", "."...
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go#L57-L77
131,707
weaveworks/flux
git/repo.go
NewRepo
func NewRepo(origin Remote, opts ...Option) *Repo { status := RepoNew if origin.URL == "" { status = RepoNoConfig } r := &Repo{ origin: origin, status: status, interval: defaultInterval, timeout: defaultTimeout, err: ErrNotCloned, notify: make(chan struct{}, 1), // `1` so that Notify doesn...
go
func NewRepo(origin Remote, opts ...Option) *Repo { status := RepoNew if origin.URL == "" { status = RepoNoConfig } r := &Repo{ origin: origin, status: status, interval: defaultInterval, timeout: defaultTimeout, err: ErrNotCloned, notify: make(chan struct{}, 1), // `1` so that Notify doesn...
[ "func", "NewRepo", "(", "origin", "Remote", ",", "opts", "...", "Option", ")", "*", "Repo", "{", "status", ":=", "RepoNew", "\n", "if", "origin", ".", "URL", "==", "\"", "\"", "{", "status", "=", "RepoNoConfig", "\n", "}", "\n", "r", ":=", "&", "Re...
// NewRepo constructs a repo mirror which will sync itself.
[ "NewRepo", "constructs", "a", "repo", "mirror", "which", "will", "sync", "itself", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/repo.go#L99-L117
131,708
weaveworks/flux
git/repo.go
Origin
func (r *Repo) Origin() Remote { r.mu.RLock() defer r.mu.RUnlock() return r.origin }
go
func (r *Repo) Origin() Remote { r.mu.RLock() defer r.mu.RUnlock() return r.origin }
[ "func", "(", "r", "*", "Repo", ")", "Origin", "(", ")", "Remote", "{", "r", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "r", ".", "origin", "\n", "}" ]
// Origin returns the Remote with which the Repo was constructed.
[ "Origin", "returns", "the", "Remote", "with", "which", "the", "Repo", "was", "constructed", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/repo.go#L120-L124
131,709
weaveworks/flux
git/repo.go
Dir
func (r *Repo) Dir() string { r.mu.RLock() defer r.mu.RUnlock() return r.dir }
go
func (r *Repo) Dir() string { r.mu.RLock() defer r.mu.RUnlock() return r.dir }
[ "func", "(", "r", "*", "Repo", ")", "Dir", "(", ")", "string", "{", "r", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "r", ".", "dir", "\n", "}" ]
// Dir returns the local directory into which the repo has been // cloned, if it has been cloned.
[ "Dir", "returns", "the", "local", "directory", "into", "which", "the", "repo", "has", "been", "cloned", "if", "it", "has", "been", "cloned", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/repo.go#L128-L132
131,710
weaveworks/flux
git/repo.go
Clean
func (r *Repo) Clean() { r.mu.Lock() if r.dir != "" { os.RemoveAll(r.dir) } r.dir = "" r.status = RepoNew r.mu.Unlock() }
go
func (r *Repo) Clean() { r.mu.Lock() if r.dir != "" { os.RemoveAll(r.dir) } r.dir = "" r.status = RepoNew r.mu.Unlock() }
[ "func", "(", "r", "*", "Repo", ")", "Clean", "(", ")", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "r", ".", "dir", "!=", "\"", "\"", "{", "os", ".", "RemoveAll", "(", "r", ".", "dir", ")", "\n", "}", "\n", "r", ".", "dir", ...
// Clean removes the mirrored repo. Syncing may continue with a new // directory, so you may need to stop that first.
[ "Clean", "removes", "the", "mirrored", "repo", ".", "Syncing", "may", "continue", "with", "a", "new", "directory", "so", "you", "may", "need", "to", "stop", "that", "first", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/repo.go#L136-L144
131,711
weaveworks/flux
git/repo.go
errorIfNotReady
func (r *Repo) errorIfNotReady() error { switch r.status { case RepoReady: return nil case RepoNoConfig: return ErrNoConfig default: return NotReadyError{r.err} } }
go
func (r *Repo) errorIfNotReady() error { switch r.status { case RepoReady: return nil case RepoNoConfig: return ErrNoConfig default: return NotReadyError{r.err} } }
[ "func", "(", "r", "*", "Repo", ")", "errorIfNotReady", "(", ")", "error", "{", "switch", "r", ".", "status", "{", "case", "RepoReady", ":", "return", "nil", "\n", "case", "RepoNoConfig", ":", "return", "ErrNoConfig", "\n", "default", ":", "return", "NotR...
// errorIfNotReady returns the appropriate error if the repo is not // ready, and `nil` otherwise.
[ "errorIfNotReady", "returns", "the", "appropriate", "error", "if", "the", "repo", "is", "not", "ready", "and", "nil", "otherwise", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/repo.go#L190-L199
131,712
weaveworks/flux
git/repo.go
step
func (r *Repo) step(bg context.Context) bool { r.mu.RLock() url := r.origin.URL dir := r.dir status := r.status r.mu.RUnlock() switch status { case RepoNoConfig: // this is not going to change in the lifetime of this // process, so just exit. return false case RepoNew: rootdir, err := ioutil.TempDir(...
go
func (r *Repo) step(bg context.Context) bool { r.mu.RLock() url := r.origin.URL dir := r.dir status := r.status r.mu.RUnlock() switch status { case RepoNoConfig: // this is not going to change in the lifetime of this // process, so just exit. return false case RepoNew: rootdir, err := ioutil.TempDir(...
[ "func", "(", "r", "*", "Repo", ")", "step", "(", "bg", "context", ".", "Context", ")", "bool", "{", "r", ".", "mu", ".", "RLock", "(", ")", "\n", "url", ":=", "r", ".", "origin", ".", "URL", "\n", "dir", ":=", "r", ".", "dir", "\n", "status",...
// step attempts to advance the repo state machine, and returns `true` // if it has made progress, `false` otherwise.
[ "step", "attempts", "to", "advance", "the", "repo", "state", "machine", "and", "returns", "true", "if", "it", "has", "made", "progress", "false", "otherwise", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/repo.go#L231-L306
131,713
weaveworks/flux
git/repo.go
Ready
func (r *Repo) Ready(ctx context.Context) error { for r.step(ctx) { // keep going! } _, err := r.Status() return err }
go
func (r *Repo) Ready(ctx context.Context) error { for r.step(ctx) { // keep going! } _, err := r.Status() return err }
[ "func", "(", "r", "*", "Repo", ")", "Ready", "(", "ctx", "context", ".", "Context", ")", "error", "{", "for", "r", ".", "step", "(", "ctx", ")", "{", "// keep going!", "}", "\n", "_", ",", "err", ":=", "r", ".", "Status", "(", ")", "\n", "retur...
// Ready tries to advance the cloning process along as far as // possible, and returns an error if it is not able to get to a ready // state.
[ "Ready", "tries", "to", "advance", "the", "cloning", "process", "along", "as", "far", "as", "possible", "and", "returns", "an", "error", "if", "it", "is", "not", "able", "to", "get", "to", "a", "ready", "state", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/repo.go#L311-L317
131,714
weaveworks/flux
git/repo.go
Start
func (r *Repo) Start(shutdown <-chan struct{}, done *sync.WaitGroup) error { defer done.Done() for { ctx, cancel := context.WithTimeout(context.Background(), r.timeout) advanced := r.step(ctx) cancel() if advanced { continue } status, _ := r.Status() if status == RepoReady { if err := r.refresh...
go
func (r *Repo) Start(shutdown <-chan struct{}, done *sync.WaitGroup) error { defer done.Done() for { ctx, cancel := context.WithTimeout(context.Background(), r.timeout) advanced := r.step(ctx) cancel() if advanced { continue } status, _ := r.Status() if status == RepoReady { if err := r.refresh...
[ "func", "(", "r", "*", "Repo", ")", "Start", "(", "shutdown", "<-", "chan", "struct", "{", "}", ",", "done", "*", "sync", ".", "WaitGroup", ")", "error", "{", "defer", "done", ".", "Done", "(", ")", "\n\n", "for", "{", "ctx", ",", "cancel", ":=",...
// Start begins synchronising the repo by cloning it, then fetching // the required tags and so on.
[ "Start", "begins", "synchronising", "the", "repo", "by", "cloning", "it", "then", "fetching", "the", "required", "tags", "and", "so", "on", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/repo.go#L321-L355
131,715
weaveworks/flux
git/repo.go
fetch
func (r *Repo) fetch(ctx context.Context) error { if err := fetch(ctx, r.dir, "origin"); err != nil { return err } return nil }
go
func (r *Repo) fetch(ctx context.Context) error { if err := fetch(ctx, r.dir, "origin"); err != nil { return err } return nil }
[ "func", "(", "r", "*", "Repo", ")", "fetch", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "err", ":=", "fetch", "(", "ctx", ",", "r", ".", "dir", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}...
// fetch gets updated refs, and associated objects, from the upstream.
[ "fetch", "gets", "updated", "refs", "and", "associated", "objects", "from", "the", "upstream", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/repo.go#L402-L407
131,716
weaveworks/flux
cmd/fluxctl/portforward.go
tryPortforwards
func tryPortforwards(ns string, selectors ...metav1.LabelSelector) (p *portforward.PortForward, err error) { message := fmt.Sprintf("No pod found in namespace %q using the following selectors:", ns) for _, selector := range selectors { p, err = tryPortforward(ns, selector) if err == nil { return } if !st...
go
func tryPortforwards(ns string, selectors ...metav1.LabelSelector) (p *portforward.PortForward, err error) { message := fmt.Sprintf("No pod found in namespace %q using the following selectors:", ns) for _, selector := range selectors { p, err = tryPortforward(ns, selector) if err == nil { return } if !st...
[ "func", "tryPortforwards", "(", "ns", "string", ",", "selectors", "...", "metav1", ".", "LabelSelector", ")", "(", "p", "*", "portforward", ".", "PortForward", ",", "err", "error", ")", "{", "message", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", ...
// Attempt to create PortForwards to fluxes that match the label selectors until a Flux // is found or an error is returned.
[ "Attempt", "to", "create", "PortForwards", "to", "fluxes", "that", "match", "the", "label", "selectors", "until", "a", "Flux", "is", "found", "or", "an", "error", "is", "returned", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/cmd/fluxctl/portforward.go#L15-L37
131,717
weaveworks/flux
cmd/fluxctl/portforward.go
tryPortforward
func tryPortforward(ns string, selector metav1.LabelSelector) (*portforward.PortForward, error) { portforwarder, err := portforward.NewPortForwarder(ns, selector, 3030) if err != nil { return portforwarder, err } err = portforwarder.Start() if err != nil { return portforwarder, err } return portforwarder, ...
go
func tryPortforward(ns string, selector metav1.LabelSelector) (*portforward.PortForward, error) { portforwarder, err := portforward.NewPortForwarder(ns, selector, 3030) if err != nil { return portforwarder, err } err = portforwarder.Start() if err != nil { return portforwarder, err } return portforwarder, ...
[ "func", "tryPortforward", "(", "ns", "string", ",", "selector", "metav1", ".", "LabelSelector", ")", "(", "*", "portforward", ".", "PortForward", ",", "error", ")", "{", "portforwarder", ",", "err", ":=", "portforward", ".", "NewPortForwarder", "(", "ns", ",...
// Attempt to create a portforward in the namespace for the provided LabelSelector
[ "Attempt", "to", "create", "a", "portforward", "in", "the", "namespace", "for", "the", "provided", "LabelSelector" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/cmd/fluxctl/portforward.go#L40-L52
131,718
weaveworks/flux
http/websocket/client.go
Dial
func Dial(client *http.Client, ua string, token client.Token, u *url.URL) (Websocket, error) { // Build the http request req, err := http.NewRequest("GET", u.String(), nil) if err != nil { return nil, errors.Wrapf(err, "constructing request %s", u) } // Send version in user-agent req.Header.Set("User-Agent", u...
go
func Dial(client *http.Client, ua string, token client.Token, u *url.URL) (Websocket, error) { // Build the http request req, err := http.NewRequest("GET", u.String(), nil) if err != nil { return nil, errors.Wrapf(err, "constructing request %s", u) } // Send version in user-agent req.Header.Set("User-Agent", u...
[ "func", "Dial", "(", "client", "*", "http", ".", "Client", ",", "ua", "string", ",", "token", "client", ".", "Token", ",", "u", "*", "url", ".", "URL", ")", "(", "Websocket", ",", "error", ")", "{", "// Build the http request", "req", ",", "err", ":=...
// Dial initiates a new websocket connection.
[ "Dial", "initiates", "a", "new", "websocket", "connection", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/http/websocket/client.go#L28-L52
131,719
weaveworks/flux
cluster/kubernetes/namespacer.go
NewNamespacer
func NewNamespacer(d discovery.DiscoveryInterface) (*namespaceViaDiscovery, error) { fallback, err := getDefaultNamespace() if err != nil { return nil, err } return &namespaceViaDiscovery{fallbackNamespace: fallback, disco: d}, nil }
go
func NewNamespacer(d discovery.DiscoveryInterface) (*namespaceViaDiscovery, error) { fallback, err := getDefaultNamespace() if err != nil { return nil, err } return &namespaceViaDiscovery{fallbackNamespace: fallback, disco: d}, nil }
[ "func", "NewNamespacer", "(", "d", "discovery", ".", "DiscoveryInterface", ")", "(", "*", "namespaceViaDiscovery", ",", "error", ")", "{", "fallback", ",", "err", ":=", "getDefaultNamespace", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// NewNamespacer creates an implementation of Namespacer
[ "NewNamespacer", "creates", "an", "implementation", "of", "Namespacer" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/cluster/kubernetes/namespacer.go#L26-L32
131,720
weaveworks/flux
cluster/kubernetes/namespacer.go
EffectiveNamespace
func (n *namespaceViaDiscovery) EffectiveNamespace(m kresource.KubeManifest, knownScopes ResourceScopes) (string, error) { namespaced, err := n.lookupNamespaced(m.GroupVersion(), m.GetKind(), knownScopes) switch { case err != nil: return "", err case namespaced && m.GetNamespace() == "": return n.fallbackNamesp...
go
func (n *namespaceViaDiscovery) EffectiveNamespace(m kresource.KubeManifest, knownScopes ResourceScopes) (string, error) { namespaced, err := n.lookupNamespaced(m.GroupVersion(), m.GetKind(), knownScopes) switch { case err != nil: return "", err case namespaced && m.GetNamespace() == "": return n.fallbackNamesp...
[ "func", "(", "n", "*", "namespaceViaDiscovery", ")", "EffectiveNamespace", "(", "m", "kresource", ".", "KubeManifest", ",", "knownScopes", "ResourceScopes", ")", "(", "string", ",", "error", ")", "{", "namespaced", ",", "err", ":=", "n", ".", "lookupNamespaced...
// effectiveNamespace yields the namespace that would be used for this // resource were it applied, taking into account the kind of the // resource, and local configuration.
[ "effectiveNamespace", "yields", "the", "namespace", "that", "would", "be", "used", "for", "this", "resource", "were", "it", "applied", "taking", "into", "account", "the", "kind", "of", "the", "resource", "and", "local", "configuration", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/cluster/kubernetes/namespacer.go#L60-L71
131,721
weaveworks/flux
cluster/kubernetes/kubernetes.go
NewCluster
func NewCluster(client ExtendedClient, applier Applier, sshKeyRing ssh.KeyRing, logger log.Logger, allowedNamespaces []string, imageExcludeList []string) *Cluster { c := &Cluster{ client: client, applier: applier, logger: logger, sshKeyRing: sshKeyRing, allowedNamespace...
go
func NewCluster(client ExtendedClient, applier Applier, sshKeyRing ssh.KeyRing, logger log.Logger, allowedNamespaces []string, imageExcludeList []string) *Cluster { c := &Cluster{ client: client, applier: applier, logger: logger, sshKeyRing: sshKeyRing, allowedNamespace...
[ "func", "NewCluster", "(", "client", "ExtendedClient", ",", "applier", "Applier", ",", "sshKeyRing", "ssh", ".", "KeyRing", ",", "logger", "log", ".", "Logger", ",", "allowedNamespaces", "[", "]", "string", ",", "imageExcludeList", "[", "]", "string", ")", "...
// NewCluster returns a usable cluster.
[ "NewCluster", "returns", "a", "usable", "cluster", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/cluster/kubernetes/kubernetes.go#L109-L121
131,722
weaveworks/flux
cluster/kubernetes/kubernetes.go
Export
func (c *Cluster) Export() ([]byte, error) { var config bytes.Buffer namespaces, err := c.getAllowedAndExistingNamespaces() if err != nil { return nil, errors.Wrap(err, "getting namespaces") } encoder := yaml.NewEncoder(&config) defer encoder.Close() for _, ns := range namespaces { // kind & apiVersion mu...
go
func (c *Cluster) Export() ([]byte, error) { var config bytes.Buffer namespaces, err := c.getAllowedAndExistingNamespaces() if err != nil { return nil, errors.Wrap(err, "getting namespaces") } encoder := yaml.NewEncoder(&config) defer encoder.Close() for _, ns := range namespaces { // kind & apiVersion mu...
[ "func", "(", "c", "*", "Cluster", ")", "Export", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "config", "bytes", ".", "Buffer", "\n\n", "namespaces", ",", "err", ":=", "c", ".", "getAllowedAndExistingNamespaces", "(", ")", "\n", "i...
// Export exports cluster resources
[ "Export", "exports", "cluster", "resources" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/cluster/kubernetes/kubernetes.go#L219-L265
131,723
weaveworks/flux
cluster/kubernetes/kubernetes.go
getAllowedAndExistingNamespaces
func (c *Cluster) getAllowedAndExistingNamespaces() ([]apiv1.Namespace, error) { if len(c.allowedNamespaces) > 0 { nsList := []apiv1.Namespace{} for _, name := range c.allowedNamespaces { ns, err := c.client.CoreV1().Namespaces().Get(name, meta_v1.GetOptions{}) switch { case err == nil: c.loggedAllowe...
go
func (c *Cluster) getAllowedAndExistingNamespaces() ([]apiv1.Namespace, error) { if len(c.allowedNamespaces) > 0 { nsList := []apiv1.Namespace{} for _, name := range c.allowedNamespaces { ns, err := c.client.CoreV1().Namespaces().Get(name, meta_v1.GetOptions{}) switch { case err == nil: c.loggedAllowe...
[ "func", "(", "c", "*", "Cluster", ")", "getAllowedAndExistingNamespaces", "(", ")", "(", "[", "]", "apiv1", ".", "Namespace", ",", "error", ")", "{", "if", "len", "(", "c", ".", "allowedNamespaces", ")", ">", "0", "{", "nsList", ":=", "[", "]", "apiv...
// getAllowedAndExistingNamespaces returns a list of existing namespaces that // the Flux instance is expected to have access to and can look for resources inside of. // It returns a list of all namespaces unless an explicit list of allowed namespaces // has been set on the Cluster instance.
[ "getAllowedAndExistingNamespaces", "returns", "a", "list", "of", "existing", "namespaces", "that", "the", "Flux", "instance", "is", "expected", "to", "have", "access", "to", "and", "can", "look", "for", "resources", "inside", "of", ".", "It", "returns", "a", "...
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/cluster/kubernetes/kubernetes.go#L281-L308
131,724
weaveworks/flux
cluster/kubernetes/images.go
ImagesToFetch
func (c *Cluster) ImagesToFetch() registry.ImageCreds { allImageCreds := make(registry.ImageCreds) namespaces, err := c.getAllowedAndExistingNamespaces() if err != nil { c.logger.Log("err", errors.Wrap(err, "getting namespaces")) return allImageCreds } for _, ns := range namespaces { seenCreds := make(map[...
go
func (c *Cluster) ImagesToFetch() registry.ImageCreds { allImageCreds := make(registry.ImageCreds) namespaces, err := c.getAllowedAndExistingNamespaces() if err != nil { c.logger.Log("err", errors.Wrap(err, "getting namespaces")) return allImageCreds } for _, ns := range namespaces { seenCreds := make(map[...
[ "func", "(", "c", "*", "Cluster", ")", "ImagesToFetch", "(", ")", "registry", ".", "ImageCreds", "{", "allImageCreds", ":=", "make", "(", "registry", ".", "ImageCreds", ")", "\n\n", "namespaces", ",", "err", ":=", "c", ".", "getAllowedAndExistingNamespaces", ...
// ImagesToFetch is a k8s specific method to get a list of images to update along with their credentials
[ "ImagesToFetch", "is", "a", "k8s", "specific", "method", "to", "get", "a", "list", "of", "images", "to", "update", "along", "with", "their", "credentials" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/cluster/kubernetes/images.go#L123-L166
131,725
weaveworks/flux
git/export.go
Export
func (r *Repo) Export(ctx context.Context, ref string) (*Export, error) { dir, err := r.workingClone(ctx, "") if err != nil { return nil, err } if err = checkout(ctx, dir, ref); err != nil { return nil, err } return &Export{dir}, nil }
go
func (r *Repo) Export(ctx context.Context, ref string) (*Export, error) { dir, err := r.workingClone(ctx, "") if err != nil { return nil, err } if err = checkout(ctx, dir, ref); err != nil { return nil, err } return &Export{dir}, nil }
[ "func", "(", "r", "*", "Repo", ")", "Export", "(", "ctx", "context", ".", "Context", ",", "ref", "string", ")", "(", "*", "Export", ",", "error", ")", "{", "dir", ",", "err", ":=", "r", ".", "workingClone", "(", "ctx", ",", "\"", "\"", ")", "\n...
// Export creates a minimal clone of the repo, at the ref given.
[ "Export", "creates", "a", "minimal", "clone", "of", "the", "repo", "at", "the", "ref", "given", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/export.go#L23-L32
131,726
weaveworks/flux
integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go
List
func (s *helmReleaseLister) List(selector labels.Selector) (ret []*v1beta1.HelmRelease, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { ret = append(ret, m.(*v1beta1.HelmRelease)) }) return ret, err }
go
func (s *helmReleaseLister) List(selector labels.Selector) (ret []*v1beta1.HelmRelease, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { ret = append(ret, m.(*v1beta1.HelmRelease)) }) return ret, err }
[ "func", "(", "s", "*", "helmReleaseLister", ")", "List", "(", "selector", "labels", ".", "Selector", ")", "(", "ret", "[", "]", "*", "v1beta1", ".", "HelmRelease", ",", "err", "error", ")", "{", "err", "=", "cache", ".", "ListAll", "(", "s", ".", "...
// List lists all HelmReleases in the indexer.
[ "List", "lists", "all", "HelmReleases", "in", "the", "indexer", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go#L48-L53
131,727
weaveworks/flux
integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go
HelmReleases
func (s *helmReleaseLister) HelmReleases(namespace string) HelmReleaseNamespaceLister { return helmReleaseNamespaceLister{indexer: s.indexer, namespace: namespace} }
go
func (s *helmReleaseLister) HelmReleases(namespace string) HelmReleaseNamespaceLister { return helmReleaseNamespaceLister{indexer: s.indexer, namespace: namespace} }
[ "func", "(", "s", "*", "helmReleaseLister", ")", "HelmReleases", "(", "namespace", "string", ")", "HelmReleaseNamespaceLister", "{", "return", "helmReleaseNamespaceLister", "{", "indexer", ":", "s", ".", "indexer", ",", "namespace", ":", "namespace", "}", "\n", ...
// HelmReleases returns an object that can list and get HelmReleases.
[ "HelmReleases", "returns", "an", "object", "that", "can", "list", "and", "get", "HelmReleases", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go#L56-L58
131,728
weaveworks/flux
integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go
List
func (s helmReleaseNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.HelmRelease, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { ret = append(ret, m.(*v1beta1.HelmRelease)) }) return ret, err }
go
func (s helmReleaseNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.HelmRelease, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { ret = append(ret, m.(*v1beta1.HelmRelease)) }) return ret, err }
[ "func", "(", "s", "helmReleaseNamespaceLister", ")", "List", "(", "selector", "labels", ".", "Selector", ")", "(", "ret", "[", "]", "*", "v1beta1", ".", "HelmRelease", ",", "err", "error", ")", "{", "err", "=", "cache", ".", "ListAllByNamespace", "(", "s...
// List lists all HelmReleases in the indexer for a given namespace.
[ "List", "lists", "all", "HelmReleases", "in", "the", "indexer", "for", "a", "given", "namespace", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go#L77-L82
131,729
weaveworks/flux
integrations/client/clientset/versioned/fake/clientset_generated.go
FluxV1beta1
func (c *Clientset) FluxV1beta1() fluxv1beta1.FluxV1beta1Interface { return &fakefluxv1beta1.FakeFluxV1beta1{Fake: &c.Fake} }
go
func (c *Clientset) FluxV1beta1() fluxv1beta1.FluxV1beta1Interface { return &fakefluxv1beta1.FakeFluxV1beta1{Fake: &c.Fake} }
[ "func", "(", "c", "*", "Clientset", ")", "FluxV1beta1", "(", ")", "fluxv1beta1", ".", "FluxV1beta1Interface", "{", "return", "&", "fakefluxv1beta1", ".", "FakeFluxV1beta1", "{", "Fake", ":", "&", "c", ".", "Fake", "}", "\n", "}" ]
// FluxV1beta1 retrieves the FluxV1beta1Client
[ "FluxV1beta1", "retrieves", "the", "FluxV1beta1Client" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/clientset/versioned/fake/clientset_generated.go#L77-L79
131,730
weaveworks/flux
integrations/client/clientset/versioned/fake/clientset_generated.go
HelmV1alpha2
func (c *Clientset) HelmV1alpha2() helmv1alpha2.HelmV1alpha2Interface { return &fakehelmv1alpha2.FakeHelmV1alpha2{Fake: &c.Fake} }
go
func (c *Clientset) HelmV1alpha2() helmv1alpha2.HelmV1alpha2Interface { return &fakehelmv1alpha2.FakeHelmV1alpha2{Fake: &c.Fake} }
[ "func", "(", "c", "*", "Clientset", ")", "HelmV1alpha2", "(", ")", "helmv1alpha2", ".", "HelmV1alpha2Interface", "{", "return", "&", "fakehelmv1alpha2", ".", "FakeHelmV1alpha2", "{", "Fake", ":", "&", "c", ".", "Fake", "}", "\n", "}" ]
// HelmV1alpha2 retrieves the HelmV1alpha2Client
[ "HelmV1alpha2", "retrieves", "the", "HelmV1alpha2Client" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/clientset/versioned/fake/clientset_generated.go#L82-L84
131,731
weaveworks/flux
integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go
List
func (s *fluxHelmReleaseLister) List(selector labels.Selector) (ret []*v1alpha2.FluxHelmRelease, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { ret = append(ret, m.(*v1alpha2.FluxHelmRelease)) }) return ret, err }
go
func (s *fluxHelmReleaseLister) List(selector labels.Selector) (ret []*v1alpha2.FluxHelmRelease, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { ret = append(ret, m.(*v1alpha2.FluxHelmRelease)) }) return ret, err }
[ "func", "(", "s", "*", "fluxHelmReleaseLister", ")", "List", "(", "selector", "labels", ".", "Selector", ")", "(", "ret", "[", "]", "*", "v1alpha2", ".", "FluxHelmRelease", ",", "err", "error", ")", "{", "err", "=", "cache", ".", "ListAll", "(", "s", ...
// List lists all FluxHelmReleases in the indexer.
[ "List", "lists", "all", "FluxHelmReleases", "in", "the", "indexer", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go#L48-L53
131,732
weaveworks/flux
integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go
FluxHelmReleases
func (s *fluxHelmReleaseLister) FluxHelmReleases(namespace string) FluxHelmReleaseNamespaceLister { return fluxHelmReleaseNamespaceLister{indexer: s.indexer, namespace: namespace} }
go
func (s *fluxHelmReleaseLister) FluxHelmReleases(namespace string) FluxHelmReleaseNamespaceLister { return fluxHelmReleaseNamespaceLister{indexer: s.indexer, namespace: namespace} }
[ "func", "(", "s", "*", "fluxHelmReleaseLister", ")", "FluxHelmReleases", "(", "namespace", "string", ")", "FluxHelmReleaseNamespaceLister", "{", "return", "fluxHelmReleaseNamespaceLister", "{", "indexer", ":", "s", ".", "indexer", ",", "namespace", ":", "namespace", ...
// FluxHelmReleases returns an object that can list and get FluxHelmReleases.
[ "FluxHelmReleases", "returns", "an", "object", "that", "can", "list", "and", "get", "FluxHelmReleases", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go#L56-L58
131,733
weaveworks/flux
integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go
List
func (s fluxHelmReleaseNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.FluxHelmRelease, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { ret = append(ret, m.(*v1alpha2.FluxHelmRelease)) }) return ret, err }
go
func (s fluxHelmReleaseNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.FluxHelmRelease, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { ret = append(ret, m.(*v1alpha2.FluxHelmRelease)) }) return ret, err }
[ "func", "(", "s", "fluxHelmReleaseNamespaceLister", ")", "List", "(", "selector", "labels", ".", "Selector", ")", "(", "ret", "[", "]", "*", "v1alpha2", ".", "FluxHelmRelease", ",", "err", "error", ")", "{", "err", "=", "cache", ".", "ListAllByNamespace", ...
// List lists all FluxHelmReleases in the indexer for a given namespace.
[ "List", "lists", "all", "FluxHelmReleases", "in", "the", "indexer", "for", "a", "given", "namespace", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go#L77-L82
131,734
weaveworks/flux
integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go
Get
func (s fluxHelmReleaseNamespaceLister) Get(name string) (*v1alpha2.FluxHelmRelease, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { return nil, errors.NewNotFound(v1alpha2.Resource("fluxhelmrelease"), name) } return obj.(*v1alpha2.FluxH...
go
func (s fluxHelmReleaseNamespaceLister) Get(name string) (*v1alpha2.FluxHelmRelease, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { return nil, errors.NewNotFound(v1alpha2.Resource("fluxhelmrelease"), name) } return obj.(*v1alpha2.FluxH...
[ "func", "(", "s", "fluxHelmReleaseNamespaceLister", ")", "Get", "(", "name", "string", ")", "(", "*", "v1alpha2", ".", "FluxHelmRelease", ",", "error", ")", "{", "obj", ",", "exists", ",", "err", ":=", "s", ".", "indexer", ".", "GetByKey", "(", "s", "....
// Get retrieves the FluxHelmRelease from the indexer for a given namespace and name.
[ "Get", "retrieves", "the", "FluxHelmRelease", "from", "the", "indexer", "for", "a", "given", "namespace", "and", "name", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go#L85-L94
131,735
weaveworks/flux
release/context.go
WorkloadsForUpdate
func (rc *ReleaseContext) WorkloadsForUpdate() (map[flux.ResourceID]*update.WorkloadUpdate, error) { resources, err := rc.LoadManifests() if err != nil { return nil, err } var defined = map[flux.ResourceID]*update.WorkloadUpdate{} for _, res := range resources { if wl, ok := res.(resource.Workload); ok { d...
go
func (rc *ReleaseContext) WorkloadsForUpdate() (map[flux.ResourceID]*update.WorkloadUpdate, error) { resources, err := rc.LoadManifests() if err != nil { return nil, err } var defined = map[flux.ResourceID]*update.WorkloadUpdate{} for _, res := range resources { if wl, ok := res.(resource.Workload); ok { d...
[ "func", "(", "rc", "*", "ReleaseContext", ")", "WorkloadsForUpdate", "(", ")", "(", "map", "[", "flux", ".", "ResourceID", "]", "*", "update", ".", "WorkloadUpdate", ",", "error", ")", "{", "resources", ",", "err", ":=", "rc", ".", "LoadManifests", "(", ...
// WorkloadsForUpdate collects all workloads defined in manifests and prepares a list of // controller updates for each of them. It does not consider updatability.
[ "WorkloadsForUpdate", "collects", "all", "workloads", "defined", "in", "manifests", "and", "prepares", "a", "list", "of", "controller", "updates", "for", "each", "of", "them", ".", "It", "does", "not", "consider", "updatability", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/release/context.go#L131-L148
131,736
weaveworks/flux
api/v6/container.go
NewContainer
func NewContainer(name string, images []image.Info, currentImage image.Info, tagPattern policy.Pattern, fields []string) (Container, error) { sorted := update.SortImages(images, tagPattern) // All images imagesCount := len(sorted) imagesErr := "" if sorted == nil { imagesErr = registry.ErrNoImageData.Error() }...
go
func NewContainer(name string, images []image.Info, currentImage image.Info, tagPattern policy.Pattern, fields []string) (Container, error) { sorted := update.SortImages(images, tagPattern) // All images imagesCount := len(sorted) imagesErr := "" if sorted == nil { imagesErr = registry.ErrNoImageData.Error() }...
[ "func", "NewContainer", "(", "name", "string", ",", "images", "[", "]", "image", ".", "Info", ",", "currentImage", "image", ".", "Info", ",", "tagPattern", "policy", ".", "Pattern", ",", "fields", "[", "]", "string", ")", "(", "Container", ",", "error", ...
// NewContainer creates a Container given a list of images and the current image
[ "NewContainer", "creates", "a", "Container", "given", "a", "list", "of", "images", "and", "the", "current", "image" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/api/v6/container.go#L30-L72
131,737
weaveworks/flux
api/v6/container.go
filterContainerFields
func filterContainerFields(container Container, fields []string) (Container, error) { // Default fields if len(fields) == 0 { fields = []string{ "Name", "Current", "LatestFiltered", "Available", "AvailableError", "AvailableImagesCount", "NewAvailableImagesCount", "FilteredImagesCount", "N...
go
func filterContainerFields(container Container, fields []string) (Container, error) { // Default fields if len(fields) == 0 { fields = []string{ "Name", "Current", "LatestFiltered", "Available", "AvailableError", "AvailableImagesCount", "NewAvailableImagesCount", "FilteredImagesCount", "N...
[ "func", "filterContainerFields", "(", "container", "Container", ",", "fields", "[", "]", "string", ")", "(", "Container", ",", "error", ")", "{", "// Default fields", "if", "len", "(", "fields", ")", "==", "0", "{", "fields", "=", "[", "]", "string", "{"...
// filterContainerFields returns a new container with only the fields specified. If not fields are specified, // a list of default fields is used.
[ "filterContainerFields", "returns", "a", "new", "container", "with", "only", "the", "fields", "specified", ".", "If", "not", "fields", "are", "specified", "a", "list", "of", "default", "fields", "is", "used", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/api/v6/container.go#L76-L118
131,738
weaveworks/flux
integrations/helm/status/conditions.go
UpdateConditionsPatch
func UpdateConditionsPatch(status *v1beta1.HelmReleaseStatus, updates ...v1beta1.HelmReleaseCondition) { newConditions := make([]v1beta1.HelmReleaseCondition, len(status.Conditions)) oldConditions := status.Conditions for i, c := range oldConditions { newConditions[i] = c } updates: for _, up := range updates { ...
go
func UpdateConditionsPatch(status *v1beta1.HelmReleaseStatus, updates ...v1beta1.HelmReleaseCondition) { newConditions := make([]v1beta1.HelmReleaseCondition, len(status.Conditions)) oldConditions := status.Conditions for i, c := range oldConditions { newConditions[i] = c } updates: for _, up := range updates { ...
[ "func", "UpdateConditionsPatch", "(", "status", "*", "v1beta1", ".", "HelmReleaseStatus", ",", "updates", "...", "v1beta1", ".", "HelmReleaseCondition", ")", "{", "newConditions", ":=", "make", "(", "[", "]", "v1beta1", ".", "HelmReleaseCondition", ",", "len", "...
// We can't rely on having UpdateStatus, or strategic merge patching // for custom resources. So we have to create an object which // represents the merge path or JSON patch to apply.
[ "We", "can", "t", "rely", "on", "having", "UpdateStatus", "or", "strategic", "merge", "patching", "for", "custom", "resources", ".", "So", "we", "have", "to", "create", "an", "object", "which", "represents", "the", "merge", "path", "or", "JSON", "patch", "...
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/status/conditions.go#L12-L29
131,739
weaveworks/flux
integrations/helm/status/conditions.go
UpdateConditions
func UpdateConditions(client v1beta1client.HelmReleaseInterface, fhr v1beta1.HelmRelease, updates ...v1beta1.HelmReleaseCondition) error { cFhr, err := client.Get(fhr.Name, v1.GetOptions{}) if err != nil { return err } UpdateConditionsPatch(&cFhr.Status, updates...) _, err = client.UpdateStatus(cFhr) return er...
go
func UpdateConditions(client v1beta1client.HelmReleaseInterface, fhr v1beta1.HelmRelease, updates ...v1beta1.HelmReleaseCondition) error { cFhr, err := client.Get(fhr.Name, v1.GetOptions{}) if err != nil { return err } UpdateConditionsPatch(&cFhr.Status, updates...) _, err = client.UpdateStatus(cFhr) return er...
[ "func", "UpdateConditions", "(", "client", "v1beta1client", ".", "HelmReleaseInterface", ",", "fhr", "v1beta1", ".", "HelmRelease", ",", "updates", "...", "v1beta1", ".", "HelmReleaseCondition", ")", "error", "{", "cFhr", ",", "err", ":=", "client", ".", "Get", ...
// UpdateConditions retrieves a new copy of the HelmRelease given, // applies the updates to this copy, and updates the resource in the // cluster.
[ "UpdateConditions", "retrieves", "a", "new", "copy", "of", "the", "HelmRelease", "given", "applies", "the", "updates", "to", "this", "copy", "and", "updates", "the", "resource", "in", "the", "cluster", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/status/conditions.go#L34-L43
131,740
weaveworks/flux
integrations/helm/chartsync/chartsync.go
maybeMirror
func (chs *ChartChangeSync) maybeMirror(fhr fluxv1beta1.HelmRelease) { chartSource := fhr.Spec.ChartSource.GitChartSource if chartSource != nil { if ok := chs.mirrors.Mirror( mirrorName(chartSource), git.Remote{chartSource.GitURL}, git.Timeout(chs.config.GitTimeout), git.PollInterval(chs.config.GitPollInterva...
go
func (chs *ChartChangeSync) maybeMirror(fhr fluxv1beta1.HelmRelease) { chartSource := fhr.Spec.ChartSource.GitChartSource if chartSource != nil { if ok := chs.mirrors.Mirror( mirrorName(chartSource), git.Remote{chartSource.GitURL}, git.Timeout(chs.config.GitTimeout), git.PollInterval(chs.config.GitPollInterva...
[ "func", "(", "chs", "*", "ChartChangeSync", ")", "maybeMirror", "(", "fhr", "fluxv1beta1", ".", "HelmRelease", ")", "{", "chartSource", ":=", "fhr", ".", "Spec", ".", "ChartSource", ".", "GitChartSource", "\n", "if", "chartSource", "!=", "nil", "{", "if", ...
// maybeMirror starts mirroring the repo needed by a HelmRelease, // if necessary
[ "maybeMirror", "starts", "mirroring", "the", "repo", "needed", "by", "a", "HelmRelease", "if", "necessary" ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/chartsync/chartsync.go#L271-L281
131,741
weaveworks/flux
integrations/helm/chartsync/chartsync.go
DeleteRelease
func (chs *ChartChangeSync) DeleteRelease(fhr fluxv1beta1.HelmRelease) { // FIXME(michael): these may need to stop mirroring a repo. name := release.GetReleaseName(fhr) err := chs.release.Delete(name) if err != nil { chs.logger.Log("warning", "chart release not deleted", "resource", fhr.ResourceID().String(), "re...
go
func (chs *ChartChangeSync) DeleteRelease(fhr fluxv1beta1.HelmRelease) { // FIXME(michael): these may need to stop mirroring a repo. name := release.GetReleaseName(fhr) err := chs.release.Delete(name) if err != nil { chs.logger.Log("warning", "chart release not deleted", "resource", fhr.ResourceID().String(), "re...
[ "func", "(", "chs", "*", "ChartChangeSync", ")", "DeleteRelease", "(", "fhr", "fluxv1beta1", ".", "HelmRelease", ")", "{", "// FIXME(michael): these may need to stop mirroring a repo.", "name", ":=", "release", ".", "GetReleaseName", "(", "fhr", ")", "\n", "err", ":...
// DeleteRelease deletes the helm release associated with a // HelmRelease. This exists mainly so that the operator code can // call it when it is handling a resource deletion.
[ "DeleteRelease", "deletes", "the", "helm", "release", "associated", "with", "a", "HelmRelease", ".", "This", "exists", "mainly", "so", "that", "the", "operator", "code", "can", "call", "it", "when", "it", "is", "handling", "a", "resource", "deletion", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/chartsync/chartsync.go#L417-L435
131,742
weaveworks/flux
integrations/helm/chartsync/chartsync.go
SyncMirrors
func (chs *ChartChangeSync) SyncMirrors() { chs.logger.Log("info", "starting mirror sync") for _, err := range chs.mirrors.RefreshAll(chs.config.GitTimeout) { chs.logger.Log("error", fmt.Sprintf("failure while syncing mirror: %s", err)) } chs.logger.Log("info", "finished syncing mirrors") }
go
func (chs *ChartChangeSync) SyncMirrors() { chs.logger.Log("info", "starting mirror sync") for _, err := range chs.mirrors.RefreshAll(chs.config.GitTimeout) { chs.logger.Log("error", fmt.Sprintf("failure while syncing mirror: %s", err)) } chs.logger.Log("info", "finished syncing mirrors") }
[ "func", "(", "chs", "*", "ChartChangeSync", ")", "SyncMirrors", "(", ")", "{", "chs", ".", "logger", ".", "Log", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "for", "_", ",", "err", ":=", "range", "chs", ".", "mirrors", ".", "RefreshAll", "(", "c...
// SyncMirrors instructs all mirrors to refresh from their upstream.
[ "SyncMirrors", "instructs", "all", "mirrors", "to", "refresh", "from", "their", "upstream", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/chartsync/chartsync.go#L438-L444
131,743
weaveworks/flux
integrations/helm/chartsync/chartsync.go
getCustomResourcesForMirror
func (chs *ChartChangeSync) getCustomResourcesForMirror(mirror string) ([]fluxv1beta1.HelmRelease, error) { var fhrs []v1beta1.HelmRelease list, err := chs.fhrLister.List(labels.Everything()) if err != nil { return nil, err } for _, fhr := range list { if mirror != mirrorName(fhr.Spec.GitChartSource) { con...
go
func (chs *ChartChangeSync) getCustomResourcesForMirror(mirror string) ([]fluxv1beta1.HelmRelease, error) { var fhrs []v1beta1.HelmRelease list, err := chs.fhrLister.List(labels.Everything()) if err != nil { return nil, err } for _, fhr := range list { if mirror != mirrorName(fhr.Spec.GitChartSource) { con...
[ "func", "(", "chs", "*", "ChartChangeSync", ")", "getCustomResourcesForMirror", "(", "mirror", "string", ")", "(", "[", "]", "fluxv1beta1", ".", "HelmRelease", ",", "error", ")", "{", "var", "fhrs", "[", "]", "v1beta1", ".", "HelmRelease", "\n", "list", ",...
// getCustomResourcesForMirror retrieves all the resources that make // use of the given mirror from the lister.
[ "getCustomResourcesForMirror", "retrieves", "all", "the", "resources", "that", "make", "use", "of", "the", "given", "mirror", "from", "the", "lister", "." ]
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/chartsync/chartsync.go#L448-L462
131,744
weaveworks/flux
integrations/helm/chartsync/chartsync.go
shouldUpgrade
func (chs *ChartChangeSync) shouldUpgrade(chartsRepo string, currRel *hapi_release.Release, fhr fluxv1beta1.HelmRelease) (bool, error) { if currRel == nil { return false, fmt.Errorf("no chart release provided for %v", fhr.GetName()) } currVals := currRel.GetConfig() currChart := currRel.GetChart() // Get the d...
go
func (chs *ChartChangeSync) shouldUpgrade(chartsRepo string, currRel *hapi_release.Release, fhr fluxv1beta1.HelmRelease) (bool, error) { if currRel == nil { return false, fmt.Errorf("no chart release provided for %v", fhr.GetName()) } currVals := currRel.GetConfig() currChart := currRel.GetChart() // Get the d...
[ "func", "(", "chs", "*", "ChartChangeSync", ")", "shouldUpgrade", "(", "chartsRepo", "string", ",", "currRel", "*", "hapi_release", ".", "Release", ",", "fhr", "fluxv1beta1", ".", "HelmRelease", ")", "(", "bool", ",", "error", ")", "{", "if", "currRel", "=...
// shouldUpgrade returns true if the current running values or chart // don't match what the repo says we ought to be running, based on // doing a dry run install from the chart in the git repo.
[ "shouldUpgrade", "returns", "true", "if", "the", "current", "running", "values", "or", "chart", "don", "t", "match", "what", "the", "repo", "says", "we", "ought", "to", "be", "running", "based", "on", "doing", "a", "dry", "run", "install", "from", "the", ...
6e1702275f5fae61a4d2c796215612450e73da62
https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/chartsync/chartsync.go#L531-L569
131,745
golang/protobuf
proto/encode.go
EncodeVarint
func EncodeVarint(x uint64) []byte { var buf [maxVarintBytes]byte var n int for n = 0; x > 127; n++ { buf[n] = 0x80 | uint8(x&0x7F) x >>= 7 } buf[n] = uint8(x) n++ return buf[0:n] }
go
func EncodeVarint(x uint64) []byte { var buf [maxVarintBytes]byte var n int for n = 0; x > 127; n++ { buf[n] = 0x80 | uint8(x&0x7F) x >>= 7 } buf[n] = uint8(x) n++ return buf[0:n] }
[ "func", "EncodeVarint", "(", "x", "uint64", ")", "[", "]", "byte", "{", "var", "buf", "[", "maxVarintBytes", "]", "byte", "\n", "var", "n", "int", "\n", "for", "n", "=", "0", ";", "x", ">", "127", ";", "n", "++", "{", "buf", "[", "n", "]", "=...
// EncodeVarint returns the varint encoding of x. // This is the format for the // int32, int64, uint32, uint64, bool, and enum // protocol buffer types. // Not used by the package itself, but helpful to clients // wishing to use the same encoding.
[ "EncodeVarint", "returns", "the", "varint", "encoding", "of", "x", ".", "This", "is", "the", "format", "for", "the", "int32", "int64", "uint32", "uint64", "bool", "and", "enum", "protocol", "buffer", "types", ".", "Not", "used", "by", "the", "package", "it...
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L72-L82
131,746
golang/protobuf
proto/encode.go
EncodeVarint
func (p *Buffer) EncodeVarint(x uint64) error { for x >= 1<<7 { p.buf = append(p.buf, uint8(x&0x7f|0x80)) x >>= 7 } p.buf = append(p.buf, uint8(x)) return nil }
go
func (p *Buffer) EncodeVarint(x uint64) error { for x >= 1<<7 { p.buf = append(p.buf, uint8(x&0x7f|0x80)) x >>= 7 } p.buf = append(p.buf, uint8(x)) return nil }
[ "func", "(", "p", "*", "Buffer", ")", "EncodeVarint", "(", "x", "uint64", ")", "error", "{", "for", "x", ">=", "1", "<<", "7", "{", "p", ".", "buf", "=", "append", "(", "p", ".", "buf", ",", "uint8", "(", "x", "&", "0x7f", "|", "0x80", ")", ...
// EncodeVarint writes a varint-encoded integer to the Buffer. // This is the format for the // int32, int64, uint32, uint64, bool, and enum // protocol buffer types.
[ "EncodeVarint", "writes", "a", "varint", "-", "encoded", "integer", "to", "the", "Buffer", ".", "This", "is", "the", "format", "for", "the", "int32", "int64", "uint32", "uint64", "bool", "and", "enum", "protocol", "buffer", "types", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L88-L95
131,747
golang/protobuf
proto/encode.go
SizeVarint
func SizeVarint(x uint64) int { switch { case x < 1<<7: return 1 case x < 1<<14: return 2 case x < 1<<21: return 3 case x < 1<<28: return 4 case x < 1<<35: return 5 case x < 1<<42: return 6 case x < 1<<49: return 7 case x < 1<<56: return 8 case x < 1<<63: return 9 } return 10 }
go
func SizeVarint(x uint64) int { switch { case x < 1<<7: return 1 case x < 1<<14: return 2 case x < 1<<21: return 3 case x < 1<<28: return 4 case x < 1<<35: return 5 case x < 1<<42: return 6 case x < 1<<49: return 7 case x < 1<<56: return 8 case x < 1<<63: return 9 } return 10 }
[ "func", "SizeVarint", "(", "x", "uint64", ")", "int", "{", "switch", "{", "case", "x", "<", "1", "<<", "7", ":", "return", "1", "\n", "case", "x", "<", "1", "<<", "14", ":", "return", "2", "\n", "case", "x", "<", "1", "<<", "21", ":", "return...
// SizeVarint returns the varint encoding size of an integer.
[ "SizeVarint", "returns", "the", "varint", "encoding", "size", "of", "an", "integer", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L98-L120
131,748
golang/protobuf
proto/encode.go
EncodeFixed64
func (p *Buffer) EncodeFixed64(x uint64) error { p.buf = append(p.buf, uint8(x), uint8(x>>8), uint8(x>>16), uint8(x>>24), uint8(x>>32), uint8(x>>40), uint8(x>>48), uint8(x>>56)) return nil }
go
func (p *Buffer) EncodeFixed64(x uint64) error { p.buf = append(p.buf, uint8(x), uint8(x>>8), uint8(x>>16), uint8(x>>24), uint8(x>>32), uint8(x>>40), uint8(x>>48), uint8(x>>56)) return nil }
[ "func", "(", "p", "*", "Buffer", ")", "EncodeFixed64", "(", "x", "uint64", ")", "error", "{", "p", ".", "buf", "=", "append", "(", "p", ".", "buf", ",", "uint8", "(", "x", ")", ",", "uint8", "(", "x", ">>", "8", ")", ",", "uint8", "(", "x", ...
// EncodeFixed64 writes a 64-bit integer to the Buffer. // This is the format for the // fixed64, sfixed64, and double protocol buffer types.
[ "EncodeFixed64", "writes", "a", "64", "-", "bit", "integer", "to", "the", "Buffer", ".", "This", "is", "the", "format", "for", "the", "fixed64", "sfixed64", "and", "double", "protocol", "buffer", "types", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L125-L136
131,749
golang/protobuf
proto/encode.go
EncodeFixed32
func (p *Buffer) EncodeFixed32(x uint64) error { p.buf = append(p.buf, uint8(x), uint8(x>>8), uint8(x>>16), uint8(x>>24)) return nil }
go
func (p *Buffer) EncodeFixed32(x uint64) error { p.buf = append(p.buf, uint8(x), uint8(x>>8), uint8(x>>16), uint8(x>>24)) return nil }
[ "func", "(", "p", "*", "Buffer", ")", "EncodeFixed32", "(", "x", "uint64", ")", "error", "{", "p", ".", "buf", "=", "append", "(", "p", ".", "buf", ",", "uint8", "(", "x", ")", ",", "uint8", "(", "x", ">>", "8", ")", ",", "uint8", "(", "x", ...
// EncodeFixed32 writes a 32-bit integer to the Buffer. // This is the format for the // fixed32, sfixed32, and float protocol buffer types.
[ "EncodeFixed32", "writes", "a", "32", "-", "bit", "integer", "to", "the", "Buffer", ".", "This", "is", "the", "format", "for", "the", "fixed32", "sfixed32", "and", "float", "protocol", "buffer", "types", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L141-L148
131,750
golang/protobuf
proto/encode.go
EncodeZigzag64
func (p *Buffer) EncodeZigzag64(x uint64) error { // use signed number to get arithmetic right shift. return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) }
go
func (p *Buffer) EncodeZigzag64(x uint64) error { // use signed number to get arithmetic right shift. return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) }
[ "func", "(", "p", "*", "Buffer", ")", "EncodeZigzag64", "(", "x", "uint64", ")", "error", "{", "// use signed number to get arithmetic right shift.", "return", "p", ".", "EncodeVarint", "(", "uint64", "(", "(", "x", "<<", "1", ")", "^", "uint64", "(", "(", ...
// EncodeZigzag64 writes a zigzag-encoded 64-bit integer // to the Buffer. // This is the format used for the sint64 protocol buffer type.
[ "EncodeZigzag64", "writes", "a", "zigzag", "-", "encoded", "64", "-", "bit", "integer", "to", "the", "Buffer", ".", "This", "is", "the", "format", "used", "for", "the", "sint64", "protocol", "buffer", "type", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L153-L156
131,751
golang/protobuf
proto/encode.go
EncodeZigzag32
func (p *Buffer) EncodeZigzag32(x uint64) error { // use signed number to get arithmetic right shift. return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) }
go
func (p *Buffer) EncodeZigzag32(x uint64) error { // use signed number to get arithmetic right shift. return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) }
[ "func", "(", "p", "*", "Buffer", ")", "EncodeZigzag32", "(", "x", "uint64", ")", "error", "{", "// use signed number to get arithmetic right shift.", "return", "p", ".", "EncodeVarint", "(", "uint64", "(", "(", "uint32", "(", "x", ")", "<<", "1", ")", "^", ...
// EncodeZigzag32 writes a zigzag-encoded 32-bit integer // to the Buffer. // This is the format used for the sint32 protocol buffer type.
[ "EncodeZigzag32", "writes", "a", "zigzag", "-", "encoded", "32", "-", "bit", "integer", "to", "the", "Buffer", ".", "This", "is", "the", "format", "used", "for", "the", "sint32", "protocol", "buffer", "type", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L161-L164
131,752
golang/protobuf
proto/encode.go
EncodeRawBytes
func (p *Buffer) EncodeRawBytes(b []byte) error { p.EncodeVarint(uint64(len(b))) p.buf = append(p.buf, b...) return nil }
go
func (p *Buffer) EncodeRawBytes(b []byte) error { p.EncodeVarint(uint64(len(b))) p.buf = append(p.buf, b...) return nil }
[ "func", "(", "p", "*", "Buffer", ")", "EncodeRawBytes", "(", "b", "[", "]", "byte", ")", "error", "{", "p", ".", "EncodeVarint", "(", "uint64", "(", "len", "(", "b", ")", ")", ")", "\n", "p", ".", "buf", "=", "append", "(", "p", ".", "buf", "...
// EncodeRawBytes writes a count-delimited byte buffer to the Buffer. // This is the format used for the bytes protocol buffer // type and for embedded messages.
[ "EncodeRawBytes", "writes", "a", "count", "-", "delimited", "byte", "buffer", "to", "the", "Buffer", ".", "This", "is", "the", "format", "used", "for", "the", "bytes", "protocol", "buffer", "type", "and", "for", "embedded", "messages", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L169-L173
131,753
golang/protobuf
proto/encode.go
EncodeStringBytes
func (p *Buffer) EncodeStringBytes(s string) error { p.EncodeVarint(uint64(len(s))) p.buf = append(p.buf, s...) return nil }
go
func (p *Buffer) EncodeStringBytes(s string) error { p.EncodeVarint(uint64(len(s))) p.buf = append(p.buf, s...) return nil }
[ "func", "(", "p", "*", "Buffer", ")", "EncodeStringBytes", "(", "s", "string", ")", "error", "{", "p", ".", "EncodeVarint", "(", "uint64", "(", "len", "(", "s", ")", ")", ")", "\n", "p", ".", "buf", "=", "append", "(", "p", ".", "buf", ",", "s"...
// EncodeStringBytes writes an encoded string to the Buffer. // This is the format used for the proto2 string type.
[ "EncodeStringBytes", "writes", "an", "encoded", "string", "to", "the", "Buffer", ".", "This", "is", "the", "format", "used", "for", "the", "proto2", "string", "type", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L177-L181
131,754
golang/protobuf
proto/encode.go
EncodeMessage
func (p *Buffer) EncodeMessage(pb Message) error { siz := Size(pb) p.EncodeVarint(uint64(siz)) return p.Marshal(pb) }
go
func (p *Buffer) EncodeMessage(pb Message) error { siz := Size(pb) p.EncodeVarint(uint64(siz)) return p.Marshal(pb) }
[ "func", "(", "p", "*", "Buffer", ")", "EncodeMessage", "(", "pb", "Message", ")", "error", "{", "siz", ":=", "Size", "(", "pb", ")", "\n", "p", ".", "EncodeVarint", "(", "uint64", "(", "siz", ")", ")", "\n", "return", "p", ".", "Marshal", "(", "p...
// EncodeMessage writes the protocol buffer to the Buffer, // prefixed by a varint-encoded length.
[ "EncodeMessage", "writes", "the", "protocol", "buffer", "to", "the", "Buffer", "prefixed", "by", "a", "varint", "-", "encoded", "length", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L190-L194
131,755
golang/protobuf
proto/encode.go
isNil
func isNil(v reflect.Value) bool { switch v.Kind() { case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: return v.IsNil() } return false }
go
func isNil(v reflect.Value) bool { switch v.Kind() { case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: return v.IsNil() } return false }
[ "func", "isNil", "(", "v", "reflect", ".", "Value", ")", "bool", "{", "switch", "v", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Interface", ",", "reflect", ".", "Map", ",", "reflect", ".", "Ptr", ",", "reflect", ".", "Slice", ":", "return...
// All protocol buffer fields are nillable, but be careful.
[ "All", "protocol", "buffer", "fields", "are", "nillable", "but", "be", "careful", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/encode.go#L197-L203
131,756
golang/protobuf
protoc-gen-go/grpc/grpc.go
generateUnimplementedServer
func (g *grpc) generateUnimplementedServer(servName string, service *pb.ServiceDescriptorProto) { serverType := servName + "Server" g.P("// Unimplemented", serverType, " can be embedded to have forward compatible implementations.") g.P("type Unimplemented", serverType, " struct {") g.P("}") g.P() // Unimplemented...
go
func (g *grpc) generateUnimplementedServer(servName string, service *pb.ServiceDescriptorProto) { serverType := servName + "Server" g.P("// Unimplemented", serverType, " can be embedded to have forward compatible implementations.") g.P("type Unimplemented", serverType, " struct {") g.P("}") g.P() // Unimplemented...
[ "func", "(", "g", "*", "grpc", ")", "generateUnimplementedServer", "(", "servName", "string", ",", "service", "*", "pb", ".", "ServiceDescriptorProto", ")", "{", "serverType", ":=", "servName", "+", "\"", "\"", "\n", "g", ".", "P", "(", "\"", "\"", ",", ...
// generateUnimplementedServer creates the unimplemented server struct
[ "generateUnimplementedServer", "creates", "the", "unimplemented", "server", "struct" ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/protoc-gen-go/grpc/grpc.go#L281-L292
131,757
golang/protobuf
protoc-gen-go/grpc/grpc.go
generateServerMethodConcrete
func (g *grpc) generateServerMethodConcrete(servName string, method *pb.MethodDescriptorProto) { header := g.generateServerSignatureWithParamNames(servName, method) g.P("func (*Unimplemented", servName, "Server) ", header, " {") var nilArg string if !method.GetServerStreaming() && !method.GetClientStreaming() { n...
go
func (g *grpc) generateServerMethodConcrete(servName string, method *pb.MethodDescriptorProto) { header := g.generateServerSignatureWithParamNames(servName, method) g.P("func (*Unimplemented", servName, "Server) ", header, " {") var nilArg string if !method.GetServerStreaming() && !method.GetClientStreaming() { n...
[ "func", "(", "g", "*", "grpc", ")", "generateServerMethodConcrete", "(", "servName", "string", ",", "method", "*", "pb", ".", "MethodDescriptorProto", ")", "{", "header", ":=", "g", ".", "generateServerSignatureWithParamNames", "(", "servName", ",", "method", ")...
// generateServerMethodConcrete returns unimplemented methods which ensure forward compatibility
[ "generateServerMethodConcrete", "returns", "unimplemented", "methods", "which", "ensure", "forward", "compatibility" ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/protoc-gen-go/grpc/grpc.go#L295-L307
131,758
golang/protobuf
protoc-gen-go/grpc/grpc.go
generateServerSignatureWithParamNames
func (g *grpc) generateServerSignatureWithParamNames(servName string, method *pb.MethodDescriptorProto) string { origMethName := method.GetName() methName := generator.CamelCase(origMethName) if reservedClientName[methName] { methName += "_" } var reqArgs []string ret := "error" if !method.GetServerStreaming(...
go
func (g *grpc) generateServerSignatureWithParamNames(servName string, method *pb.MethodDescriptorProto) string { origMethName := method.GetName() methName := generator.CamelCase(origMethName) if reservedClientName[methName] { methName += "_" } var reqArgs []string ret := "error" if !method.GetServerStreaming(...
[ "func", "(", "g", "*", "grpc", ")", "generateServerSignatureWithParamNames", "(", "servName", "string", ",", "method", "*", "pb", ".", "MethodDescriptorProto", ")", "string", "{", "origMethName", ":=", "method", ".", "GetName", "(", ")", "\n", "methName", ":="...
// generateServerSignatureWithParamNames returns the server-side signature for a method with parameter names.
[ "generateServerSignatureWithParamNames", "returns", "the", "server", "-", "side", "signature", "for", "a", "method", "with", "parameter", "names", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/protoc-gen-go/grpc/grpc.go#L409-L430
131,759
golang/protobuf
proto/discard.go
DiscardUnknown
func DiscardUnknown(m Message) { if m, ok := m.(generatedDiscarder); ok { m.XXX_DiscardUnknown() return } // TODO: Dynamically populate a InternalMessageInfo for legacy messages, // but the master branch has no implementation for InternalMessageInfo, // so it would be more work to replicate that approach. dis...
go
func DiscardUnknown(m Message) { if m, ok := m.(generatedDiscarder); ok { m.XXX_DiscardUnknown() return } // TODO: Dynamically populate a InternalMessageInfo for legacy messages, // but the master branch has no implementation for InternalMessageInfo, // so it would be more work to replicate that approach. dis...
[ "func", "DiscardUnknown", "(", "m", "Message", ")", "{", "if", "m", ",", "ok", ":=", "m", ".", "(", "generatedDiscarder", ")", ";", "ok", "{", "m", ".", "XXX_DiscardUnknown", "(", ")", "\n", "return", "\n", "}", "\n", "// TODO: Dynamically populate a Inter...
// DiscardUnknown recursively discards all unknown fields from this message // and all embedded messages. // // When unmarshaling a message with unrecognized fields, the tags and values // of such fields are preserved in the Message. This allows a later call to // marshal to be able to produce a message that continues ...
[ "DiscardUnknown", "recursively", "discards", "all", "unknown", "fields", "from", "this", "message", "and", "all", "embedded", "messages", ".", "When", "unmarshaling", "a", "message", "with", "unrecognized", "fields", "the", "tags", "and", "values", "of", "such", ...
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/discard.go#L57-L66
131,760
golang/protobuf
proto/discard.go
DiscardUnknown
func (a *InternalMessageInfo) DiscardUnknown(m Message) { di := atomicLoadDiscardInfo(&a.discard) if di == nil { di = getDiscardInfo(reflect.TypeOf(m).Elem()) atomicStoreDiscardInfo(&a.discard, di) } di.discard(toPointer(&m)) }
go
func (a *InternalMessageInfo) DiscardUnknown(m Message) { di := atomicLoadDiscardInfo(&a.discard) if di == nil { di = getDiscardInfo(reflect.TypeOf(m).Elem()) atomicStoreDiscardInfo(&a.discard, di) } di.discard(toPointer(&m)) }
[ "func", "(", "a", "*", "InternalMessageInfo", ")", "DiscardUnknown", "(", "m", "Message", ")", "{", "di", ":=", "atomicLoadDiscardInfo", "(", "&", "a", ".", "discard", ")", "\n", "if", "di", "==", "nil", "{", "di", "=", "getDiscardInfo", "(", "reflect", ...
// DiscardUnknown recursively discards all unknown fields.
[ "DiscardUnknown", "recursively", "discards", "all", "unknown", "fields", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/discard.go#L69-L76
131,761
golang/protobuf
proto/table_merge.go
Merge
func (a *InternalMessageInfo) Merge(dst, src Message) { mi := atomicLoadMergeInfo(&a.merge) if mi == nil { mi = getMergeInfo(reflect.TypeOf(dst).Elem()) atomicStoreMergeInfo(&a.merge, mi) } mi.merge(toPointer(&dst), toPointer(&src)) }
go
func (a *InternalMessageInfo) Merge(dst, src Message) { mi := atomicLoadMergeInfo(&a.merge) if mi == nil { mi = getMergeInfo(reflect.TypeOf(dst).Elem()) atomicStoreMergeInfo(&a.merge, mi) } mi.merge(toPointer(&dst), toPointer(&src)) }
[ "func", "(", "a", "*", "InternalMessageInfo", ")", "Merge", "(", "dst", ",", "src", "Message", ")", "{", "mi", ":=", "atomicLoadMergeInfo", "(", "&", "a", ".", "merge", ")", "\n", "if", "mi", "==", "nil", "{", "mi", "=", "getMergeInfo", "(", "reflect...
// Merge merges the src message into dst. // This assumes that dst and src of the same type and are non-nil.
[ "Merge", "merges", "the", "src", "message", "into", "dst", ".", "This", "assumes", "that", "dst", "and", "src", "of", "the", "same", "type", "and", "are", "non", "-", "nil", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/table_merge.go#L44-L51
131,762
golang/protobuf
protoc-gen-go/generator/internal/remap/remap.go
Find
func (m Map) Find(pos, end int) (Location, bool) { key := Location{ Pos: pos, End: end, } if loc, ok := m[key]; ok { return loc, true } return key, false }
go
func (m Map) Find(pos, end int) (Location, bool) { key := Location{ Pos: pos, End: end, } if loc, ok := m[key]; ok { return loc, true } return key, false }
[ "func", "(", "m", "Map", ")", "Find", "(", "pos", ",", "end", "int", ")", "(", "Location", ",", "bool", ")", "{", "key", ":=", "Location", "{", "Pos", ":", "pos", ",", "End", ":", "end", ",", "}", "\n", "if", "loc", ",", "ok", ":=", "m", "[...
// Find reports whether the specified span is recorded by m, and if so returns // the new location it was mapped to. If the input span was not found, the // returned location is the same as the input.
[ "Find", "reports", "whether", "the", "specified", "span", "is", "recorded", "by", "m", "and", "if", "so", "returns", "the", "new", "location", "it", "was", "mapped", "to", ".", "If", "the", "input", "span", "was", "not", "found", "the", "returned", "loca...
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/protoc-gen-go/generator/internal/remap/remap.go#L56-L65
131,763
golang/protobuf
protoc-gen-go/generator/internal/remap/remap.go
Compute
func Compute(input, output []byte) (Map, error) { itok := tokenize(input) otok := tokenize(output) if len(itok) != len(otok) { return nil, fmt.Errorf("wrong number of tokens, %d ≠ %d", len(itok), len(otok)) } m := make(Map) for i, ti := range itok { to := otok[i] if ti.Token != to.Token { return nil, fmt...
go
func Compute(input, output []byte) (Map, error) { itok := tokenize(input) otok := tokenize(output) if len(itok) != len(otok) { return nil, fmt.Errorf("wrong number of tokens, %d ≠ %d", len(itok), len(otok)) } m := make(Map) for i, ti := range itok { to := otok[i] if ti.Token != to.Token { return nil, fmt...
[ "func", "Compute", "(", "input", ",", "output", "[", "]", "byte", ")", "(", "Map", ",", "error", ")", "{", "itok", ":=", "tokenize", "(", "input", ")", "\n", "otok", ":=", "tokenize", "(", "output", ")", "\n", "if", "len", "(", "itok", ")", "!=",...
// Compute constructs a location mapping from input to output. An error is // reported if any of the tokens of output cannot be mapped.
[ "Compute", "constructs", "a", "location", "mapping", "from", "input", "to", "output", ".", "An", "error", "is", "reported", "if", "any", "of", "the", "tokens", "of", "output", "cannot", "be", "mapped", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/protoc-gen-go/generator/internal/remap/remap.go#L73-L88
131,764
golang/protobuf
proto/text.go
isAny
func isAny(sv reflect.Value) bool { type wkt interface { XXX_WellKnownType() string } t, ok := sv.Addr().Interface().(wkt) return ok && t.XXX_WellKnownType() == "Any" }
go
func isAny(sv reflect.Value) bool { type wkt interface { XXX_WellKnownType() string } t, ok := sv.Addr().Interface().(wkt) return ok && t.XXX_WellKnownType() == "Any" }
[ "func", "isAny", "(", "sv", "reflect", ".", "Value", ")", "bool", "{", "type", "wkt", "interface", "{", "XXX_WellKnownType", "(", ")", "string", "\n", "}", "\n", "t", ",", "ok", ":=", "sv", ".", "Addr", "(", ")", ".", "Interface", "(", ")", ".", ...
// isAny reports whether sv is a google.protobuf.Any message
[ "isAny", "reports", "whether", "sv", "is", "a", "google", ".", "protobuf", ".", "Any", "message" ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/text.go#L192-L198
131,765
golang/protobuf
proto/text.go
writeString
func writeString(w *textWriter, s string) error { // use WriteByte here to get any needed indent if err := w.WriteByte('"'); err != nil { return err } // Loop over the bytes, not the runes. for i := 0; i < len(s); i++ { var err error // Divergence from C++: we don't escape apostrophes. // There's no need t...
go
func writeString(w *textWriter, s string) error { // use WriteByte here to get any needed indent if err := w.WriteByte('"'); err != nil { return err } // Loop over the bytes, not the runes. for i := 0; i < len(s); i++ { var err error // Divergence from C++: we don't escape apostrophes. // There's no need t...
[ "func", "writeString", "(", "w", "*", "textWriter", ",", "s", "string", ")", "error", "{", "// use WriteByte here to get any needed indent", "if", "err", ":=", "w", ".", "WriteByte", "(", "'\"'", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}...
// writeString writes a string in the protocol buffer text format. // It is similar to strconv.Quote except we don't use Go escape sequences, // we treat the string as a byte sequence, and we use octal escapes. // These differences are to maintain interoperability with the other // languages' implementations of the tex...
[ "writeString", "writes", "a", "string", "in", "the", "protocol", "buffer", "text", "format", ".", "It", "is", "similar", "to", "strconv", ".", "Quote", "except", "we", "don", "t", "use", "Go", "escape", "sequences", "we", "treat", "the", "string", "as", ...
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/text.go#L559-L593
131,766
golang/protobuf
proto/text.go
Text
func (tm *TextMarshaler) Text(pb Message) string { var buf bytes.Buffer tm.Marshal(&buf, pb) return buf.String() }
go
func (tm *TextMarshaler) Text(pb Message) string { var buf bytes.Buffer tm.Marshal(&buf, pb) return buf.String() }
[ "func", "(", "tm", "*", "TextMarshaler", ")", "Text", "(", "pb", "Message", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "tm", ".", "Marshal", "(", "&", "buf", ",", "pb", ")", "\n", "return", "buf", ".", "String", "(", ")", "\n...
// Text is the same as Marshal, but returns the string directly.
[ "Text", "is", "the", "same", "as", "Marshal", "but", "returns", "the", "string", "directly", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/text.go#L819-L823
131,767
golang/protobuf
proto/properties.go
setFieldProps
func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { switch t1 := typ; t1.Kind() { case reflect.Ptr: if t1.Elem().Kind() == reflect.Struct { p.stype = t1.Elem() } case reflect.Slice: if t2 := t1.Elem(); t2.Kind() == reflect.Ptr && t2.Elem().Kind() == reflect.Stru...
go
func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { switch t1 := typ; t1.Kind() { case reflect.Ptr: if t1.Elem().Kind() == reflect.Struct { p.stype = t1.Elem() } case reflect.Slice: if t2 := t1.Elem(); t2.Kind() == reflect.Ptr && t2.Elem().Kind() == reflect.Stru...
[ "func", "(", "p", "*", "Properties", ")", "setFieldProps", "(", "typ", "reflect", ".", "Type", ",", "f", "*", "reflect", ".", "StructField", ",", "lockGetProp", "bool", ")", "{", "switch", "t1", ":=", "typ", ";", "t1", ".", "Kind", "(", ")", "{", "...
// setFieldProps initializes the field properties for submessages and maps.
[ "setFieldProps", "initializes", "the", "field", "properties", "for", "submessages", "and", "maps", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/properties.go#L264-L297
131,768
golang/protobuf
proto/properties.go
Init
func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { p.init(typ, name, tag, f, true) }
go
func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { p.init(typ, name, tag, f, true) }
[ "func", "(", "p", "*", "Properties", ")", "Init", "(", "typ", "reflect", ".", "Type", ",", "name", ",", "tag", "string", ",", "f", "*", "reflect", ".", "StructField", ")", "{", "p", ".", "init", "(", "typ", ",", "name", ",", "tag", ",", "f", ",...
// Init populates the properties from a protocol buffer struct tag.
[ "Init", "populates", "the", "properties", "from", "a", "protocol", "buffer", "struct", "tag", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/properties.go#L304-L306
131,769
golang/protobuf
proto/properties.go
GetProperties
func GetProperties(t reflect.Type) *StructProperties { if t.Kind() != reflect.Struct { panic("proto: type must have kind struct") } // Most calls to GetProperties in a long-running program will be // retrieving details for types we have seen before. propertiesMu.RLock() sprop, ok := propertiesMap[t] propertie...
go
func GetProperties(t reflect.Type) *StructProperties { if t.Kind() != reflect.Struct { panic("proto: type must have kind struct") } // Most calls to GetProperties in a long-running program will be // retrieving details for types we have seen before. propertiesMu.RLock() sprop, ok := propertiesMap[t] propertie...
[ "func", "GetProperties", "(", "t", "reflect", ".", "Type", ")", "*", "StructProperties", "{", "if", "t", ".", "Kind", "(", ")", "!=", "reflect", ".", "Struct", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Most calls to GetProperties in a long...
// GetProperties returns the list of properties for the type represented by t. // t must represent a generated struct type of a protocol message.
[ "GetProperties", "returns", "the", "list", "of", "properties", "for", "the", "type", "represented", "by", "t", ".", "t", "must", "represent", "a", "generated", "struct", "type", "of", "a", "protocol", "message", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/properties.go#L326-L344
131,770
golang/protobuf
proto/properties.go
RegisterMapType
func RegisterMapType(x interface{}, name string) { if reflect.TypeOf(x).Kind() != reflect.Map { panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name)) } if _, ok := protoMapTypes[name]; ok { log.Printf("proto: duplicate proto type registered: %s", name) return } t := reflect.TypeOf(x) protoMapType...
go
func RegisterMapType(x interface{}, name string) { if reflect.TypeOf(x).Kind() != reflect.Map { panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name)) } if _, ok := protoMapTypes[name]; ok { log.Printf("proto: duplicate proto type registered: %s", name) return } t := reflect.TypeOf(x) protoMapType...
[ "func", "RegisterMapType", "(", "x", "interface", "{", "}", ",", "name", "string", ")", "{", "if", "reflect", ".", "TypeOf", "(", "x", ")", ".", "Kind", "(", ")", "!=", "reflect", ".", "Map", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "...
// RegisterMapType is called from generated code and maps from the fully qualified // proto name to the native map type of the proto map definition.
[ "RegisterMapType", "is", "called", "from", "generated", "code", "and", "maps", "from", "the", "fully", "qualified", "proto", "name", "to", "the", "native", "map", "type", "of", "the", "proto", "map", "definition", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/properties.go#L499-L510
131,771
golang/protobuf
proto/properties.go
MessageName
func MessageName(x Message) string { type xname interface { XXX_MessageName() string } if m, ok := x.(xname); ok { return m.XXX_MessageName() } return revProtoTypes[reflect.TypeOf(x)] }
go
func MessageName(x Message) string { type xname interface { XXX_MessageName() string } if m, ok := x.(xname); ok { return m.XXX_MessageName() } return revProtoTypes[reflect.TypeOf(x)] }
[ "func", "MessageName", "(", "x", "Message", ")", "string", "{", "type", "xname", "interface", "{", "XXX_MessageName", "(", ")", "string", "\n", "}", "\n", "if", "m", ",", "ok", ":=", "x", ".", "(", "xname", ")", ";", "ok", "{", "return", "m", ".", ...
// MessageName returns the fully-qualified proto name for the given message type.
[ "MessageName", "returns", "the", "fully", "-", "qualified", "proto", "name", "for", "the", "given", "message", "type", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/properties.go#L513-L521
131,772
golang/protobuf
jsonpb/jsonpb.go
MarshalToString
func (m *Marshaler) MarshalToString(pb proto.Message) (string, error) { var buf bytes.Buffer if err := m.Marshal(&buf, pb); err != nil { return "", err } return buf.String(), nil }
go
func (m *Marshaler) MarshalToString(pb proto.Message) (string, error) { var buf bytes.Buffer if err := m.Marshal(&buf, pb); err != nil { return "", err } return buf.String(), nil }
[ "func", "(", "m", "*", "Marshaler", ")", "MarshalToString", "(", "pb", "proto", ".", "Message", ")", "(", "string", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "if", "err", ":=", "m", ".", "Marshal", "(", "&", "buf", ",", ...
// MarshalToString converts a protocol buffer object to JSON string.
[ "MarshalToString", "converts", "a", "protocol", "buffer", "object", "to", "JSON", "string", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/jsonpb/jsonpb.go#L142-L148
131,773
golang/protobuf
jsonpb/jsonpb.go
marshalField
func (m *Marshaler) marshalField(out *errWriter, prop *proto.Properties, v reflect.Value, indent string) error { if m.Indent != "" { out.write(indent) out.write(m.Indent) } out.write(`"`) out.write(prop.JSONName) out.write(`":`) if m.Indent != "" { out.write(" ") } if err := m.marshalValue(out, prop, v, i...
go
func (m *Marshaler) marshalField(out *errWriter, prop *proto.Properties, v reflect.Value, indent string) error { if m.Indent != "" { out.write(indent) out.write(m.Indent) } out.write(`"`) out.write(prop.JSONName) out.write(`":`) if m.Indent != "" { out.write(" ") } if err := m.marshalValue(out, prop, v, i...
[ "func", "(", "m", "*", "Marshaler", ")", "marshalField", "(", "out", "*", "errWriter", ",", "prop", "*", "proto", ".", "Properties", ",", "v", "reflect", ".", "Value", ",", "indent", "string", ")", "error", "{", "if", "m", ".", "Indent", "!=", "\"", ...
// marshalField writes field description and value to the Writer.
[ "marshalField", "writes", "field", "description", "and", "value", "to", "the", "Writer", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/jsonpb/jsonpb.go#L469-L484
131,774
golang/protobuf
jsonpb/jsonpb.go
jsonProperties
func jsonProperties(f reflect.StructField, origName bool) *proto.Properties { var prop proto.Properties prop.Init(f.Type, f.Name, f.Tag.Get("protobuf"), &f) if origName || prop.JSONName == "" { prop.JSONName = prop.OrigName } return &prop }
go
func jsonProperties(f reflect.StructField, origName bool) *proto.Properties { var prop proto.Properties prop.Init(f.Type, f.Name, f.Tag.Get("protobuf"), &f) if origName || prop.JSONName == "" { prop.JSONName = prop.OrigName } return &prop }
[ "func", "jsonProperties", "(", "f", "reflect", ".", "StructField", ",", "origName", "bool", ")", "*", "proto", ".", "Properties", "{", "var", "prop", "proto", ".", "Properties", "\n", "prop", ".", "Init", "(", "f", ".", "Type", ",", "f", ".", "Name", ...
// jsonProperties returns parsed proto.Properties for the field and corrects JSONName attribute.
[ "jsonProperties", "returns", "parsed", "proto", ".", "Properties", "for", "the", "field", "and", "corrects", "JSONName", "attribute", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/jsonpb/jsonpb.go#L1082-L1089
131,775
golang/protobuf
proto/extensions.go
extendable
func extendable(p interface{}) (extendableProto, error) { switch p := p.(type) { case extendableProto: if isNilPtr(p) { return nil, fmt.Errorf("proto: nil %T is not extendable", p) } return p, nil case extendableProtoV1: if isNilPtr(p) { return nil, fmt.Errorf("proto: nil %T is not extendable", p) } ...
go
func extendable(p interface{}) (extendableProto, error) { switch p := p.(type) { case extendableProto: if isNilPtr(p) { return nil, fmt.Errorf("proto: nil %T is not extendable", p) } return p, nil case extendableProtoV1: if isNilPtr(p) { return nil, fmt.Errorf("proto: nil %T is not extendable", p) } ...
[ "func", "extendable", "(", "p", "interface", "{", "}", ")", "(", "extendableProto", ",", "error", ")", "{", "switch", "p", ":=", "p", ".", "(", "type", ")", "{", "case", "extendableProto", ":", "if", "isNilPtr", "(", "p", ")", "{", "return", "nil", ...
// extendable returns the extendableProto interface for the given generated proto message. // If the proto message has the old extension format, it returns a wrapper that implements // the extendableProto interface.
[ "extendable", "returns", "the", "extendableProto", "interface", "for", "the", "given", "generated", "proto", "message", ".", "If", "the", "proto", "message", "has", "the", "old", "extension", "format", "it", "returns", "a", "wrapper", "that", "implements", "the"...
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L95-L111
131,776
golang/protobuf
proto/extensions.go
extensionsWrite
func (e *XXX_InternalExtensions) extensionsWrite() map[int32]Extension { if e.p == nil { e.p = new(struct { mu sync.Mutex extensionMap map[int32]Extension }) e.p.extensionMap = make(map[int32]Extension) } return e.p.extensionMap }
go
func (e *XXX_InternalExtensions) extensionsWrite() map[int32]Extension { if e.p == nil { e.p = new(struct { mu sync.Mutex extensionMap map[int32]Extension }) e.p.extensionMap = make(map[int32]Extension) } return e.p.extensionMap }
[ "func", "(", "e", "*", "XXX_InternalExtensions", ")", "extensionsWrite", "(", ")", "map", "[", "int32", "]", "Extension", "{", "if", "e", ".", "p", "==", "nil", "{", "e", ".", "p", "=", "new", "(", "struct", "{", "mu", "sync", ".", "Mutex", "\n", ...
// extensionsWrite returns the extension map, creating it on first use.
[ "extensionsWrite", "returns", "the", "extension", "map", "creating", "it", "on", "first", "use", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L142-L151
131,777
golang/protobuf
proto/extensions.go
extensionsRead
func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Locker) { if e.p == nil { return nil, nil } return e.p.extensionMap, &e.p.mu }
go
func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Locker) { if e.p == nil { return nil, nil } return e.p.extensionMap, &e.p.mu }
[ "func", "(", "e", "*", "XXX_InternalExtensions", ")", "extensionsRead", "(", ")", "(", "map", "[", "int32", "]", "Extension", ",", "sync", ".", "Locker", ")", "{", "if", "e", ".", "p", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n",...
// extensionsRead returns the extensions map for read-only use. It may be nil. // The caller must hold the returned mutex's lock when accessing Elements within the map.
[ "extensionsRead", "returns", "the", "extensions", "map", "for", "read", "-", "only", "use", ".", "It", "may", "be", "nil", ".", "The", "caller", "must", "hold", "the", "returned", "mutex", "s", "lock", "when", "accessing", "Elements", "within", "the", "map...
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L155-L160
131,778
golang/protobuf
proto/extensions.go
SetRawExtension
func SetRawExtension(base Message, id int32, b []byte) { epb, err := extendable(base) if err != nil { return } extmap := epb.extensionsWrite() extmap[id] = Extension{enc: b} }
go
func SetRawExtension(base Message, id int32, b []byte) { epb, err := extendable(base) if err != nil { return } extmap := epb.extensionsWrite() extmap[id] = Extension{enc: b} }
[ "func", "SetRawExtension", "(", "base", "Message", ",", "id", "int32", ",", "b", "[", "]", "byte", ")", "{", "epb", ",", "err", ":=", "extendable", "(", "base", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "extmap", ":=", ...
// SetRawExtension is for testing only.
[ "SetRawExtension", "is", "for", "testing", "only", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L210-L217
131,779
golang/protobuf
proto/extensions.go
isExtensionField
func isExtensionField(pb extendableProto, field int32) bool { for _, er := range pb.ExtensionRangeArray() { if er.Start <= field && field <= er.End { return true } } return false }
go
func isExtensionField(pb extendableProto, field int32) bool { for _, er := range pb.ExtensionRangeArray() { if er.Start <= field && field <= er.End { return true } } return false }
[ "func", "isExtensionField", "(", "pb", "extendableProto", ",", "field", "int32", ")", "bool", "{", "for", "_", ",", "er", ":=", "range", "pb", ".", "ExtensionRangeArray", "(", ")", "{", "if", "er", ".", "Start", "<=", "field", "&&", "field", "<=", "er"...
// isExtensionField returns true iff the given field number is in an extension range.
[ "isExtensionField", "returns", "true", "iff", "the", "given", "field", "number", "is", "in", "an", "extension", "range", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L220-L227
131,780
golang/protobuf
proto/extensions.go
checkExtensionTypes
func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { var pbi interface{} = pb // Check the extended type. if ea, ok := pbi.(extensionAdapter); ok { pbi = ea.extendableProtoV1 } if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b { return fmt.Errorf("proto: b...
go
func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { var pbi interface{} = pb // Check the extended type. if ea, ok := pbi.(extensionAdapter); ok { pbi = ea.extendableProtoV1 } if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b { return fmt.Errorf("proto: b...
[ "func", "checkExtensionTypes", "(", "pb", "extendableProto", ",", "extension", "*", "ExtensionDesc", ")", "error", "{", "var", "pbi", "interface", "{", "}", "=", "pb", "\n", "// Check the extended type.", "if", "ea", ",", "ok", ":=", "pbi", ".", "(", "extens...
// checkExtensionTypes checks that the given extension is valid for pb.
[ "checkExtensionTypes", "checks", "that", "the", "given", "extension", "is", "valid", "for", "pb", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L230-L244
131,781
golang/protobuf
proto/extensions.go
HasExtension
func HasExtension(pb Message, extension *ExtensionDesc) bool { // TODO: Check types, field numbers, etc.? epb, err := extendable(pb) if err != nil { return false } extmap, mu := epb.extensionsRead() if extmap == nil { return false } mu.Lock() _, ok := extmap[extension.Field] mu.Unlock() return ok }
go
func HasExtension(pb Message, extension *ExtensionDesc) bool { // TODO: Check types, field numbers, etc.? epb, err := extendable(pb) if err != nil { return false } extmap, mu := epb.extensionsRead() if extmap == nil { return false } mu.Lock() _, ok := extmap[extension.Field] mu.Unlock() return ok }
[ "func", "HasExtension", "(", "pb", "Message", ",", "extension", "*", "ExtensionDesc", ")", "bool", "{", "// TODO: Check types, field numbers, etc.?", "epb", ",", "err", ":=", "extendable", "(", "pb", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false",...
// HasExtension returns whether the given extension is present in pb.
[ "HasExtension", "returns", "whether", "the", "given", "extension", "is", "present", "in", "pb", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L283-L297
131,782
golang/protobuf
proto/extensions.go
ClearExtension
func ClearExtension(pb Message, extension *ExtensionDesc) { epb, err := extendable(pb) if err != nil { return } // TODO: Check types, field numbers, etc.? extmap := epb.extensionsWrite() delete(extmap, extension.Field) }
go
func ClearExtension(pb Message, extension *ExtensionDesc) { epb, err := extendable(pb) if err != nil { return } // TODO: Check types, field numbers, etc.? extmap := epb.extensionsWrite() delete(extmap, extension.Field) }
[ "func", "ClearExtension", "(", "pb", "Message", ",", "extension", "*", "ExtensionDesc", ")", "{", "epb", ",", "err", ":=", "extendable", "(", "pb", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "// TODO: Check types, field numbers, etc...
// ClearExtension removes the given extension from pb.
[ "ClearExtension", "removes", "the", "given", "extension", "from", "pb", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L300-L308
131,783
golang/protobuf
proto/extensions.go
defaultExtensionValue
func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { if extension.ExtensionType == nil { // incomplete descriptor, so no default return nil, ErrMissingExtension } t := reflect.TypeOf(extension.ExtensionType) props := extensionProperties(extension) sf, _, err := fieldDefault(t, props) ...
go
func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { if extension.ExtensionType == nil { // incomplete descriptor, so no default return nil, ErrMissingExtension } t := reflect.TypeOf(extension.ExtensionType) props := extensionProperties(extension) sf, _, err := fieldDefault(t, props) ...
[ "func", "defaultExtensionValue", "(", "extension", "*", "ExtensionDesc", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "extension", ".", "ExtensionType", "==", "nil", "{", "// incomplete descriptor, so no default", "return", "nil", ",", "ErrMissin...
// defaultExtensionValue returns the default value for extension. // If no default for an extension is defined ErrMissingExtension is returned.
[ "defaultExtensionValue", "returns", "the", "default", "value", "for", "extension", ".", "If", "no", "default", "for", "an", "extension", "is", "defined", "ErrMissingExtension", "is", "returned", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L377-L413
131,784
golang/protobuf
proto/extensions.go
decodeExtension
func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { t := reflect.TypeOf(extension.ExtensionType) unmarshal := typeUnmarshaler(t, extension.Tag) // t is a pointer to a struct, pointer to basic type or a slice. // Allocate space to store the pointer/slice. value := reflect.New(t).Elem() ...
go
func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { t := reflect.TypeOf(extension.ExtensionType) unmarshal := typeUnmarshaler(t, extension.Tag) // t is a pointer to a struct, pointer to basic type or a slice. // Allocate space to store the pointer/slice. value := reflect.New(t).Elem() ...
[ "func", "decodeExtension", "(", "b", "[", "]", "byte", ",", "extension", "*", "ExtensionDesc", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "t", ":=", "reflect", ".", "TypeOf", "(", "extension", ".", "ExtensionType", ")", "\n", "unmarshal", ...
// decodeExtension decodes an extension encoded in b.
[ "decodeExtension", "decodes", "an", "extension", "encoded", "in", "b", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L416-L443
131,785
golang/protobuf
proto/extensions.go
GetExtensions
func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { epb, err := extendable(pb) if err != nil { return nil, err } extensions = make([]interface{}, len(es)) for i, e := range es { extensions[i], err = GetExtension(epb, e) if err == ErrMissingExtension { err = nil } ...
go
func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { epb, err := extendable(pb) if err != nil { return nil, err } extensions = make([]interface{}, len(es)) for i, e := range es { extensions[i], err = GetExtension(epb, e) if err == ErrMissingExtension { err = nil } ...
[ "func", "GetExtensions", "(", "pb", "Message", ",", "es", "[", "]", "*", "ExtensionDesc", ")", "(", "extensions", "[", "]", "interface", "{", "}", ",", "err", "error", ")", "{", "epb", ",", "err", ":=", "extendable", "(", "pb", ")", "\n", "if", "er...
// GetExtensions returns a slice of the extensions present in pb that are also listed in es. // The returned slice has the same length as es; missing extensions will appear as nil elements.
[ "GetExtensions", "returns", "a", "slice", "of", "the", "extensions", "present", "in", "pb", "that", "are", "also", "listed", "in", "es", ".", "The", "returned", "slice", "has", "the", "same", "length", "as", "es", ";", "missing", "extensions", "will", "app...
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L447-L463
131,786
golang/protobuf
proto/extensions.go
ExtensionDescs
func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { epb, err := extendable(pb) if err != nil { return nil, err } registeredExtensions := RegisteredExtensions(pb) emap, mu := epb.extensionsRead() if emap == nil { return nil, nil } mu.Lock() defer mu.Unlock() extensions := make([]*ExtensionDesc, 0,...
go
func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { epb, err := extendable(pb) if err != nil { return nil, err } registeredExtensions := RegisteredExtensions(pb) emap, mu := epb.extensionsRead() if emap == nil { return nil, nil } mu.Lock() defer mu.Unlock() extensions := make([]*ExtensionDesc, 0,...
[ "func", "ExtensionDescs", "(", "pb", "Message", ")", "(", "[", "]", "*", "ExtensionDesc", ",", "error", ")", "{", "epb", ",", "err", ":=", "extendable", "(", "pb", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// ExtensionDescs returns a new slice containing pb's extension descriptors, in undefined order. // For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing // just the Field field, which defines the extension's field number.
[ "ExtensionDescs", "returns", "a", "new", "slice", "containing", "pb", "s", "extension", "descriptors", "in", "undefined", "order", ".", "For", "non", "-", "registered", "extensions", "ExtensionDescs", "returns", "an", "incomplete", "descriptor", "containing", "just"...
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L468-L494
131,787
golang/protobuf
proto/extensions.go
SetExtension
func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { epb, err := extendable(pb) if err != nil { return err } if err := checkExtensionTypes(epb, extension); err != nil { return err } typ := reflect.TypeOf(extension.ExtensionType) if typ != reflect.TypeOf(value) { return fmt.Err...
go
func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { epb, err := extendable(pb) if err != nil { return err } if err := checkExtensionTypes(epb, extension); err != nil { return err } typ := reflect.TypeOf(extension.ExtensionType) if typ != reflect.TypeOf(value) { return fmt.Err...
[ "func", "SetExtension", "(", "pb", "Message", ",", "extension", "*", "ExtensionDesc", ",", "value", "interface", "{", "}", ")", "error", "{", "epb", ",", "err", ":=", "extendable", "(", "pb", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", ...
// SetExtension sets the specified extension of pb to the specified value.
[ "SetExtension", "sets", "the", "specified", "extension", "of", "pb", "to", "the", "specified", "value", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L497-L521
131,788
golang/protobuf
proto/extensions.go
ClearAllExtensions
func ClearAllExtensions(pb Message) { epb, err := extendable(pb) if err != nil { return } m := epb.extensionsWrite() for k := range m { delete(m, k) } }
go
func ClearAllExtensions(pb Message) { epb, err := extendable(pb) if err != nil { return } m := epb.extensionsWrite() for k := range m { delete(m, k) } }
[ "func", "ClearAllExtensions", "(", "pb", "Message", ")", "{", "epb", ",", "err", ":=", "extendable", "(", "pb", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "m", ":=", "epb", ".", "extensionsWrite", "(", ")", "\n", "for", "k...
// ClearAllExtensions clears all extensions from pb.
[ "ClearAllExtensions", "clears", "all", "extensions", "from", "pb", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L524-L533
131,789
golang/protobuf
proto/extensions.go
RegisterExtension
func RegisterExtension(desc *ExtensionDesc) { st := reflect.TypeOf(desc.ExtendedType).Elem() m := extensionMaps[st] if m == nil { m = make(map[int32]*ExtensionDesc) extensionMaps[st] = m } if _, ok := m[desc.Field]; ok { panic("proto: duplicate extension registered: " + st.String() + " " + strconv.Itoa(int(d...
go
func RegisterExtension(desc *ExtensionDesc) { st := reflect.TypeOf(desc.ExtendedType).Elem() m := extensionMaps[st] if m == nil { m = make(map[int32]*ExtensionDesc) extensionMaps[st] = m } if _, ok := m[desc.Field]; ok { panic("proto: duplicate extension registered: " + st.String() + " " + strconv.Itoa(int(d...
[ "func", "RegisterExtension", "(", "desc", "*", "ExtensionDesc", ")", "{", "st", ":=", "reflect", ".", "TypeOf", "(", "desc", ".", "ExtendedType", ")", ".", "Elem", "(", ")", "\n", "m", ":=", "extensionMaps", "[", "st", "]", "\n", "if", "m", "==", "ni...
// RegisterExtension is called from the generated code.
[ "RegisterExtension", "is", "called", "from", "the", "generated", "code", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L541-L552
131,790
golang/protobuf
proto/extensions.go
RegisteredExtensions
func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { return extensionMaps[reflect.TypeOf(pb).Elem()] }
go
func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { return extensionMaps[reflect.TypeOf(pb).Elem()] }
[ "func", "RegisteredExtensions", "(", "pb", "Message", ")", "map", "[", "int32", "]", "*", "ExtensionDesc", "{", "return", "extensionMaps", "[", "reflect", ".", "TypeOf", "(", "pb", ")", ".", "Elem", "(", ")", "]", "\n", "}" ]
// RegisteredExtensions returns a map of the registered extensions of a // protocol buffer struct, indexed by the extension number. // The argument pb should be a nil pointer to the struct type.
[ "RegisteredExtensions", "returns", "a", "map", "of", "the", "registered", "extensions", "of", "a", "protocol", "buffer", "struct", "indexed", "by", "the", "extension", "number", ".", "The", "argument", "pb", "should", "be", "a", "nil", "pointer", "to", "the", ...
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L557-L559
131,791
golang/protobuf
proto/extensions.go
extensionAsLegacyType
func extensionAsLegacyType(v interface{}) interface{} { switch rv := reflect.ValueOf(v); rv.Kind() { case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String: // Represent primitive types as a pointer to the value. rv2 := reflect.New(rv.Type...
go
func extensionAsLegacyType(v interface{}) interface{} { switch rv := reflect.ValueOf(v); rv.Kind() { case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String: // Represent primitive types as a pointer to the value. rv2 := reflect.New(rv.Type...
[ "func", "extensionAsLegacyType", "(", "v", "interface", "{", "}", ")", "interface", "{", "}", "{", "switch", "rv", ":=", "reflect", ".", "ValueOf", "(", "v", ")", ";", "rv", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Bool", ",", "reflect", ...
// extensionAsLegacyType converts an value in the storage type as the API type. // See Extension.value.
[ "extensionAsLegacyType", "converts", "an", "value", "in", "the", "storage", "type", "as", "the", "API", "type", ".", "See", "Extension", ".", "value", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/extensions.go#L563-L582
131,792
golang/protobuf
descriptor/descriptor.go
extractFile
func extractFile(gz []byte) (*protobuf.FileDescriptorProto, error) { r, err := gzip.NewReader(bytes.NewReader(gz)) if err != nil { return nil, fmt.Errorf("failed to open gzip reader: %v", err) } defer r.Close() b, err := ioutil.ReadAll(r) if err != nil { return nil, fmt.Errorf("failed to uncompress descripto...
go
func extractFile(gz []byte) (*protobuf.FileDescriptorProto, error) { r, err := gzip.NewReader(bytes.NewReader(gz)) if err != nil { return nil, fmt.Errorf("failed to open gzip reader: %v", err) } defer r.Close() b, err := ioutil.ReadAll(r) if err != nil { return nil, fmt.Errorf("failed to uncompress descripto...
[ "func", "extractFile", "(", "gz", "[", "]", "byte", ")", "(", "*", "protobuf", ".", "FileDescriptorProto", ",", "error", ")", "{", "r", ",", "err", ":=", "gzip", ".", "NewReader", "(", "bytes", ".", "NewReader", "(", "gz", ")", ")", "\n", "if", "er...
// extractFile extracts a FileDescriptorProto from a gzip'd buffer.
[ "extractFile", "extracts", "a", "FileDescriptorProto", "from", "a", "gzip", "d", "buffer", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/descriptor/descriptor.go#L50-L68
131,793
golang/protobuf
descriptor/descriptor.go
ForMessage
func ForMessage(msg Message) (fd *protobuf.FileDescriptorProto, md *protobuf.DescriptorProto) { gz, path := msg.Descriptor() fd, err := extractFile(gz) if err != nil { panic(fmt.Sprintf("invalid FileDescriptorProto for %T: %v", msg, err)) } md = fd.MessageType[path[0]] for _, i := range path[1:] { md = md.Ne...
go
func ForMessage(msg Message) (fd *protobuf.FileDescriptorProto, md *protobuf.DescriptorProto) { gz, path := msg.Descriptor() fd, err := extractFile(gz) if err != nil { panic(fmt.Sprintf("invalid FileDescriptorProto for %T: %v", msg, err)) } md = fd.MessageType[path[0]] for _, i := range path[1:] { md = md.Ne...
[ "func", "ForMessage", "(", "msg", "Message", ")", "(", "fd", "*", "protobuf", ".", "FileDescriptorProto", ",", "md", "*", "protobuf", ".", "DescriptorProto", ")", "{", "gz", ",", "path", ":=", "msg", ".", "Descriptor", "(", ")", "\n", "fd", ",", "err",...
// ForMessage returns a FileDescriptorProto and a DescriptorProto from within it // describing the given message.
[ "ForMessage", "returns", "a", "FileDescriptorProto", "and", "a", "DescriptorProto", "from", "within", "it", "describing", "the", "given", "message", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/descriptor/descriptor.go#L81-L93
131,794
golang/protobuf
proto/pointer_unsafe.go
toPointer
func toPointer(i *Message) pointer { // Super-tricky - read pointer out of data word of interface value. // Saves ~25ns over the equivalent: // return valToPointer(reflect.ValueOf(*i)) return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} }
go
func toPointer(i *Message) pointer { // Super-tricky - read pointer out of data word of interface value. // Saves ~25ns over the equivalent: // return valToPointer(reflect.ValueOf(*i)) return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} }
[ "func", "toPointer", "(", "i", "*", "Message", ")", "pointer", "{", "// Super-tricky - read pointer out of data word of interface value.", "// Saves ~25ns over the equivalent:", "// return valToPointer(reflect.ValueOf(*i))", "return", "pointer", "{", "p", ":", "(", "*", "[", ...
// toPointer converts an interface of pointer type to a pointer // that points to the same target.
[ "toPointer", "converts", "an", "interface", "of", "pointer", "type", "to", "a", "pointer", "that", "points", "to", "the", "same", "target", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/pointer_unsafe.go#L79-L84
131,795
golang/protobuf
proto/pointer_unsafe.go
valToPointer
func valToPointer(v reflect.Value) pointer { return pointer{p: unsafe.Pointer(v.Pointer())} }
go
func valToPointer(v reflect.Value) pointer { return pointer{p: unsafe.Pointer(v.Pointer())} }
[ "func", "valToPointer", "(", "v", "reflect", ".", "Value", ")", "pointer", "{", "return", "pointer", "{", "p", ":", "unsafe", ".", "Pointer", "(", "v", ".", "Pointer", "(", ")", ")", "}", "\n", "}" ]
// valToPointer converts v to a pointer. v must be of pointer type.
[ "valToPointer", "converts", "v", "to", "a", "pointer", ".", "v", "must", "be", "of", "pointer", "type", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/pointer_unsafe.go#L106-L108
131,796
golang/protobuf
proto/pointer_unsafe.go
getPointer
func (p pointer) getPointer() pointer { return pointer{p: *(*unsafe.Pointer)(p.p)} }
go
func (p pointer) getPointer() pointer { return pointer{p: *(*unsafe.Pointer)(p.p)} }
[ "func", "(", "p", "pointer", ")", "getPointer", "(", ")", "pointer", "{", "return", "pointer", "{", "p", ":", "*", "(", "*", "unsafe", ".", "Pointer", ")", "(", "p", ".", "p", ")", "}", "\n", "}" ]
// getPointer loads the pointer at p and returns it.
[ "getPointer", "loads", "the", "pointer", "at", "p", "and", "returns", "it", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/pointer_unsafe.go#L262-L264
131,797
golang/protobuf
proto/pointer_unsafe.go
setPointer
func (p pointer) setPointer(q pointer) { *(*unsafe.Pointer)(p.p) = q.p }
go
func (p pointer) setPointer(q pointer) { *(*unsafe.Pointer)(p.p) = q.p }
[ "func", "(", "p", "pointer", ")", "setPointer", "(", "q", "pointer", ")", "{", "*", "(", "*", "unsafe", ".", "Pointer", ")", "(", "p", ".", "p", ")", "=", "q", ".", "p", "\n", "}" ]
// setPointer stores the pointer q at p.
[ "setPointer", "stores", "the", "pointer", "q", "at", "p", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/pointer_unsafe.go#L267-L269
131,798
golang/protobuf
proto/pointer_unsafe.go
appendPointer
func (p pointer) appendPointer(q pointer) { s := (*[]unsafe.Pointer)(p.p) *s = append(*s, q.p) }
go
func (p pointer) appendPointer(q pointer) { s := (*[]unsafe.Pointer)(p.p) *s = append(*s, q.p) }
[ "func", "(", "p", "pointer", ")", "appendPointer", "(", "q", "pointer", ")", "{", "s", ":=", "(", "*", "[", "]", "unsafe", ".", "Pointer", ")", "(", "p", ".", "p", ")", "\n", "*", "s", "=", "append", "(", "*", "s", ",", "q", ".", "p", ")", ...
// append q to the slice pointed to by p.
[ "append", "q", "to", "the", "slice", "pointed", "to", "by", "p", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/pointer_unsafe.go#L272-L275
131,799
golang/protobuf
proto/pointer_unsafe.go
asPointerTo
func (p pointer) asPointerTo(t reflect.Type) reflect.Value { return reflect.NewAt(t, p.p) }
go
func (p pointer) asPointerTo(t reflect.Type) reflect.Value { return reflect.NewAt(t, p.p) }
[ "func", "(", "p", "pointer", ")", "asPointerTo", "(", "t", "reflect", ".", "Type", ")", "reflect", ".", "Value", "{", "return", "reflect", ".", "NewAt", "(", "t", ",", "p", ".", "p", ")", "\n", "}" ]
// asPointerTo returns a reflect.Value that is a pointer to an // object of type t stored at p.
[ "asPointerTo", "returns", "a", "reflect", ".", "Value", "that", "is", "a", "pointer", "to", "an", "object", "of", "type", "t", "stored", "at", "p", "." ]
e91709a02e0e8ff8b86b7aa913fdc9ae9498e825
https://github.com/golang/protobuf/blob/e91709a02e0e8ff8b86b7aa913fdc9ae9498e825/proto/pointer_unsafe.go#L286-L288