id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c178800
return t.root.addRoute(httpMethod, pathExp, route, []string{}) }
c178801
t.root.printDebug(0) fmt.Print("</trie>\n") }
c178802
Route: node.HttpMethodToRoute[httpMethod], Params: context.paramsAsMap(), }, ) } } t.root.find(httpMethod, path, context) return matches }
c178803
&Match{ Route: node.HttpMethodToRoute[httpMethod], Params: context.paramsAsMap(), }, ) } } t.root.find(httpMethod, path, context) return matches, pathMatched }
c178804
matches = append( matches, &Match{ Route: route, Params: params, }, ) } } t.root.find("", path, context) return matches }
c178805
append(api.stack, middlewares...) }
c178806
} else { appFunc = func(w ResponseWriter, r *Request) {} } return http.HandlerFunc( adapterFunc( WrapMiddlewares(api.stack, appFunc), ), ) }
c178807
"" { poweredBy = mw.XPoweredBy } return func(w ResponseWriter, r *Request) { w.Header().Add("X-Powered-By", poweredBy) // call the handler h(w, r) } }
c178808
Env[\"ELAPSED_TIME\"] is nil, " + "TimerMiddleware may not be in the wrapped Middlewares.") } responseTime := r.Env["ELAPSED_TIME"].(*time.Duration) mw.lock.Lock() mw.responseCounts[fmt.Sprintf("%d", statusCode)]++ mw.totalResponseTime = mw.totalResponseTime.Add(*responseTime) mw.lock.Unlock() } }
c178809
now.String(), TimeUnix: now.Unix(), StatusCodeCount: mw.responseCounts, TotalCount: totalCount, TotalResponseTime: totalResponseTime.String(), TotalResponseTimeSec: totalResponseTime.Seconds(), AverageResponseTime: averageResponseTime.String(), AverageResponseTimeSec: averageResponseTime.Seconds(), } mw.lock.RUnlock() return status }
c178810
// TODO validate the callbackName ? if callbackName != "" { // the client request JSONP, instantiate JsonpMiddleware. writer := &jsonpResponseWriter{w, false, callbackName} // call the handler with the wrapped writer h(writer, r) } else { // do nothing special h(w, r) } } }
c178811
flusher := w.ResponseWriter.(http.Flusher) flusher.Flush() }
c178812
// call the handler h(w, r) mw.Logger.Printf("%s", makeAccessLogJsonRecord(r).asJson()) } }
c178813
if err != nil { return nil, fmt.Errorf("GET request failed (%s)", err) } //extract gz files if strings.HasSuffix(s.Key, ".gz") && aws.StringValue(get.ContentEncoding) != "gzip" { return gzip.NewReader(get.Body) } //success! return get.Body, nil }
c178814
os.Getenv(envBinCheckLegacy); token != "" { fmt.Fprint(os.Stdout, token) return true } return false }
c178815
if deadline not met waited := make(chan bool) go func() { l.wg.Wait() waited <- true }() go func() { select { case <-time.After(timeout): close(l.closeByForce) case <-waited: //no need to force close } }() }
c178816
delay := min - diff //ensures at least MinFetchInterval delay. //should be throttled by the fetcher! time.Sleep(delay) } } }
c178817
mp.fork(); err != nil { return err } } }
c178818
* time.Second } if err := f.updateHash(); err != nil { return err } return nil }
c178819
for { if attempt == total { file.Close() return nil, errors.New("file is currently being changed") } attempt++ //sleep time.Sleep(rate) //check hash! if err := f.updateHash(); err != nil { file.Close() return nil, err } //check until no longer changing if lastHash == f.hash { break } lastHash = f.hash } return file, nil }
c178820
using GET resp, err = http.Get(h.URL) if err != nil { return nil, fmt.Errorf("GET request failed (%s)", err) } if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("GET request failed (status code %d)", resp.StatusCode) } //extract gz files if strings.HasSuffix(h.URL, ".gz") && resp.Header.Get("Content-Encoding") != "gzip" { return gzip.NewReader(resp.Body) } //success! return resp.Body, nil }
c178821
= 3 c.Group.Offsets.Synchronization.DwellTime = c.Consumer.MaxProcessingTime c.Group.Session.Timeout = 30 * time.Second c.Group.Heartbeat.Interval = 3 * time.Second c.Config.Version = minVersion return c }
c178822
must be <= 10m") case c.Group.Heartbeat.Interval <= 0: return sarama.ConfigurationError("Group.Heartbeat.Interval must be > 0") case c.Group.Session.Timeout <= 0: return sarama.ConfigurationError("Group.Session.Timeout must be > 0") case !c.Metadata.Full && c.Group.Topics.Whitelist != nil: return sarama.ConfigurationError("Metadata.Full must be enabled when Group.Topics.Whitelist is used") case !c.Metadata.Full && c.Group.Topics.Blacklist != nil: return sarama.ConfigurationError("Metadata.Full must be enabled when Group.Topics.Blacklist is used") } // ensure offset is correct switch c.Consumer.Offsets.Initial { case sarama.OffsetOldest, sarama.OffsetNewest: default: return sarama.ConfigurationError("Consumer.Offsets.Initial must be either OffsetOldest or OffsetNewest") } return nil }
c178823
!= nil { return nil, err } client, err := sarama.NewClient(addrs, &config.Config) if err != nil { return nil, err } return &Client{Client: client, config: *config}, nil }
c178824
= c.PartitionConsumer.Close() close(c.dying) }) }
c178825
<-c.dead return c.closeErr }
c178826
= next c.state.Info.Metadata = metadata c.state.Dirty = true } c.mu.Unlock() }
c178827
:= NewConsumerFromClient(client, groupID, topics) if err != nil { return nil, err } consumer.ownClient = true return consumer, nil }
c178828
sub != nil { sub.MarkOffset(info.Offset, info.Metadata) } delete(s.offsets, tp) } }
c178829
{ if sub := c.subs.Fetch(msg.Topic, msg.Partition); sub != nil { sub.ResetOffset(msg.Offset, metadata) } }
c178830
for range c.errors { } for p := range c.partitions { _ = p.Close() } for range c.notifications { } c.client.release() if c.ownClient { if e := c.client.Close(); e != nil { err = e } } }) return }
c178831
return default: c.handleError(&Error{Ctx: "heartbeat", error: err}) return } case <-stopped: return case <-c.dying: return } } }
c178832
if !c.isKnownCoreTopic(topic) && !c.isKnownExtraTopic(topic) && c.isPotentialExtraTopic(topic) { return } } case <-stopped: return case <-c.dying: return } } }
c178833
c.handleError(&Error{Ctx: "commit", error: err}) return } case <-stopped: return case <-c.dying: return } } }
c178834
} } broker, err := c.client.Coordinator(c.groupID) if err != nil { c.closeCoordinator(broker, err) return nil, err } resp, err := broker.FetchOffset(req) if err != nil { c.closeCoordinator(broker, err) return nil, err } for topic, partitions := range subs { for _, partition := range partitions { block := resp.GetBlock(topic, partition) if block == nil { return nil, sarama.ErrIncompleteResponse } if block.Err == sarama.ErrNoError { offsets[topic][partition] = offsetInfo{Offset: block.Offset, Metadata: block.Metadata} } else { return nil, block.Err } } } return offsets, nil }
c178835
s.MarkPartitionOffset(msg.Topic, msg.Partition, msg.Offset, metadata) }
c178836
s.ResetPartitionOffset(msg.Topic, msg.Partition, msg.Offset, metadata) }
c178837
range s.offsets { res[tp.String()] = info.Offset } return res }
c178838
instances, err := Sdk.Service.Instances.List(immutable.ProviderConfig().CloudId, immutable.ProviderConfig().Location).Do() if err != nil { return nil, nil, err } count := len(instances.Items) if count > 0 { newResource.Count = count instance := instances.Items[0] newResource.Name = instance.Name newResource.CloudID = string(instance.Id) newResource.Size = instance.Kind newResource.Image = r.Image newResource.Location = instance.Zone } } newResource.BootstrapScripts = r.ServerPool.BootstrapScripts newResource.SSHFingerprint = immutable.ProviderConfig().SSH.PublicKeyFingerprint newResource.Name = r.Name r.CachedActual = newResource return immutable, newResource, nil }
c178839
Name: r.Name, CloudID: r.ServerPool.Identifier, }, Size: r.ServerPool.Size, Location: immutable.ProviderConfig().Location, Image: r.ServerPool.Image, Count: r.ServerPool.MaxCount, SSHFingerprint: immutable.ProviderConfig().SSH.PublicKeyFingerprint, BootstrapScripts: r.ServerPool.BootstrapScripts, } r.CachedExpected = expected return immutable, expected, nil }
c178840
_, err = Sdk.Service.InstanceTemplates.Get(immutable.ProviderConfig().CloudId, strings.ToLower(r.ServerPool.Name)).Do() if err == nil { err := r.retryDeleteInstanceTemplate(immutable) if err != nil { return nil, nil, err } } // Kubernetes API providerConfig := immutable.ProviderConfig() providerConfig.KubernetesAPI.Endpoint = "" immutable.SetProviderConfig(providerConfig) renderedCluster, err := r.immutableRender(actual, immutable) if err != nil { return nil, nil, err } return renderedCluster, actual, nil }
c178841
if err != nil { return nil, err } osr.Sdk = sdk return cloud.NewAtomicReconciler(known, osovh.NewOvhPublicModel(known)), nil case cluster.CloudPacket: sdk, err := packetSDK.NewSdk() if err != nil { return nil, err } packetr.Sdk = sdk return cloud.NewAtomicReconciler(known, packetpub.NewPacketPublicModel(known)), nil case cluster.CloudECS: sdk, err := openstackSdk.NewSdk(known.ProviderConfig().Location) if err != nil { return nil, err } osr.Sdk = sdk return cloud.NewAtomicReconciler(known, osecs.NewEcsPublicModel(known)), nil default: return nil, fmt.Errorf("Invalid cloud type: %s", known.ProviderConfig().Cloud) } }
c178842
BuildDate: time.Now().UTC().String(), GoVersion: runtime.Version(), GOOS: runtime.GOOS, GOArch: runtime.GOARCH, } }
c178843
to marshal version struct: %v", err) } return string(verBytes) }
c178844
} newResource.Location = *group.Location newResource.Name = *group.Name newResource.Identifier = *group.ID } newCluster := r.immutableRender(newResource, immutable) return newCluster, newResource, nil }
c178845
Name: immutable.Name, Tags: r.Tags, Identifier: immutable.ProviderConfig().GroupIdentifier, }, Location: immutable.ProviderConfig().Location, } newCluster := r.immutableRender(newResource, immutable) return newCluster, newResource, nil }
c178846
keySet, "C", viper.GetStringSlice(keySet), descSet) fs.StringArrayVarP(&co.MasterSet, keyMasterSet, "M", viper.GetStringSlice(keyMasterSet), descMasterSet) fs.StringArrayVarP(&co.NodeSet, keyNodeSet, "N", viper.GetStringSlice(keyNodeSet), descNodeSet) fs.StringVarP(&co.GitRemote, keyGitConfig, "g", viper.GetString(keyGitConfig), descGitConfig) fs.StringArrayVar(&co.AwsOptions.PolicyAttachments, keyPolicyAttachments, co.AwsOptions.PolicyAttachments, descPolicyAttachments) flagApplyAnnotations(createCmd, "profile", "__kubicorn_parse_profiles") flagApplyAnnotations(createCmd, "cloudid", "__kubicorn_parse_cloudid") createCmd.SetUsageTemplate(cli.UsageTemplate) return createCmd }
c178847
Size: "Standard_DS3_v2 ", BootstrapScripts: []string{}, Firewalls: []*cluster.Firewall{ { Name: fmt.Sprintf("%s-node", name), IngressRules: []*cluster.IngressRule{ { IngressToPort: "22", IngressSource: "0.0.0.0/0", IngressProtocol: "tcp", }, { IngressToPort: "1194", IngressSource: "0.0.0.0/0", IngressProtocol: "udp", }, }, EgressRules: []*cluster.EgressRule{ { EgressToPort: "all", // By default all egress from VM EgressDestination: "0.0.0.0/0", EgressProtocol: "tcp", }, { EgressToPort: "all", // By default all egress from VM EgressDestination: "0.0.0.0/0", EgressProtocol: "udp", }, }, }, }, }, }, } c := cluster.NewCluster(name) c.SetProviderConfig(controlPlaneProviderConfig) c.NewMachineSetsFromProviderConfigs(machineSetsProviderConfigs) return c }
c178848
err != nil { logger.Critical("Unable to unmarshal provider config: %v", err) } return providerConfig }
c178849
if err != nil { logger.Critical("Unable to marshal provider config: %v", err) return err } str := string(bytes) c.ClusterAPI.Spec.ProviderConfig = str return nil }
c178850
logger.Critical("Unable to unmarshal provider config: %v", err) } providerConfigs = append(providerConfigs, providerConfig) } return providerConfigs }
c178851
now if we have a machine provider config and we can't match it // we log a warning and move on. We might want to change this to create // the machineSet moving forward.. if !found { logger.Warning("Unable to match provider config to machine set: %s", name) } } }
c178852
Spec: clusterv1.ClusterSpec{}, }, ControlPlane: &clusterv1.MachineSet{}, } }
c178853
switch len(args) { case 0: dco.Name = viper.GetString(keyKubicornName) case 1: dco.Name = args[0] default: logger.Critical("Too many arguments.") os.Exit(1) } if err := runDeployController(dco); err != nil { logger.Critical(err.Error()) os.Exit(1) } }, } fs := deployControllerCmd.Flags() bindCommonStateStoreFlags(&dco.StateStoreOptions, fs) bindCommonAwsFlags(&dco.AwsOptions, fs) fs.StringVar(&dco.GitRemote, keyGitConfig, viper.GetString(keyGitConfig), descGitConfig) return deployControllerCmd }
c178854
return &Retrier{ retries: retries, sleepSeconds: sleepSeconds, retryable: retryable, } }
c178855
logger.Critical("detected signal. retry failed.") os.Exit(1) } } } }() for i := 0; i < r.retries; i++ { err := r.retryable.Try() if err != nil { logger.Info("Retryable error: %v", err) time.Sleep(time.Duration(r.sleepSeconds) * time.Second) continue } finish <- true return nil } finish <- true return fmt.Errorf("unable to succeed at retry after %d attempts at %d seconds", r.retries, r.sleepSeconds) }
c178856
panic("Could not generate random bytes") } return res }
c178857
exo.Name = args[0] default: logger.Critical("Too many arguments.") os.Exit(1) } if err := runExplain(exo); err != nil { logger.Critical(err.Error()) os.Exit(1) } }, } fs := cmd.Flags() bindCommonStateStoreFlags(&exo.StateStoreOptions, fs) bindCommonAwsFlags(&exo.AwsOptions, fs) fs.StringVarP(&exo.Output, keyOutput, "o", viper.GetString(keyOutput), descOutput) fs.StringVar(&exo.GitRemote, keyGitConfig, viper.GetString(keyGitConfig), descGitConfig) return cmd }
c178858
rand.MustGenerateRandomBytes(2), rand.MustGenerateRandomBytes(2), rand.MustGenerateRandomBytes(4)) }
c178859
switch len(args) { case 0: cro.Name = viper.GetString(keyKubicornName) case 1: cro.Name = args[0] default: logger.Critical("Too many arguments.") os.Exit(1) } if err := runGetConfig(cro); err != nil { logger.Critical(err.Error()) os.Exit(1) } }, } fs := getConfigCmd.Flags() bindCommonStateStoreFlags(&cro.StateStoreOptions, fs) bindCommonAwsFlags(&cro.AwsOptions, fs) fs.StringVar(&cro.GitRemote, keyGitConfig, viper.GetString(keyGitConfig), descGitConfig) return getConfigCmd }
c178860
= value } } go func() { errCh <- task() }() l(description) logActivity(symbol, l, t, doneCh) err := <-errCh doneCh <- true return err }
c178861
:= cmd.Flags() bindCommonStateStoreFlags(&lo.StateStoreOptions, fs) bindCommonAwsFlags(&lo.AwsOptions, fs) fs.BoolVarP(&noHeaders, keyNoHeaders, "n", viper.GetBool(keyNoHeaders), desNoHeaders) return cmd }
c178862
}, }, }, { ServerPool: &cluster.ServerPool{ Type: cluster.ServerPoolTypeNode, Name: fmt.Sprintf("%s.node", name), MaxCount: 1, MinCount: 1, Image: "ubuntu_16_04", Size: "baremetal_2", BootstrapScripts: []string{ "bootstrap/packet_k8s_ubuntu_16.04_node.sh", }, }, }, } c := cluster.NewCluster(name) c.SetProviderConfig(controlPlaneProviderConfig) c.NewMachineSetsFromProviderConfigs(machineSetsProviderConfigs) return c }
c178863
default: logger.Critical("Too many arguments.") os.Exit(1) } if err := runEdit(eo); err != nil { logger.Critical(err.Error()) os.Exit(1) } }, } fs := editCmd.Flags() bindCommonStateStoreFlags(&eo.StateStoreOptions, fs) bindCommonAwsFlags(&eo.AwsOptions, fs) fs.StringVarP(&eo.Editor, keyEditor, "e", viper.GetString(keyEditor), descEditor) fs.StringVar(&eo.GitRemote, keyGitConfig, viper.GetString(keyGitConfig), descGitConfig) return editCmd }
c178864
error { return k.Agent.Remove(key) }
c178865
_ := ssh.ParseAuthorizedKey(p) if err != nil { return err } return k.RemoveKey(key) }
c178866
// hack: DO api doesn't take "0" as portRange, but returns "0" for port range in firewall.List. for i := 0; i < len(newResource.OutboundRules); i++ { if newResource.OutboundRules[i].PortRange == "0" { newResource.OutboundRules[i].PortRange = "all" } } for i := 0; i < len(newResource.InboundRules); i++ { if newResource.InboundRules[i].PortRange == "0" { newResource.InboundRules[i].PortRange = "all" } } } } newCluster := r.immutableRender(newResource, immutable) return newCluster, newResource, nil }
c178867
r.Status, Created: r.Created, } //logger.Info("Expected firewall returned is %+v", immutable) newCluster := r.immutableRender(newResource, immutable) return newCluster, newResource, nil }
c178868
0; i <= TagsGetAttempts; i++ { active := true droplets, _, err := Sdk.Client.Droplets.ListByTag(context.TODO(), machineProviderConfig.ServerPool.Name, &godo.ListOptions{}) if err != nil { logger.Debug("Hanging for droplets to get created.. (%v)", err) time.Sleep(time.Duration(TagsGetTimeout) * time.Second) continue } if len(droplets) == 0 { continue } for _, d := range droplets { if d.Status != "active" { active = false break } } if !active { logger.Debug("Waiting for droplets to become active..") time.Sleep(time.Duration(TagsGetTimeout) * time.Second) continue } break } } firewall, _, err := Sdk.Client.Firewalls.Create(context.TODO(), &firewallRequest) if err != nil { return nil, nil, fmt.Errorf("failed to create the firewall err: %v", err) } logger.Success("Created Firewall [%s]", firewall.ID) newResource := &Firewall{ Shared: Shared{ CloudID: firewall.ID, Name: r.Name, Tags: r.Tags, }, DropletIDs: r.DropletIDs, FirewallID: firewall.ID, InboundRules: r.InboundRules, OutboundRules: r.OutboundRules, Created: r.Created, } newCluster := r.immutableRender(newResource, immutable) return newCluster, newResource, nil }
c178869
firewall [%s]", deleteResource.FirewallID) newResource := &Firewall{ Shared: Shared{ Name: r.Name, Tags: r.Tags, }, InboundRules: r.InboundRules, OutboundRules: r.OutboundRules, Created: r.Created, } newCluster := r.immutableRender(newResource, immutable) return newCluster, newResource, nil }
c178870
runDelete(do); err != nil { logger.Critical(err.Error()) os.Exit(1) } }, } fs := deleteCmd.Flags() bindCommonStateStoreFlags(&do.StateStoreOptions, fs) bindCommonAwsFlags(&do.AwsOptions, fs) fs.StringVar(&do.AwsProfile, keyAwsProfile, viper.GetString(keyAwsProfile), descAwsProfile) fs.StringVar(&do.GitRemote, keyGitConfig, viper.GetString(keyGitConfig), descGitConfig) fs.BoolVarP(&do.Purge, keyPurge, "p", viper.GetBool(keyPurge), descPurge) return deleteCmd }
c178871
options.StateStorePath, ClusterName: options.Name, }) case "s3": logger.Info("Selected [s3] state store") client, err := minio.New(options.BucketEndpointURL, options.S3AccessKey, options.S3SecretKey, options.BucketSSL) if err != nil { return nil, err } stateStore = s3.NewJSONFS3Store(&s3.JSONS3StoreOptions{ BasePath: options.StateStorePath, ClusterName: options.Name, Client: client, BucketOptions: &s3.S3BucketOptions{ EndpointURL: options.BucketEndpointURL, BucketName: options.BucketName, }, }) default: return nil, fmt.Errorf("state store [%s] has an invalid type [%s]", options.Name, options.StateStore) } return stateStore, nil }
c178872
//commits the changes r, err := g.NewFilesystemRepository(state.ClusterJSONFile) if err != nil { return err } // Add a new remote, with the default fetch refspec _, err = r.CreateRemote(&config.RemoteConfig{ Name: git.ClusterName, URL: git.options.CommitConfig.Remote, }) _, err = r.Commits() if err != nil { return err } return nil }
c178873
} }, } fs := applyCmd.Flags() bindCommonStateStoreFlags(&ao.StateStoreOptions, fs) bindCommonAwsFlags(&ao.AwsOptions, fs) fs.StringArrayVarP(&ao.Set, keyKubicornSet, "e", viper.GetStringSlice(keyKubicornSet), descSet) fs.StringVar(&ao.AwsProfile, keyAwsProfile, viper.GetString(keyAwsProfile), descAwsProfile) fs.StringVar(&ao.GitRemote, keyGitConfig, viper.GetString(keyGitConfig), descGitConfig) return applyCmd }
c178874
logger.Critical("Unable to use user.Current() for user. Maybe a cross compile issue: %v", err) return "" } path = homeUser.HomeDir } } return path }
c178875
.bashrc/.zshrc: source $(brew --prefix)/etc/bash_completion`, RunE: func(cmd *cobra.Command, args []string) error { if logger.Fabulous { cmd.SetOutput(logger.FabulousWriter) } if viper.GetString(keyTrueColor) != "" { cmd.SetOutput(logger.FabulousWriter) } switch len(args) { case 0: return fmt.Errorf("shell argument is not specified") default: switch args[0] { case "bash": return runBashGeneration() case "zsh": return runZshGeneration() default: return fmt.Errorf("invalid shell argument") } } }, } }
c178876
This command will query cloud resources and attempt to build a representation of the cluster in the Kubicorn API model. Once the cluster has been adopted, a user can manage and scale their Kubernetes cluster with Kubicorn.`, Run: func(cmd *cobra.Command, args []string) { fmt.Println("adopt called") }, } }
c178877
val := os.Getenv(env) if val == "" { return def } return val }
c178878
ival, err := strconv.Atoi(val) if err != nil { return def } return ival }
c178879
} b, err := strconv.ParseBool(val) if err != nil { return def } return b }
c178880
return "", fmt.Errorf("Could not find $HOME") } sourcePath = filepath.Join(homeDir, sourcePath[1:]) } bytes, err := ioutil.ReadFile(sourcePath) if err != nil { return "", err } return string(bytes), nil }
c178881
binary.`, Run: func(cmd *cobra.Command, args []string) { fmt.Printf("%s\n", version.GetVersionJSON()) }, } }
c178882
os.Interrupt, os.Kill) return &Handler{ timeoutSeconds: timeoutSeconds, signals: signals, signalReceived: 0, } }
c178883
os.Exit(130) break case s == syscall.SIGQUIT: h.signalReceived = signalAbort break case s == syscall.SIGTERM: h.signalReceived = signalTerminate os.Exit(3) break } case <-h.timer.C: os.Exit(4) break } } }() }
c178884
[]*cluster.Subnet{ { Name: "internal", CIDR: "192.168.200.0/24", }, }, Firewalls: []*cluster.Firewall{ { Name: masterName, IngressRules: []*cluster.IngressRule{ { IngressFromPort: "22", IngressToPort: "22", IngressSource: "0.0.0.0/0", IngressProtocol: "tcp", }, { IngressFromPort: "443", IngressToPort: "443", IngressSource: "0.0.0.0/0", IngressProtocol: "tcp", }, { IngressSource: "192.168.200.0/24", }, }, }, }, }, }, { ServerPool: &cluster.ServerPool{ Type: cluster.ServerPoolTypeNode, Name: nodeName, MaxCount: 2, Image: "GNU/Linux Ubuntu Server 16.04 Xenial Xerus x64", Size: "e3standard.x3", BootstrapScripts: []string{ "bootstrap/ecs_k8s_ubuntu_16.04_node.sh", }, Firewalls: []*cluster.Firewall{ { Name: nodeName, IngressRules: []*cluster.IngressRule{ { IngressFromPort: "22", IngressToPort: "22", IngressSource: "0.0.0.0/0", IngressProtocol: "tcp", }, { IngressSource: "192.168.200.0/24", }, }, }, }, }, }, } c := cluster.NewCluster(name) c.SetProviderConfig(controlPlaneProviderConfig) c.NewMachineSetsFromProviderConfigs(machineSetsProviderConfigs) return c }
c178885
m, d, now.Time.Hour(), 0, 0, 0, now.Time.Location()) }
c178886
return time.Date(y, m, d, 0, 0, 0, 0, now.Time.Location()) }
c178887
7 - weekStartDayInt } else { weekday = weekday - weekStartDayInt } } return t.AddDate(0, 0, -weekday) }
c178888
return time.Date(y, m, 1, 0, 0, 0, 0, now.Location()) }
c178889
- 1) % 3 return month.AddDate(0, -offset, 0) }
c178890
time.Date(y, time.January, 1, 0, 0, 0, 0, now.Location()) }
c178891
now.BeginningOfMinute().Add(time.Minute - time.Nanosecond) }
c178892
now.BeginningOfHour().Add(time.Hour - time.Nanosecond) }
c178893
return time.Date(y, m, d, 23, 59, 59, int(time.Second-time.Nanosecond), now.Location()) }
c178894
now.BeginningOfWeek().AddDate(0, 0, 7).Add(-time.Nanosecond) }
c178895
now.BeginningOfMonth().AddDate(0, 1, 0).Add(-time.Nanosecond) }
c178896
now.BeginningOfQuarter().AddDate(0, 3, 0).Add(-time.Nanosecond) }
c178897
now.BeginningOfYear().AddDate(1, 0, 0).Add(-time.Nanosecond) }
c178898
{ t, err := now.Parse(strs...) if err != nil { panic(err) } return t }
c178899
return now.After(beginTime) && now.Before(endTime) }