repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
jpillora/overseer | fetcher/fetcher_s3.go | Fetch | func (s *S3) Fetch() (io.Reader, error) {
//delay fetches after first
if s.delay {
time.Sleep(s.Interval)
}
s.delay = true
//status check using HEAD
head, err := s.client.HeadObject(&s3.HeadObjectInput{Bucket: &s.Bucket, Key: &s.Key})
if err != nil {
return nil, fmt.Errorf("HEAD request failed (%s)", err)
}... | go | func (s *S3) Fetch() (io.Reader, error) {
//delay fetches after first
if s.delay {
time.Sleep(s.Interval)
}
s.delay = true
//status check using HEAD
head, err := s.client.HeadObject(&s3.HeadObjectInput{Bucket: &s.Bucket, Key: &s.Key})
if err != nil {
return nil, fmt.Errorf("HEAD request failed (%s)", err)
}... | [
"func",
"(",
"s",
"*",
"S3",
")",
"Fetch",
"(",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"if",
"s",
".",
"delay",
"{",
"time",
".",
"Sleep",
"(",
"s",
".",
"Interval",
")",
"\n",
"}",
"\n",
"s",
".",
"delay",
"=",
"true",
"\n"... | // Fetch the binary from S3 | [
"Fetch",
"the",
"binary",
"from",
"S3"
] | ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a | https://github.com/jpillora/overseer/blob/ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a/fetcher/fetcher_s3.go#L63-L89 | test |
jpillora/overseer | overseer.go | sanityCheck | func sanityCheck() bool {
//sanity check
if token := os.Getenv(envBinCheck); token != "" {
fmt.Fprint(os.Stdout, token)
return true
}
//legacy sanity check using old env var
if token := os.Getenv(envBinCheckLegacy); token != "" {
fmt.Fprint(os.Stdout, token)
return true
}
return false
} | go | func sanityCheck() bool {
//sanity check
if token := os.Getenv(envBinCheck); token != "" {
fmt.Fprint(os.Stdout, token)
return true
}
//legacy sanity check using old env var
if token := os.Getenv(envBinCheckLegacy); token != "" {
fmt.Fprint(os.Stdout, token)
return true
}
return false
} | [
"func",
"sanityCheck",
"(",
")",
"bool",
"{",
"if",
"token",
":=",
"os",
".",
"Getenv",
"(",
"envBinCheck",
")",
";",
"token",
"!=",
"\"\"",
"{",
"fmt",
".",
"Fprint",
"(",
"os",
".",
"Stdout",
",",
"token",
")",
"\n",
"return",
"true",
"\n",
"}",
... | //sanityCheck returns true if a check was performed | [
"sanityCheck",
"returns",
"true",
"if",
"a",
"check",
"was",
"performed"
] | ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a | https://github.com/jpillora/overseer/blob/ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a/overseer.go#L113-L125 | test |
jpillora/overseer | graceful.go | release | func (l *overseerListener) release(timeout time.Duration) {
//stop accepting connections - release fd
l.closeError = l.Listener.Close()
//start timer, close by force if deadline not met
waited := make(chan bool)
go func() {
l.wg.Wait()
waited <- true
}()
go func() {
select {
case <-time.After(timeout):
... | go | func (l *overseerListener) release(timeout time.Duration) {
//stop accepting connections - release fd
l.closeError = l.Listener.Close()
//start timer, close by force if deadline not met
waited := make(chan bool)
go func() {
l.wg.Wait()
waited <- true
}()
go func() {
select {
case <-time.After(timeout):
... | [
"func",
"(",
"l",
"*",
"overseerListener",
")",
"release",
"(",
"timeout",
"time",
".",
"Duration",
")",
"{",
"l",
".",
"closeError",
"=",
"l",
".",
"Listener",
".",
"Close",
"(",
")",
"\n",
"waited",
":=",
"make",
"(",
"chan",
"bool",
")",
"\n",
"... | //non-blocking trigger close | [
"non",
"-",
"blocking",
"trigger",
"close"
] | ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a | https://github.com/jpillora/overseer/blob/ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a/graceful.go#L55-L72 | test |
jpillora/overseer | proc_master.go | fetchLoop | func (mp *master) fetchLoop() {
min := mp.Config.MinFetchInterval
time.Sleep(min)
for {
t0 := time.Now()
mp.fetch()
//duration fetch of fetch
diff := time.Now().Sub(t0)
if diff < min {
delay := min - diff
//ensures at least MinFetchInterval delay.
//should be throttled by the fetcher!
time.Slee... | go | func (mp *master) fetchLoop() {
min := mp.Config.MinFetchInterval
time.Sleep(min)
for {
t0 := time.Now()
mp.fetch()
//duration fetch of fetch
diff := time.Now().Sub(t0)
if diff < min {
delay := min - diff
//ensures at least MinFetchInterval delay.
//should be throttled by the fetcher!
time.Slee... | [
"func",
"(",
"mp",
"*",
"master",
")",
"fetchLoop",
"(",
")",
"{",
"min",
":=",
"mp",
".",
"Config",
".",
"MinFetchInterval",
"\n",
"time",
".",
"Sleep",
"(",
"min",
")",
"\n",
"for",
"{",
"t0",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"mp",
"... | //fetchLoop is run in a goroutine | [
"fetchLoop",
"is",
"run",
"in",
"a",
"goroutine"
] | ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a | https://github.com/jpillora/overseer/blob/ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a/proc_master.go#L181-L196 | test |
jpillora/overseer | proc_master.go | forkLoop | func (mp *master) forkLoop() error {
//loop, restart command
for {
if err := mp.fork(); err != nil {
return err
}
}
} | go | func (mp *master) forkLoop() error {
//loop, restart command
for {
if err := mp.fork(); err != nil {
return err
}
}
} | [
"func",
"(",
"mp",
"*",
"master",
")",
"forkLoop",
"(",
")",
"error",
"{",
"for",
"{",
"if",
"err",
":=",
"mp",
".",
"fork",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | //not a real fork | [
"not",
"a",
"real",
"fork"
] | ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a | https://github.com/jpillora/overseer/blob/ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a/proc_master.go#L336-L343 | test |
jpillora/overseer | fetcher/fetcher_file.go | Init | func (f *File) Init() error {
if f.Path == "" {
return fmt.Errorf("Path required")
}
if f.Interval < 1*time.Second {
f.Interval = 1 * time.Second
}
if err := f.updateHash(); err != nil {
return err
}
return nil
} | go | func (f *File) Init() error {
if f.Path == "" {
return fmt.Errorf("Path required")
}
if f.Interval < 1*time.Second {
f.Interval = 1 * time.Second
}
if err := f.updateHash(); err != nil {
return err
}
return nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Init",
"(",
")",
"error",
"{",
"if",
"f",
".",
"Path",
"==",
"\"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"Path required\"",
")",
"\n",
"}",
"\n",
"if",
"f",
".",
"Interval",
"<",
"1",
"*",
"time",
".... | // Init sets the Path and Interval options | [
"Init",
"sets",
"the",
"Path",
"and",
"Interval",
"options"
] | ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a | https://github.com/jpillora/overseer/blob/ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a/fetcher/fetcher_file.go#L24-L35 | test |
jpillora/overseer | fetcher/fetcher_file.go | Fetch | func (f *File) Fetch() (io.Reader, error) {
//only delay after first fetch
if f.delay {
time.Sleep(f.Interval)
}
f.delay = true
lastHash := f.hash
if err := f.updateHash(); err != nil {
return nil, err
}
// no change
if lastHash == f.hash {
return nil, nil
}
// changed!
file, err := os.Open(f.Path)
i... | go | func (f *File) Fetch() (io.Reader, error) {
//only delay after first fetch
if f.delay {
time.Sleep(f.Interval)
}
f.delay = true
lastHash := f.hash
if err := f.updateHash(); err != nil {
return nil, err
}
// no change
if lastHash == f.hash {
return nil, nil
}
// changed!
file, err := os.Open(f.Path)
i... | [
"func",
"(",
"f",
"*",
"File",
")",
"Fetch",
"(",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"if",
"f",
".",
"delay",
"{",
"time",
".",
"Sleep",
"(",
"f",
".",
"Interval",
")",
"\n",
"}",
"\n",
"f",
".",
"delay",
"=",
"true",
"\... | // Fetch file from the specified Path | [
"Fetch",
"file",
"from",
"the",
"specified",
"Path"
] | ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a | https://github.com/jpillora/overseer/blob/ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a/fetcher/fetcher_file.go#L38-L82 | test |
jpillora/overseer | fetcher/fetcher_http.go | Fetch | func (h *HTTP) Fetch() (io.Reader, error) {
//delay fetches after first
if h.delay {
time.Sleep(h.Interval)
}
h.delay = true
//status check using HEAD
resp, err := http.Head(h.URL)
if err != nil {
return nil, fmt.Errorf("HEAD request failed (%s)", err)
}
resp.Body.Close()
if resp.StatusCode != http.Status... | go | func (h *HTTP) Fetch() (io.Reader, error) {
//delay fetches after first
if h.delay {
time.Sleep(h.Interval)
}
h.delay = true
//status check using HEAD
resp, err := http.Head(h.URL)
if err != nil {
return nil, fmt.Errorf("HEAD request failed (%s)", err)
}
resp.Body.Close()
if resp.StatusCode != http.Status... | [
"func",
"(",
"h",
"*",
"HTTP",
")",
"Fetch",
"(",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"if",
"h",
".",
"delay",
"{",
"time",
".",
"Sleep",
"(",
"h",
".",
"Interval",
")",
"\n",
"}",
"\n",
"h",
".",
"delay",
"=",
"true",
"\... | // Fetch the binary from the provided URL | [
"Fetch",
"the",
"binary",
"from",
"the",
"provided",
"URL"
] | ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a | https://github.com/jpillora/overseer/blob/ce9055846616cf7e1ab91bb8a0bcbb1d7fa3d11a/fetcher/fetcher_http.go#L45-L88 | test |
bsm/sarama-cluster | config.go | NewConfig | func NewConfig() *Config {
c := &Config{
Config: *sarama.NewConfig(),
}
c.Group.PartitionStrategy = StrategyRange
c.Group.Offsets.Retry.Max = 3
c.Group.Offsets.Synchronization.DwellTime = c.Consumer.MaxProcessingTime
c.Group.Session.Timeout = 30 * time.Second
c.Group.Heartbeat.Interval = 3 * time.Second
c.Con... | go | func NewConfig() *Config {
c := &Config{
Config: *sarama.NewConfig(),
}
c.Group.PartitionStrategy = StrategyRange
c.Group.Offsets.Retry.Max = 3
c.Group.Offsets.Synchronization.DwellTime = c.Consumer.MaxProcessingTime
c.Group.Session.Timeout = 30 * time.Second
c.Group.Heartbeat.Interval = 3 * time.Second
c.Con... | [
"func",
"NewConfig",
"(",
")",
"*",
"Config",
"{",
"c",
":=",
"&",
"Config",
"{",
"Config",
":",
"*",
"sarama",
".",
"NewConfig",
"(",
")",
",",
"}",
"\n",
"c",
".",
"Group",
".",
"PartitionStrategy",
"=",
"StrategyRange",
"\n",
"c",
".",
"Group",
... | // NewConfig returns a new configuration instance with sane defaults. | [
"NewConfig",
"returns",
"a",
"new",
"configuration",
"instance",
"with",
"sane",
"defaults",
"."
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/config.go#L87-L98 | test |
bsm/sarama-cluster | config.go | Validate | func (c *Config) Validate() error {
if c.Group.Heartbeat.Interval%time.Millisecond != 0 {
sarama.Logger.Println("Group.Heartbeat.Interval only supports millisecond precision; nanoseconds will be truncated.")
}
if c.Group.Session.Timeout%time.Millisecond != 0 {
sarama.Logger.Println("Group.Session.Timeout only su... | go | func (c *Config) Validate() error {
if c.Group.Heartbeat.Interval%time.Millisecond != 0 {
sarama.Logger.Println("Group.Heartbeat.Interval only supports millisecond precision; nanoseconds will be truncated.")
}
if c.Group.Session.Timeout%time.Millisecond != 0 {
sarama.Logger.Println("Group.Session.Timeout only su... | [
"func",
"(",
"c",
"*",
"Config",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"c",
".",
"Group",
".",
"Heartbeat",
".",
"Interval",
"%",
"time",
".",
"Millisecond",
"!=",
"0",
"{",
"sarama",
".",
"Logger",
".",
"Println",
"(",
"\"Group.Heartbeat.Inte... | // Validate checks a Config instance. It will return a
// sarama.ConfigurationError if the specified values don't make sense. | [
"Validate",
"checks",
"a",
"Config",
"instance",
".",
"It",
"will",
"return",
"a",
"sarama",
".",
"ConfigurationError",
"if",
"the",
"specified",
"values",
"don",
"t",
"make",
"sense",
"."
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/config.go#L102-L146 | test |
bsm/sarama-cluster | client.go | NewClient | func NewClient(addrs []string, config *Config) (*Client, error) {
if config == nil {
config = NewConfig()
}
if err := config.Validate(); err != nil {
return nil, err
}
client, err := sarama.NewClient(addrs, &config.Config)
if err != nil {
return nil, err
}
return &Client{Client: client, config: *config... | go | func NewClient(addrs []string, config *Config) (*Client, error) {
if config == nil {
config = NewConfig()
}
if err := config.Validate(); err != nil {
return nil, err
}
client, err := sarama.NewClient(addrs, &config.Config)
if err != nil {
return nil, err
}
return &Client{Client: client, config: *config... | [
"func",
"NewClient",
"(",
"addrs",
"[",
"]",
"string",
",",
"config",
"*",
"Config",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"config",
"=",
"NewConfig",
"(",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"con... | // NewClient creates a new client instance | [
"NewClient",
"creates",
"a",
"new",
"client",
"instance"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/client.go#L21-L36 | test |
bsm/sarama-cluster | partitions.go | AsyncClose | func (c *partitionConsumer) AsyncClose() {
c.closeOnce.Do(func() {
c.closeErr = c.PartitionConsumer.Close()
close(c.dying)
})
} | go | func (c *partitionConsumer) AsyncClose() {
c.closeOnce.Do(func() {
c.closeErr = c.PartitionConsumer.Close()
close(c.dying)
})
} | [
"func",
"(",
"c",
"*",
"partitionConsumer",
")",
"AsyncClose",
"(",
")",
"{",
"c",
".",
"closeOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"c",
".",
"closeErr",
"=",
"c",
".",
"PartitionConsumer",
".",
"Close",
"(",
")",
"\n",
"close",
"(",
"c",
... | // AsyncClose implements PartitionConsumer | [
"AsyncClose",
"implements",
"PartitionConsumer"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/partitions.go#L87-L92 | test |
bsm/sarama-cluster | partitions.go | Close | func (c *partitionConsumer) Close() error {
c.AsyncClose()
<-c.dead
return c.closeErr
} | go | func (c *partitionConsumer) Close() error {
c.AsyncClose()
<-c.dead
return c.closeErr
} | [
"func",
"(",
"c",
"*",
"partitionConsumer",
")",
"Close",
"(",
")",
"error",
"{",
"c",
".",
"AsyncClose",
"(",
")",
"\n",
"<-",
"c",
".",
"dead",
"\n",
"return",
"c",
".",
"closeErr",
"\n",
"}"
] | // Close implements PartitionConsumer | [
"Close",
"implements",
"PartitionConsumer"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/partitions.go#L95-L99 | test |
bsm/sarama-cluster | partitions.go | MarkOffset | func (c *partitionConsumer) MarkOffset(offset int64, metadata string) {
c.mu.Lock()
if next := offset + 1; next > c.state.Info.Offset {
c.state.Info.Offset = next
c.state.Info.Metadata = metadata
c.state.Dirty = true
}
c.mu.Unlock()
} | go | func (c *partitionConsumer) MarkOffset(offset int64, metadata string) {
c.mu.Lock()
if next := offset + 1; next > c.state.Info.Offset {
c.state.Info.Offset = next
c.state.Info.Metadata = metadata
c.state.Dirty = true
}
c.mu.Unlock()
} | [
"func",
"(",
"c",
"*",
"partitionConsumer",
")",
"MarkOffset",
"(",
"offset",
"int64",
",",
"metadata",
"string",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"next",
":=",
"offset",
"+",
"1",
";",
"next",
">",
"c",
".",
"state",
... | // MarkOffset implements PartitionConsumer | [
"MarkOffset",
"implements",
"PartitionConsumer"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/partitions.go#L161-L169 | test |
bsm/sarama-cluster | consumer.go | NewConsumer | func NewConsumer(addrs []string, groupID string, topics []string, config *Config) (*Consumer, error) {
client, err := NewClient(addrs, config)
if err != nil {
return nil, err
}
consumer, err := NewConsumerFromClient(client, groupID, topics)
if err != nil {
return nil, err
}
consumer.ownClient = true
return... | go | func NewConsumer(addrs []string, groupID string, topics []string, config *Config) (*Consumer, error) {
client, err := NewClient(addrs, config)
if err != nil {
return nil, err
}
consumer, err := NewConsumerFromClient(client, groupID, topics)
if err != nil {
return nil, err
}
consumer.ownClient = true
return... | [
"func",
"NewConsumer",
"(",
"addrs",
"[",
"]",
"string",
",",
"groupID",
"string",
",",
"topics",
"[",
"]",
"string",
",",
"config",
"*",
"Config",
")",
"(",
"*",
"Consumer",
",",
"error",
")",
"{",
"client",
",",
"err",
":=",
"NewClient",
"(",
"addr... | // NewConsumer initializes a new consumer | [
"NewConsumer",
"initializes",
"a",
"new",
"consumer"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L43-L55 | test |
bsm/sarama-cluster | consumer.go | MarkOffsets | func (c *Consumer) MarkOffsets(s *OffsetStash) {
s.mu.Lock()
defer s.mu.Unlock()
for tp, info := range s.offsets {
if sub := c.subs.Fetch(tp.Topic, tp.Partition); sub != nil {
sub.MarkOffset(info.Offset, info.Metadata)
}
delete(s.offsets, tp)
}
} | go | func (c *Consumer) MarkOffsets(s *OffsetStash) {
s.mu.Lock()
defer s.mu.Unlock()
for tp, info := range s.offsets {
if sub := c.subs.Fetch(tp.Topic, tp.Partition); sub != nil {
sub.MarkOffset(info.Offset, info.Metadata)
}
delete(s.offsets, tp)
}
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"MarkOffsets",
"(",
"s",
"*",
"OffsetStash",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"tp",
",",
"info",
":=",
"range",
"s",
... | // MarkOffsets marks stashed offsets as processed.
// See MarkOffset for additional explanation. | [
"MarkOffsets",
"marks",
"stashed",
"offsets",
"as",
"processed",
".",
"See",
"MarkOffset",
"for",
"additional",
"explanation",
"."
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L158-L168 | test |
bsm/sarama-cluster | consumer.go | ResetOffset | func (c *Consumer) ResetOffset(msg *sarama.ConsumerMessage, metadata string) {
if sub := c.subs.Fetch(msg.Topic, msg.Partition); sub != nil {
sub.ResetOffset(msg.Offset, metadata)
}
} | go | func (c *Consumer) ResetOffset(msg *sarama.ConsumerMessage, metadata string) {
if sub := c.subs.Fetch(msg.Topic, msg.Partition); sub != nil {
sub.ResetOffset(msg.Offset, metadata)
}
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"ResetOffset",
"(",
"msg",
"*",
"sarama",
".",
"ConsumerMessage",
",",
"metadata",
"string",
")",
"{",
"if",
"sub",
":=",
"c",
".",
"subs",
".",
"Fetch",
"(",
"msg",
".",
"Topic",
",",
"msg",
".",
"Partition",
... | // ResetOffset marks the provided message as processed, alongside a metadata string
// that represents the state of the partition consumer at that point in time. The
// metadata string can be used by another consumer to restore that state, so it
// can resume consumption.
//
// Difference between ResetOffset and MarkOf... | [
"ResetOffset",
"marks",
"the",
"provided",
"message",
"as",
"processed",
"alongside",
"a",
"metadata",
"string",
"that",
"represents",
"the",
"state",
"of",
"the",
"partition",
"consumer",
"at",
"that",
"point",
"in",
"time",
".",
"The",
"metadata",
"string",
... | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L176-L180 | test |
bsm/sarama-cluster | consumer.go | Close | func (c *Consumer) Close() (err error) {
c.closeOnce.Do(func() {
close(c.dying)
<-c.dead
if e := c.release(); e != nil {
err = e
}
if e := c.consumer.Close(); e != nil {
err = e
}
close(c.messages)
close(c.errors)
if e := c.leaveGroup(); e != nil {
err = e
}
close(c.partitions)
close... | go | func (c *Consumer) Close() (err error) {
c.closeOnce.Do(func() {
close(c.dying)
<-c.dead
if e := c.release(); e != nil {
err = e
}
if e := c.consumer.Close(); e != nil {
err = e
}
close(c.messages)
close(c.errors)
if e := c.leaveGroup(); e != nil {
err = e
}
close(c.partitions)
close... | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"Close",
"(",
")",
"(",
"err",
"error",
")",
"{",
"c",
".",
"closeOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"close",
"(",
"c",
".",
"dying",
")",
"\n",
"<-",
"c",
".",
"dead",
"\n",
"if",
"e",
":=... | // Close safely closes the consumer and releases all resources | [
"Close",
"safely",
"closes",
"the",
"consumer",
"and",
"releases",
"all",
"resources"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L272-L311 | test |
bsm/sarama-cluster | consumer.go | hbLoop | func (c *Consumer) hbLoop(stopped <-chan none) {
ticker := time.NewTicker(c.client.config.Group.Heartbeat.Interval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
switch err := c.heartbeat(); err {
case nil, sarama.ErrNoError:
case sarama.ErrNotCoordinatorForConsumer, sarama.ErrRebalanceInProgress... | go | func (c *Consumer) hbLoop(stopped <-chan none) {
ticker := time.NewTicker(c.client.config.Group.Heartbeat.Interval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
switch err := c.heartbeat(); err {
case nil, sarama.ErrNoError:
case sarama.ErrNotCoordinatorForConsumer, sarama.ErrRebalanceInProgress... | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"hbLoop",
"(",
"stopped",
"<-",
"chan",
"none",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"c",
".",
"client",
".",
"config",
".",
"Group",
".",
"Heartbeat",
".",
"Interval",
")",
"\n",
"defer",
... | // heartbeat loop, triggered by the mainLoop | [
"heartbeat",
"loop",
"triggered",
"by",
"the",
"mainLoop"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L398-L419 | test |
bsm/sarama-cluster | consumer.go | twLoop | func (c *Consumer) twLoop(stopped <-chan none) {
ticker := time.NewTicker(c.client.config.Metadata.RefreshFrequency / 2)
defer ticker.Stop()
for {
select {
case <-ticker.C:
topics, err := c.client.Topics()
if err != nil {
c.handleError(&Error{Ctx: "topics", error: err})
return
}
for _, topi... | go | func (c *Consumer) twLoop(stopped <-chan none) {
ticker := time.NewTicker(c.client.config.Metadata.RefreshFrequency / 2)
defer ticker.Stop()
for {
select {
case <-ticker.C:
topics, err := c.client.Topics()
if err != nil {
c.handleError(&Error{Ctx: "topics", error: err})
return
}
for _, topi... | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"twLoop",
"(",
"stopped",
"<-",
"chan",
"none",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"c",
".",
"client",
".",
"config",
".",
"Metadata",
".",
"RefreshFrequency",
"/",
"2",
")",
"\n",
"defer"... | // topic watcher loop, triggered by the mainLoop | [
"topic",
"watcher",
"loop",
"triggered",
"by",
"the",
"mainLoop"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L422-L448 | test |
bsm/sarama-cluster | consumer.go | cmLoop | func (c *Consumer) cmLoop(stopped <-chan none) {
ticker := time.NewTicker(c.client.config.Consumer.Offsets.CommitInterval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
if err := c.commitOffsetsWithRetry(c.client.config.Group.Offsets.Retry.Max); err != nil {
c.handleError(&Error{Ctx: "commit", erro... | go | func (c *Consumer) cmLoop(stopped <-chan none) {
ticker := time.NewTicker(c.client.config.Consumer.Offsets.CommitInterval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
if err := c.commitOffsetsWithRetry(c.client.config.Group.Offsets.Retry.Max); err != nil {
c.handleError(&Error{Ctx: "commit", erro... | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"cmLoop",
"(",
"stopped",
"<-",
"chan",
"none",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"c",
".",
"client",
".",
"config",
".",
"Consumer",
".",
"Offsets",
".",
"CommitInterval",
")",
"\n",
"de... | // commit loop, triggered by the mainLoop | [
"commit",
"loop",
"triggered",
"by",
"the",
"mainLoop"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L451-L468 | test |
bsm/sarama-cluster | consumer.go | fetchOffsets | func (c *Consumer) fetchOffsets(subs map[string][]int32) (map[string]map[int32]offsetInfo, error) {
offsets := make(map[string]map[int32]offsetInfo, len(subs))
req := &sarama.OffsetFetchRequest{
Version: 1,
ConsumerGroup: c.groupID,
}
for topic, partitions := range subs {
offsets[topic] = make(map[int3... | go | func (c *Consumer) fetchOffsets(subs map[string][]int32) (map[string]map[int32]offsetInfo, error) {
offsets := make(map[string]map[int32]offsetInfo, len(subs))
req := &sarama.OffsetFetchRequest{
Version: 1,
ConsumerGroup: c.groupID,
}
for topic, partitions := range subs {
offsets[topic] = make(map[int3... | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"fetchOffsets",
"(",
"subs",
"map",
"[",
"string",
"]",
"[",
"]",
"int32",
")",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"int32",
"]",
"offsetInfo",
",",
"error",
")",
"{",
"offsets",
":=",
"make",
"(",
... | // Fetches latest committed offsets for all subscriptions | [
"Fetches",
"latest",
"committed",
"offsets",
"for",
"all",
"subscriptions"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L748-L790 | test |
bsm/sarama-cluster | offsets.go | MarkOffset | func (s *OffsetStash) MarkOffset(msg *sarama.ConsumerMessage, metadata string) {
s.MarkPartitionOffset(msg.Topic, msg.Partition, msg.Offset, metadata)
} | go | func (s *OffsetStash) MarkOffset(msg *sarama.ConsumerMessage, metadata string) {
s.MarkPartitionOffset(msg.Topic, msg.Partition, msg.Offset, metadata)
} | [
"func",
"(",
"s",
"*",
"OffsetStash",
")",
"MarkOffset",
"(",
"msg",
"*",
"sarama",
".",
"ConsumerMessage",
",",
"metadata",
"string",
")",
"{",
"s",
".",
"MarkPartitionOffset",
"(",
"msg",
".",
"Topic",
",",
"msg",
".",
"Partition",
",",
"msg",
".",
"... | // MarkOffset stashes the provided message offset | [
"MarkOffset",
"stashes",
"the",
"provided",
"message",
"offset"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/offsets.go#L22-L24 | test |
bsm/sarama-cluster | offsets.go | ResetOffset | func (s *OffsetStash) ResetOffset(msg *sarama.ConsumerMessage, metadata string) {
s.ResetPartitionOffset(msg.Topic, msg.Partition, msg.Offset, metadata)
} | go | func (s *OffsetStash) ResetOffset(msg *sarama.ConsumerMessage, metadata string) {
s.ResetPartitionOffset(msg.Topic, msg.Partition, msg.Offset, metadata)
} | [
"func",
"(",
"s",
"*",
"OffsetStash",
")",
"ResetOffset",
"(",
"msg",
"*",
"sarama",
".",
"ConsumerMessage",
",",
"metadata",
"string",
")",
"{",
"s",
".",
"ResetPartitionOffset",
"(",
"msg",
".",
"Topic",
",",
"msg",
".",
"Partition",
",",
"msg",
".",
... | // ResetOffset stashes the provided message offset
// See ResetPartitionOffset for explanation | [
"ResetOffset",
"stashes",
"the",
"provided",
"message",
"offset",
"See",
"ResetPartitionOffset",
"for",
"explanation"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/offsets.go#L55-L57 | test |
bsm/sarama-cluster | offsets.go | Offsets | func (s *OffsetStash) Offsets() map[string]int64 {
s.mu.Lock()
defer s.mu.Unlock()
res := make(map[string]int64, len(s.offsets))
for tp, info := range s.offsets {
res[tp.String()] = info.Offset
}
return res
} | go | func (s *OffsetStash) Offsets() map[string]int64 {
s.mu.Lock()
defer s.mu.Unlock()
res := make(map[string]int64, len(s.offsets))
for tp, info := range s.offsets {
res[tp.String()] = info.Offset
}
return res
} | [
"func",
"(",
"s",
"*",
"OffsetStash",
")",
"Offsets",
"(",
")",
"map",
"[",
"string",
"]",
"int64",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"res",
":=",
"make",
"(",
"map",
"["... | // Offsets returns the latest stashed offsets by topic-partition | [
"Offsets",
"returns",
"the",
"latest",
"stashed",
"offsets",
"by",
"topic",
"-",
"partition"
] | d5779253526cc8a3129a0e5d7cc429f4b4473ab4 | https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/offsets.go#L60-L69 | test |
kubicorn/kubicorn | cloud/google/compute/resources/instancegroup.go | Actual | func (r *InstanceGroup) Actual(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("instanceGroup.Actual")
if r.CachedActual != nil {
logger.Debug("Using cached instance [actual]")
return immutable, r.CachedActual, nil
}
newResource := &InstanceGroup{
Shared: Shared{
Name: ... | go | func (r *InstanceGroup) Actual(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("instanceGroup.Actual")
if r.CachedActual != nil {
logger.Debug("Using cached instance [actual]")
return immutable, r.CachedActual, nil
}
newResource := &InstanceGroup{
Shared: Shared{
Name: ... | [
"func",
"(",
"r",
"*",
"InstanceGroup",
")",
"Actual",
"(",
"immutable",
"*",
"cluster",
".",
"Cluster",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"cloud",
".",
"Resource",
",",
"error",
")",
"{",
"logger",
".",
"Debug",
"(",
"\"instanceGroup.Actual... | // Actual is used to build a cluster based on instances on the cloud provider. | [
"Actual",
"is",
"used",
"to",
"build",
"a",
"cluster",
"based",
"on",
"instances",
"on",
"the",
"cloud",
"provider",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cloud/google/compute/resources/instancegroup.go#L57-L95 | test |
kubicorn/kubicorn | cloud/google/compute/resources/instancegroup.go | Expected | func (r *InstanceGroup) Expected(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("instanceGroup.Expected")
if r.CachedExpected != nil {
logger.Debug("Using instance subnet [expected]")
return immutable, r.CachedExpected, nil
}
expected := &InstanceGroup{
Shared: Shared{
... | go | func (r *InstanceGroup) Expected(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("instanceGroup.Expected")
if r.CachedExpected != nil {
logger.Debug("Using instance subnet [expected]")
return immutable, r.CachedExpected, nil
}
expected := &InstanceGroup{
Shared: Shared{
... | [
"func",
"(",
"r",
"*",
"InstanceGroup",
")",
"Expected",
"(",
"immutable",
"*",
"cluster",
".",
"Cluster",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"cloud",
".",
"Resource",
",",
"error",
")",
"{",
"logger",
".",
"Debug",
"(",
"\"instanceGroup.Expe... | // Expected is used to build a cluster expected to be on the cloud provider. | [
"Expected",
"is",
"used",
"to",
"build",
"a",
"cluster",
"expected",
"to",
"be",
"on",
"the",
"cloud",
"provider",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cloud/google/compute/resources/instancegroup.go#L98-L118 | test |
kubicorn/kubicorn | cloud/google/compute/resources/instancegroup.go | Delete | func (r *InstanceGroup) Delete(actual cloud.Resource, immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("instanceGroup.Delete")
deleteResource := actual.(*InstanceGroup)
if deleteResource.Name == "" {
return nil, nil, fmt.Errorf("Unable to delete instance resource without Name [%... | go | func (r *InstanceGroup) Delete(actual cloud.Resource, immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("instanceGroup.Delete")
deleteResource := actual.(*InstanceGroup)
if deleteResource.Name == "" {
return nil, nil, fmt.Errorf("Unable to delete instance resource without Name [%... | [
"func",
"(",
"r",
"*",
"InstanceGroup",
")",
"Delete",
"(",
"actual",
"cloud",
".",
"Resource",
",",
"immutable",
"*",
"cluster",
".",
"Cluster",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"cloud",
".",
"Resource",
",",
"error",
")",
"{",
"logger",... | // Delete is used to delete the instances on the cloud provider | [
"Delete",
"is",
"used",
"to",
"delete",
"the",
"instances",
"on",
"the",
"cloud",
"provider"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cloud/google/compute/resources/instancegroup.go#L338-L371 | test |
kubicorn/kubicorn | pkg/reconciler.go | GetReconciler | func GetReconciler(known *cluster.Cluster, runtimeParameters *RuntimeParameters) (reconciler cloud.Reconciler, err error) {
switch known.ProviderConfig().Cloud {
case cluster.CloudGoogle:
sdk, err := googleSDK.NewSdk()
if err != nil {
return nil, err
}
gr.Sdk = sdk
return cloud.NewAtomicReconciler(known,... | go | func GetReconciler(known *cluster.Cluster, runtimeParameters *RuntimeParameters) (reconciler cloud.Reconciler, err error) {
switch known.ProviderConfig().Cloud {
case cluster.CloudGoogle:
sdk, err := googleSDK.NewSdk()
if err != nil {
return nil, err
}
gr.Sdk = sdk
return cloud.NewAtomicReconciler(known,... | [
"func",
"GetReconciler",
"(",
"known",
"*",
"cluster",
".",
"Cluster",
",",
"runtimeParameters",
"*",
"RuntimeParameters",
")",
"(",
"reconciler",
"cloud",
".",
"Reconciler",
",",
"err",
"error",
")",
"{",
"switch",
"known",
".",
"ProviderConfig",
"(",
")",
... | // GetReconciler gets the correct Reconciler for the cloud provider currenty used. | [
"GetReconciler",
"gets",
"the",
"correct",
"Reconciler",
"for",
"the",
"cloud",
"provider",
"currenty",
"used",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/reconciler.go#L51-L109 | test |
kubicorn/kubicorn | pkg/version/version.go | GetVersion | func GetVersion() *Version {
return &Version{
Version: KubicornVersion,
GitCommit: GitSha,
BuildDate: time.Now().UTC().String(),
GoVersion: runtime.Version(),
GOOS: runtime.GOOS,
GOArch: runtime.GOARCH,
}
} | go | func GetVersion() *Version {
return &Version{
Version: KubicornVersion,
GitCommit: GitSha,
BuildDate: time.Now().UTC().String(),
GoVersion: runtime.Version(),
GOOS: runtime.GOOS,
GOArch: runtime.GOARCH,
}
} | [
"func",
"GetVersion",
"(",
")",
"*",
"Version",
"{",
"return",
"&",
"Version",
"{",
"Version",
":",
"KubicornVersion",
",",
"GitCommit",
":",
"GitSha",
",",
"BuildDate",
":",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
".",
"String",
"(",
")"... | // GetVersion returns Kubicorn version. | [
"GetVersion",
"returns",
"Kubicorn",
"version",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/version/version.go#L48-L57 | test |
kubicorn/kubicorn | pkg/version/version.go | GetVersionJSON | func GetVersionJSON() string {
verBytes, err := json.Marshal(GetVersion())
if err != nil {
logger.Critical("Unable to marshal version struct: %v", err)
}
return string(verBytes)
} | go | func GetVersionJSON() string {
verBytes, err := json.Marshal(GetVersion())
if err != nil {
logger.Critical("Unable to marshal version struct: %v", err)
}
return string(verBytes)
} | [
"func",
"GetVersionJSON",
"(",
")",
"string",
"{",
"verBytes",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"GetVersion",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Critical",
"(",
"\"Unable to marshal version struct: %v\"",
",",
... | // GetVersionJSON returns Kubicorn version in JSON format. | [
"GetVersionJSON",
"returns",
"Kubicorn",
"version",
"in",
"JSON",
"format",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/version/version.go#L60-L66 | test |
kubicorn/kubicorn | cloud/azure/public/resources/resourcegroup.go | Actual | func (r *ResourceGroup) Actual(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("resourcegroup.Actual")
newResource := &ResourceGroup{
Shared: Shared{
Name: r.Name,
Tags: r.Tags,
Identifier: immutable.ProviderConfig().GroupIdentifier,
},
Location: r.Locat... | go | func (r *ResourceGroup) Actual(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("resourcegroup.Actual")
newResource := &ResourceGroup{
Shared: Shared{
Name: r.Name,
Tags: r.Tags,
Identifier: immutable.ProviderConfig().GroupIdentifier,
},
Location: r.Locat... | [
"func",
"(",
"r",
"*",
"ResourceGroup",
")",
"Actual",
"(",
"immutable",
"*",
"cluster",
".",
"Cluster",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"cloud",
".",
"Resource",
",",
"error",
")",
"{",
"logger",
".",
"Debug",
"(",
"\"resourcegroup.Actual... | // Actual returns the actual resource group in Azure if it exists. | [
"Actual",
"returns",
"the",
"actual",
"resource",
"group",
"in",
"Azure",
"if",
"it",
"exists",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cloud/azure/public/resources/resourcegroup.go#L35-L58 | test |
kubicorn/kubicorn | cloud/azure/public/resources/resourcegroup.go | Expected | func (r *ResourceGroup) Expected(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("resourcegroup.Expected")
newResource := &ResourceGroup{
Shared: Shared{
Name: immutable.Name,
Tags: r.Tags,
Identifier: immutable.ProviderConfig().GroupIdentifier,
},
Locat... | go | func (r *ResourceGroup) Expected(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("resourcegroup.Expected")
newResource := &ResourceGroup{
Shared: Shared{
Name: immutable.Name,
Tags: r.Tags,
Identifier: immutable.ProviderConfig().GroupIdentifier,
},
Locat... | [
"func",
"(",
"r",
"*",
"ResourceGroup",
")",
"Expected",
"(",
"immutable",
"*",
"cluster",
".",
"Cluster",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"cloud",
".",
"Resource",
",",
"error",
")",
"{",
"logger",
".",
"Debug",
"(",
"\"resourcegroup.Expe... | // Expected will return the expected resource group as it would be defined in Azure | [
"Expected",
"will",
"return",
"the",
"expected",
"resource",
"group",
"as",
"it",
"would",
"be",
"defined",
"in",
"Azure"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cloud/azure/public/resources/resourcegroup.go#L61-L73 | test |
kubicorn/kubicorn | cmd/create.go | CreateCmd | func CreateCmd() *cobra.Command {
var co = &cli.CreateOptions{}
var createCmd = &cobra.Command{
Use: "create [NAME] [-p|--profile PROFILENAME] [-c|--cloudid CLOUDID]",
Short: "Create a Kubicorn API model from a profile",
Long: `Use this command to create a Kubicorn API model in a defined state store.
This c... | go | func CreateCmd() *cobra.Command {
var co = &cli.CreateOptions{}
var createCmd = &cobra.Command{
Use: "create [NAME] [-p|--profile PROFILENAME] [-c|--cloudid CLOUDID]",
Short: "Create a Kubicorn API model from a profile",
Long: `Use this command to create a Kubicorn API model in a defined state store.
This c... | [
"func",
"CreateCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"co",
"=",
"&",
"cli",
".",
"CreateOptions",
"{",
"}",
"\n",
"var",
"createCmd",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"create [NAME] [-p|--profile PROFILENAME] [-c|--cl... | // CreateCmd represents create command | [
"CreateCmd",
"represents",
"create",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/create.go#L35-L87 | test |
kubicorn/kubicorn | profiles/azure/ubuntu.go | NewUbuntuCluster | func NewUbuntuCluster(name string) *cluster.Cluster {
controlPlaneProviderConfig := &cluster.ControlPlaneProviderConfig{
Cloud: cluster.CloudAzure,
Location: "eastus",
SSH: &cluster.SSH{
PublicKeyPath: "~/.ssh/id_rsa.pub",
User: "root",
},
KubernetesAPI: &cluster.KubernetesAPI{
Port: "4... | go | func NewUbuntuCluster(name string) *cluster.Cluster {
controlPlaneProviderConfig := &cluster.ControlPlaneProviderConfig{
Cloud: cluster.CloudAzure,
Location: "eastus",
SSH: &cluster.SSH{
PublicKeyPath: "~/.ssh/id_rsa.pub",
User: "root",
},
KubernetesAPI: &cluster.KubernetesAPI{
Port: "4... | [
"func",
"NewUbuntuCluster",
"(",
"name",
"string",
")",
"*",
"cluster",
".",
"Cluster",
"{",
"controlPlaneProviderConfig",
":=",
"&",
"cluster",
".",
"ControlPlaneProviderConfig",
"{",
"Cloud",
":",
"cluster",
".",
"CloudAzure",
",",
"Location",
":",
"\"eastus\"",... | // NewUbuntuCluster creates a basic Azure cluster profile, to bootstrap Kubernetes. | [
"NewUbuntuCluster",
"creates",
"a",
"basic",
"Azure",
"cluster",
"profile",
"to",
"bootstrap",
"Kubernetes",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/profiles/azure/ubuntu.go#L25-L132 | test |
kubicorn/kubicorn | apis/cluster/cluster.go | ProviderConfig | func (c *Cluster) ProviderConfig() *ControlPlaneProviderConfig {
//providerConfig providerConfig
raw := c.ClusterAPI.Spec.ProviderConfig
providerConfig := &ControlPlaneProviderConfig{}
err := json.Unmarshal([]byte(raw), providerConfig)
if err != nil {
logger.Critical("Unable to unmarshal provider config: %v", er... | go | func (c *Cluster) ProviderConfig() *ControlPlaneProviderConfig {
//providerConfig providerConfig
raw := c.ClusterAPI.Spec.ProviderConfig
providerConfig := &ControlPlaneProviderConfig{}
err := json.Unmarshal([]byte(raw), providerConfig)
if err != nil {
logger.Critical("Unable to unmarshal provider config: %v", er... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ProviderConfig",
"(",
")",
"*",
"ControlPlaneProviderConfig",
"{",
"raw",
":=",
"c",
".",
"ClusterAPI",
".",
"Spec",
".",
"ProviderConfig",
"\n",
"providerConfig",
":=",
"&",
"ControlPlaneProviderConfig",
"{",
"}",
"\n",... | // ProviderConfig is a convenience method that will attempt
// to return a ControlPlaneProviderConfig for a cluster.
// This is useful for managing the legacy API in a clean way.
// This will ignore errors from json.Unmarshal and will simply
// return an empty config. | [
"ProviderConfig",
"is",
"a",
"convenience",
"method",
"that",
"will",
"attempt",
"to",
"return",
"a",
"ControlPlaneProviderConfig",
"for",
"a",
"cluster",
".",
"This",
"is",
"useful",
"for",
"managing",
"the",
"legacy",
"API",
"in",
"a",
"clean",
"way",
".",
... | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/apis/cluster/cluster.go#L76-L85 | test |
kubicorn/kubicorn | apis/cluster/cluster.go | SetProviderConfig | func (c *Cluster) SetProviderConfig(config *ControlPlaneProviderConfig) error {
bytes, err := json.Marshal(config)
if err != nil {
logger.Critical("Unable to marshal provider config: %v", err)
return err
}
str := string(bytes)
c.ClusterAPI.Spec.ProviderConfig = str
return nil
} | go | func (c *Cluster) SetProviderConfig(config *ControlPlaneProviderConfig) error {
bytes, err := json.Marshal(config)
if err != nil {
logger.Critical("Unable to marshal provider config: %v", err)
return err
}
str := string(bytes)
c.ClusterAPI.Spec.ProviderConfig = str
return nil
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"SetProviderConfig",
"(",
"config",
"*",
"ControlPlaneProviderConfig",
")",
"error",
"{",
"bytes",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
... | // SetProviderConfig is a convenience method that will attempt
// to set a provider config on a particular cluster. Just like
// it's counterpart ProviderConfig this makes working with the legacy API much easier. | [
"SetProviderConfig",
"is",
"a",
"convenience",
"method",
"that",
"will",
"attempt",
"to",
"set",
"a",
"provider",
"config",
"on",
"a",
"particular",
"cluster",
".",
"Just",
"like",
"it",
"s",
"counterpart",
"ProviderConfig",
"this",
"makes",
"working",
"with",
... | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/apis/cluster/cluster.go#L90-L99 | test |
kubicorn/kubicorn | apis/cluster/cluster.go | MachineProviderConfigs | func (c *Cluster) MachineProviderConfigs() []*MachineProviderConfig {
var providerConfigs []*MachineProviderConfig
for _, machineSet := range c.MachineSets {
raw := machineSet.Spec.Template.Spec.ProviderConfig
providerConfig := &MachineProviderConfig{}
err := json.Unmarshal([]byte(raw), providerConfig)
if err... | go | func (c *Cluster) MachineProviderConfigs() []*MachineProviderConfig {
var providerConfigs []*MachineProviderConfig
for _, machineSet := range c.MachineSets {
raw := machineSet.Spec.Template.Spec.ProviderConfig
providerConfig := &MachineProviderConfig{}
err := json.Unmarshal([]byte(raw), providerConfig)
if err... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"MachineProviderConfigs",
"(",
")",
"[",
"]",
"*",
"MachineProviderConfig",
"{",
"var",
"providerConfigs",
"[",
"]",
"*",
"MachineProviderConfig",
"\n",
"for",
"_",
",",
"machineSet",
":=",
"range",
"c",
".",
"MachineSe... | // MachineProviderConfigs will return all MachineProviderConfigs for a cluster | [
"MachineProviderConfigs",
"will",
"return",
"all",
"MachineProviderConfigs",
"for",
"a",
"cluster"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/apis/cluster/cluster.go#L102-L114 | test |
kubicorn/kubicorn | apis/cluster/cluster.go | SetMachineProviderConfigs | func (c *Cluster) SetMachineProviderConfigs(providerConfigs []*MachineProviderConfig) {
for _, providerConfig := range providerConfigs {
name := providerConfig.ServerPool.Name
found := false
for _, machineSet := range c.MachineSets {
if machineSet.Name == name {
//logger.Debug("Matched machine set to prov... | go | func (c *Cluster) SetMachineProviderConfigs(providerConfigs []*MachineProviderConfig) {
for _, providerConfig := range providerConfigs {
name := providerConfig.ServerPool.Name
found := false
for _, machineSet := range c.MachineSets {
if machineSet.Name == name {
//logger.Debug("Matched machine set to prov... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"SetMachineProviderConfigs",
"(",
"providerConfigs",
"[",
"]",
"*",
"MachineProviderConfig",
")",
"{",
"for",
"_",
",",
"providerConfig",
":=",
"range",
"providerConfigs",
"{",
"name",
":=",
"providerConfig",
".",
"ServerPo... | // SetMachineProviderConfig will attempt to match a provider config to a machine set
// on the "Name" field. If a match cannot be made we warn and move on. | [
"SetMachineProviderConfig",
"will",
"attempt",
"to",
"match",
"a",
"provider",
"config",
"to",
"a",
"machine",
"set",
"on",
"the",
"Name",
"field",
".",
"If",
"a",
"match",
"cannot",
"be",
"made",
"we",
"warn",
"and",
"move",
"on",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/apis/cluster/cluster.go#L118-L147 | test |
kubicorn/kubicorn | apis/cluster/cluster.go | NewCluster | func NewCluster(name string) *Cluster {
return &Cluster{
Name: name,
ClusterAPI: &clusterv1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: clusterv1.ClusterSpec{},
},
ControlPlane: &clusterv1.MachineSet{},
}
} | go | func NewCluster(name string) *Cluster {
return &Cluster{
Name: name,
ClusterAPI: &clusterv1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: clusterv1.ClusterSpec{},
},
ControlPlane: &clusterv1.MachineSet{},
}
} | [
"func",
"NewCluster",
"(",
"name",
"string",
")",
"*",
"Cluster",
"{",
"return",
"&",
"Cluster",
"{",
"Name",
":",
"name",
",",
"ClusterAPI",
":",
"&",
"clusterv1",
".",
"Cluster",
"{",
"ObjectMeta",
":",
"metav1",
".",
"ObjectMeta",
"{",
"Name",
":",
... | // NewCluster will initialize a new Cluster | [
"NewCluster",
"will",
"initialize",
"a",
"new",
"Cluster"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/apis/cluster/cluster.go#L254-L265 | test |
kubicorn/kubicorn | cmd/deploycontroller.go | DeployControllerCmd | func DeployControllerCmd() *cobra.Command {
var dco = &cli.DeployControllerOptions{}
var deployControllerCmd = &cobra.Command{
Use: "deploycontroller <NAME>",
Short: "Deploy a controller for a given cluster",
Long: `Use this command to deploy a controller for a given cluster.
As long as a controller is defin... | go | func DeployControllerCmd() *cobra.Command {
var dco = &cli.DeployControllerOptions{}
var deployControllerCmd = &cobra.Command{
Use: "deploycontroller <NAME>",
Short: "Deploy a controller for a given cluster",
Long: `Use this command to deploy a controller for a given cluster.
As long as a controller is defin... | [
"func",
"DeployControllerCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"dco",
"=",
"&",
"cli",
".",
"DeployControllerOptions",
"{",
"}",
"\n",
"var",
"deployControllerCmd",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"deploycontroller <... | // DeployControllerCmd represents the apply command | [
"DeployControllerCmd",
"represents",
"the",
"apply",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/deploycontroller.go#L31-L66 | test |
kubicorn/kubicorn | pkg/retry/retry.go | NewRetrier | func NewRetrier(retries, sleepSeconds int, retryable Retryable) *Retrier {
return &Retrier{
retries: retries,
sleepSeconds: sleepSeconds,
retryable: retryable,
}
} | go | func NewRetrier(retries, sleepSeconds int, retryable Retryable) *Retrier {
return &Retrier{
retries: retries,
sleepSeconds: sleepSeconds,
retryable: retryable,
}
} | [
"func",
"NewRetrier",
"(",
"retries",
",",
"sleepSeconds",
"int",
",",
"retryable",
"Retryable",
")",
"*",
"Retrier",
"{",
"return",
"&",
"Retrier",
"{",
"retries",
":",
"retries",
",",
"sleepSeconds",
":",
"sleepSeconds",
",",
"retryable",
":",
"retryable",
... | // NewRetrier creates a new Retrier using given properties. | [
"NewRetrier",
"creates",
"a",
"new",
"Retrier",
"using",
"given",
"properties",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/retry/retry.go#L40-L46 | test |
kubicorn/kubicorn | pkg/retry/retry.go | RunRetry | func (r *Retrier) RunRetry() error {
// Start signal handler.
sigHandler := signals.NewSignalHandler(10)
go sigHandler.Register()
finish := make(chan bool, 1)
go func() {
select {
case <-finish:
return
case <-time.After(10 * time.Second):
return
default:
for {
if sigHandler.GetState() != 0 {
... | go | func (r *Retrier) RunRetry() error {
// Start signal handler.
sigHandler := signals.NewSignalHandler(10)
go sigHandler.Register()
finish := make(chan bool, 1)
go func() {
select {
case <-finish:
return
case <-time.After(10 * time.Second):
return
default:
for {
if sigHandler.GetState() != 0 {
... | [
"func",
"(",
"r",
"*",
"Retrier",
")",
"RunRetry",
"(",
")",
"error",
"{",
"sigHandler",
":=",
"signals",
".",
"NewSignalHandler",
"(",
"10",
")",
"\n",
"go",
"sigHandler",
".",
"Register",
"(",
")",
"\n",
"finish",
":=",
"make",
"(",
"chan",
"bool",
... | // RunRetry runs a retryable function. | [
"RunRetry",
"runs",
"a",
"retryable",
"function",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/retry/retry.go#L49-L84 | test |
kubicorn/kubicorn | pkg/rand/cryptorand.go | MustGenerateRandomBytes | func MustGenerateRandomBytes(length int) []byte {
res, err := GenerateRandomBytes(length)
if err != nil {
panic("Could not generate random bytes")
}
return res
} | go | func MustGenerateRandomBytes(length int) []byte {
res, err := GenerateRandomBytes(length)
if err != nil {
panic("Could not generate random bytes")
}
return res
} | [
"func",
"MustGenerateRandomBytes",
"(",
"length",
"int",
")",
"[",
"]",
"byte",
"{",
"res",
",",
"err",
":=",
"GenerateRandomBytes",
"(",
"length",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"Could not generate random bytes\"",
")",
"\n",
"}",... | // MustGenerateRandomBytes generates random bytes or panics if it can't | [
"MustGenerateRandomBytes",
"generates",
"random",
"bytes",
"or",
"panics",
"if",
"it",
"can",
"t"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/rand/cryptorand.go#L23-L31 | test |
kubicorn/kubicorn | cmd/explain.go | ExplainCmd | func ExplainCmd() *cobra.Command {
var exo = &cli.ExplainOptions{}
var cmd = &cobra.Command{
Use: "explain",
Short: "Explain cluster",
Long: `Output expected and actual state of the given cluster`,
Run: func(cmd *cobra.Command, args []string) {
switch len(args) {
case 0:
exo.Name = viper.GetStri... | go | func ExplainCmd() *cobra.Command {
var exo = &cli.ExplainOptions{}
var cmd = &cobra.Command{
Use: "explain",
Short: "Explain cluster",
Long: `Output expected and actual state of the given cluster`,
Run: func(cmd *cobra.Command, args []string) {
switch len(args) {
case 0:
exo.Name = viper.GetStri... | [
"func",
"ExplainCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"exo",
"=",
"&",
"cli",
".",
"ExplainOptions",
"{",
"}",
"\n",
"var",
"cmd",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"explain\"",
",",
"Short",
":",
"\"Explain cl... | // ExplainCmd represents the explain command | [
"ExplainCmd",
"represents",
"the",
"explain",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/explain.go#L39-L73 | test |
kubicorn/kubicorn | pkg/uuid/uuid.go | TimeOrderedUUID | func TimeOrderedUUID() string {
unixTime := uint32(time.Now().UTC().Unix())
return fmt.Sprintf("%08x-%04x-%04x-%04x-%04x%08x",
unixTime,
rand.MustGenerateRandomBytes(2),
rand.MustGenerateRandomBytes(2),
rand.MustGenerateRandomBytes(2),
rand.MustGenerateRandomBytes(2),
rand.MustGenerateRandomBytes(4))
} | go | func TimeOrderedUUID() string {
unixTime := uint32(time.Now().UTC().Unix())
return fmt.Sprintf("%08x-%04x-%04x-%04x-%04x%08x",
unixTime,
rand.MustGenerateRandomBytes(2),
rand.MustGenerateRandomBytes(2),
rand.MustGenerateRandomBytes(2),
rand.MustGenerateRandomBytes(2),
rand.MustGenerateRandomBytes(4))
} | [
"func",
"TimeOrderedUUID",
"(",
")",
"string",
"{",
"unixTime",
":=",
"uint32",
"(",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
".",
"Unix",
"(",
")",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%08x-%04x-%04x-%04x-%04x%08x\"",
",",
"u... | // TimeOrderedUUID generates a time ordered UUID. Top 32b are timestamp bottom 96b are random. | [
"TimeOrderedUUID",
"generates",
"a",
"time",
"ordered",
"UUID",
".",
"Top",
"32b",
"are",
"timestamp",
"bottom",
"96b",
"are",
"random",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/uuid/uuid.go#L25-L34 | test |
kubicorn/kubicorn | cmd/getconfig.go | GetConfigCmd | func GetConfigCmd() *cobra.Command {
var cro = &cli.GetConfigOptions{}
var getConfigCmd = &cobra.Command{
Use: "getconfig <NAME>",
Short: "Manage Kubernetes configuration",
Long: `Use this command to pull a kubeconfig file from a cluster so you can use kubectl.
This command will attempt to find a cluster, ... | go | func GetConfigCmd() *cobra.Command {
var cro = &cli.GetConfigOptions{}
var getConfigCmd = &cobra.Command{
Use: "getconfig <NAME>",
Short: "Manage Kubernetes configuration",
Long: `Use this command to pull a kubeconfig file from a cluster so you can use kubectl.
This command will attempt to find a cluster, ... | [
"func",
"GetConfigCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"cro",
"=",
"&",
"cli",
".",
"GetConfigOptions",
"{",
"}",
"\n",
"var",
"getConfigCmd",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"getconfig <NAME>\"",
",",
"Short",
... | // GetConfigCmd represents the apply command | [
"GetConfigCmd",
"represents",
"the",
"apply",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/getconfig.go#L31-L66 | test |
kubicorn/kubicorn | pkg/task/task.go | RunAnnotated | func RunAnnotated(task Task, description string, symbol string, options ...interface{}) error {
doneCh := make(chan bool)
errCh := make(chan error)
l := logger.Log
t := DefaultTicker
for _, o := range options {
if value, ok := o.(logger.Logger); ok {
l = value
} else if value, ok := o.(*time.Ticker); ok {... | go | func RunAnnotated(task Task, description string, symbol string, options ...interface{}) error {
doneCh := make(chan bool)
errCh := make(chan error)
l := logger.Log
t := DefaultTicker
for _, o := range options {
if value, ok := o.(logger.Logger); ok {
l = value
} else if value, ok := o.(*time.Ticker); ok {... | [
"func",
"RunAnnotated",
"(",
"task",
"Task",
",",
"description",
"string",
",",
"symbol",
"string",
",",
"options",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"doneCh",
":=",
"make",
"(",
"chan",
"bool",
")",
"\n",
"errCh",
":=",
"make",
"(",
"ch... | // RunAnnotated annotates a task with a description and a sequence of symbols indicating task activity until it terminates | [
"RunAnnotated",
"annotates",
"a",
"task",
"with",
"a",
"description",
"and",
"a",
"sequence",
"of",
"symbols",
"indicating",
"task",
"activity",
"until",
"it",
"terminates"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/task/task.go#L30-L56 | test |
kubicorn/kubicorn | cmd/list.go | ListCmd | func ListCmd() *cobra.Command {
var lo = &cli.ListOptions{}
var cmd = &cobra.Command{
Use: "list",
Short: "List available states",
Long: `List the states available in the _state directory`,
Run: func(cmd *cobra.Command, args []string) {
if err := runList(lo); err != nil {
logger.Critical(err.Error()... | go | func ListCmd() *cobra.Command {
var lo = &cli.ListOptions{}
var cmd = &cobra.Command{
Use: "list",
Short: "List available states",
Long: `List the states available in the _state directory`,
Run: func(cmd *cobra.Command, args []string) {
if err := runList(lo); err != nil {
logger.Critical(err.Error()... | [
"func",
"ListCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"lo",
"=",
"&",
"cli",
".",
"ListOptions",
"{",
"}",
"\n",
"var",
"cmd",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"list\"",
",",
"Short",
":",
"\"List available state... | // ListCmd represents the list command | [
"ListCmd",
"represents",
"the",
"list",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/list.go#L36-L58 | test |
kubicorn/kubicorn | profiles/packet/ubuntu_16_04.go | NewUbuntuCluster | func NewUbuntuCluster(name string) *cluster.Cluster {
controlPlaneProviderConfig := &cluster.ControlPlaneProviderConfig{
Cloud: cluster.CloudPacket,
Project: &cluster.Project{
Name: fmt.Sprintf("kubicorn-%s", name),
},
Location: "ewr1",
SSH: &cluster.SSH{
PublicKeyPath: "~/.ssh/id_rsa.pub",
User: ... | go | func NewUbuntuCluster(name string) *cluster.Cluster {
controlPlaneProviderConfig := &cluster.ControlPlaneProviderConfig{
Cloud: cluster.CloudPacket,
Project: &cluster.Project{
Name: fmt.Sprintf("kubicorn-%s", name),
},
Location: "ewr1",
SSH: &cluster.SSH{
PublicKeyPath: "~/.ssh/id_rsa.pub",
User: ... | [
"func",
"NewUbuntuCluster",
"(",
"name",
"string",
")",
"*",
"cluster",
".",
"Cluster",
"{",
"controlPlaneProviderConfig",
":=",
"&",
"cluster",
".",
"ControlPlaneProviderConfig",
"{",
"Cloud",
":",
"cluster",
".",
"CloudPacket",
",",
"Project",
":",
"&",
"clust... | // NewUbuntuCluster creates a simple Ubuntu Amazon cluster | [
"NewUbuntuCluster",
"creates",
"a",
"simple",
"Ubuntu",
"Amazon",
"cluster"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/profiles/packet/ubuntu_16_04.go#L25-L78 | test |
kubicorn/kubicorn | cmd/edit.go | EditCmd | func EditCmd() *cobra.Command {
var eo = &cli.EditOptions{}
var editCmd = &cobra.Command{
Use: "edit <NAME>",
Short: "Edit a cluster state",
Long: `Use this command to edit a state.`,
Run: func(cmd *cobra.Command, args []string) {
switch len(args) {
case 0:
eo.Name = viper.GetString(keyKubicornNa... | go | func EditCmd() *cobra.Command {
var eo = &cli.EditOptions{}
var editCmd = &cobra.Command{
Use: "edit <NAME>",
Short: "Edit a cluster state",
Long: `Use this command to edit a state.`,
Run: func(cmd *cobra.Command, args []string) {
switch len(args) {
case 0:
eo.Name = viper.GetString(keyKubicornNa... | [
"func",
"EditCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"eo",
"=",
"&",
"cli",
".",
"EditOptions",
"{",
"}",
"\n",
"var",
"editCmd",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"edit <NAME>\"",
",",
"Short",
":",
"\"Edit a cl... | // EditCmd represents edit command | [
"EditCmd",
"represents",
"edit",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/edit.go#L31-L65 | test |
kubicorn/kubicorn | pkg/agent/agent.go | RemoveKey | func (k *Keyring) RemoveKey(key ssh.PublicKey) error {
return k.Agent.Remove(key)
} | go | func (k *Keyring) RemoveKey(key ssh.PublicKey) error {
return k.Agent.Remove(key)
} | [
"func",
"(",
"k",
"*",
"Keyring",
")",
"RemoveKey",
"(",
"key",
"ssh",
".",
"PublicKey",
")",
"error",
"{",
"return",
"k",
".",
"Agent",
".",
"Remove",
"(",
"key",
")",
"\n",
"}"
] | // RemoveKey removes an existing key from keyring | [
"RemoveKey",
"removes",
"an",
"existing",
"key",
"from",
"keyring"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/agent/agent.go#L117-L119 | test |
kubicorn/kubicorn | pkg/agent/agent.go | RemoveKeyUsingFile | func (k *Keyring) RemoveKeyUsingFile(pubkey string) error {
p, err := ioutil.ReadFile(pubkey)
if err != nil {
return err
}
key, _, _, _, _ := ssh.ParseAuthorizedKey(p)
if err != nil {
return err
}
return k.RemoveKey(key)
} | go | func (k *Keyring) RemoveKeyUsingFile(pubkey string) error {
p, err := ioutil.ReadFile(pubkey)
if err != nil {
return err
}
key, _, _, _, _ := ssh.ParseAuthorizedKey(p)
if err != nil {
return err
}
return k.RemoveKey(key)
} | [
"func",
"(",
"k",
"*",
"Keyring",
")",
"RemoveKeyUsingFile",
"(",
"pubkey",
"string",
")",
"error",
"{",
"p",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"pubkey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"k... | // RemoveKeyUsingFile removes an existing key from keyring given a file | [
"RemoveKeyUsingFile",
"removes",
"an",
"existing",
"key",
"from",
"keyring",
"given",
"a",
"file"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/agent/agent.go#L122-L134 | test |
kubicorn/kubicorn | cloud/digitalocean/droplet/resources/firewall.go | Actual | func (r *Firewall) Actual(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("firewall.Actual")
newResource := defaultFirewallStruct()
// Digital Firewalls.Get requires firewall ID, which we will not always have.thats why using List.
firewalls, _, err := Sdk.Client.Firewalls.List(... | go | func (r *Firewall) Actual(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("firewall.Actual")
newResource := defaultFirewallStruct()
// Digital Firewalls.Get requires firewall ID, which we will not always have.thats why using List.
firewalls, _, err := Sdk.Client.Firewalls.List(... | [
"func",
"(",
"r",
"*",
"Firewall",
")",
"Actual",
"(",
"immutable",
"*",
"cluster",
".",
"Cluster",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"cloud",
".",
"Resource",
",",
"error",
")",
"{",
"logger",
".",
"Debug",
"(",
"\"firewall.Actual\"",
")"... | // Actual calls DO firewall Api and returns the actual state of firewall in the cloud. | [
"Actual",
"calls",
"DO",
"firewall",
"Api",
"and",
"returns",
"the",
"actual",
"state",
"of",
"firewall",
"in",
"the",
"cloud",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cloud/digitalocean/droplet/resources/firewall.go#L82-L117 | test |
kubicorn/kubicorn | cloud/digitalocean/droplet/resources/firewall.go | Expected | func (r *Firewall) Expected(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("firewall.Expected")
newResource := &Firewall{
Shared: Shared{
Name: r.Name,
CloudID: r.ServerPool.Identifier,
},
InboundRules: r.InboundRules,
OutboundRules: r.OutboundRules,
DropletID... | go | func (r *Firewall) Expected(immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("firewall.Expected")
newResource := &Firewall{
Shared: Shared{
Name: r.Name,
CloudID: r.ServerPool.Identifier,
},
InboundRules: r.InboundRules,
OutboundRules: r.OutboundRules,
DropletID... | [
"func",
"(",
"r",
"*",
"Firewall",
")",
"Expected",
"(",
"immutable",
"*",
"cluster",
".",
"Cluster",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"cloud",
".",
"Resource",
",",
"error",
")",
"{",
"logger",
".",
"Debug",
"(",
"\"firewall.Expected\"",
... | // Expected returns the Firewall structure of what is Expected. | [
"Expected",
"returns",
"the",
"Firewall",
"structure",
"of",
"what",
"is",
"Expected",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cloud/digitalocean/droplet/resources/firewall.go#L120-L140 | test |
kubicorn/kubicorn | cloud/digitalocean/droplet/resources/firewall.go | Apply | func (r *Firewall) Apply(actual, expected cloud.Resource, immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("firewall.Apply")
expectedResource := expected.(*Firewall)
actualResource := actual.(*Firewall)
isEqual, err := compare.IsEqual(actualResource, expectedResource)
if err !=... | go | func (r *Firewall) Apply(actual, expected cloud.Resource, immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("firewall.Apply")
expectedResource := expected.(*Firewall)
actualResource := actual.(*Firewall)
isEqual, err := compare.IsEqual(actualResource, expectedResource)
if err !=... | [
"func",
"(",
"r",
"*",
"Firewall",
")",
"Apply",
"(",
"actual",
",",
"expected",
"cloud",
".",
"Resource",
",",
"immutable",
"*",
"cluster",
".",
"Cluster",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"cloud",
".",
"Resource",
",",
"error",
")",
"... | // Apply will compare the actual and expected firewall config, if needed it will create the firewall. | [
"Apply",
"will",
"compare",
"the",
"actual",
"and",
"expected",
"firewall",
"config",
"if",
"needed",
"it",
"will",
"create",
"the",
"firewall",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cloud/digitalocean/droplet/resources/firewall.go#L143-L213 | test |
kubicorn/kubicorn | cloud/digitalocean/droplet/resources/firewall.go | Delete | func (r *Firewall) Delete(actual cloud.Resource, immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("firewall.Delete")
deleteResource, ok := actual.(*Firewall)
if !ok {
return nil, nil, fmt.Errorf("failed to type convert actual Firewall type ")
}
if deleteResource.Name == "" {
... | go | func (r *Firewall) Delete(actual cloud.Resource, immutable *cluster.Cluster) (*cluster.Cluster, cloud.Resource, error) {
logger.Debug("firewall.Delete")
deleteResource, ok := actual.(*Firewall)
if !ok {
return nil, nil, fmt.Errorf("failed to type convert actual Firewall type ")
}
if deleteResource.Name == "" {
... | [
"func",
"(",
"r",
"*",
"Firewall",
")",
"Delete",
"(",
"actual",
"cloud",
".",
"Resource",
",",
"immutable",
"*",
"cluster",
".",
"Cluster",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"cloud",
".",
"Resource",
",",
"error",
")",
"{",
"logger",
".... | // Delete removes the firewall | [
"Delete",
"removes",
"the",
"firewall"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cloud/digitalocean/droplet/resources/firewall.go#L304-L331 | test |
kubicorn/kubicorn | cmd/delete.go | DeleteCmd | func DeleteCmd() *cobra.Command {
var do = &cli.DeleteOptions{}
var deleteCmd = &cobra.Command{
Use: "delete <NAME>",
Short: "Delete a Kubernetes cluster",
Long: `Use this command to delete cloud resources.
This command will attempt to build the resource graph based on an API model.
Once the graph is buil... | go | func DeleteCmd() *cobra.Command {
var do = &cli.DeleteOptions{}
var deleteCmd = &cobra.Command{
Use: "delete <NAME>",
Short: "Delete a Kubernetes cluster",
Long: `Use this command to delete cloud resources.
This command will attempt to build the resource graph based on an API model.
Once the graph is buil... | [
"func",
"DeleteCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"do",
"=",
"&",
"cli",
".",
"DeleteOptions",
"{",
"}",
"\n",
"var",
"deleteCmd",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"delete <NAME>\"",
",",
"Short",
":",
"\"D... | // DeleteCmd represents the delete command | [
"DeleteCmd",
"represents",
"the",
"delete",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/delete.go#L32-L73 | test |
kubicorn/kubicorn | pkg/cli/state_store.go | NewStateStore | func (options Options) NewStateStore() (state.ClusterStorer, error) {
var stateStore state.ClusterStorer
switch options.StateStore {
case "fs":
logger.Info("Selected [fs] state store")
stateStore = fs.NewFileSystemStore(&fs.FileSystemStoreOptions{
BasePath: options.StateStorePath,
ClusterName: options.... | go | func (options Options) NewStateStore() (state.ClusterStorer, error) {
var stateStore state.ClusterStorer
switch options.StateStore {
case "fs":
logger.Info("Selected [fs] state store")
stateStore = fs.NewFileSystemStore(&fs.FileSystemStoreOptions{
BasePath: options.StateStorePath,
ClusterName: options.... | [
"func",
"(",
"options",
"Options",
")",
"NewStateStore",
"(",
")",
"(",
"state",
".",
"ClusterStorer",
",",
"error",
")",
"{",
"var",
"stateStore",
"state",
".",
"ClusterStorer",
"\n",
"switch",
"options",
".",
"StateStore",
"{",
"case",
"\"fs\"",
":",
"lo... | // NewStateStore returns clusterStorer object based on type. | [
"NewStateStore",
"returns",
"clusterStorer",
"object",
"based",
"on",
"type",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/cli/state_store.go#L33-L92 | test |
kubicorn/kubicorn | pkg/state/git/impl.go | Commit | func (git *JSONGitStore) Commit(c *cluster.Cluster) error {
if c == nil {
return fmt.Errorf("Nil cluster spec")
}
bytes, err := json.Marshal(c)
if err != nil {
return err
}
//writes latest changes to git repo.
git.Write(state.ClusterJSONFile, bytes)
//commits the changes
r, err := g.NewFilesystemReposito... | go | func (git *JSONGitStore) Commit(c *cluster.Cluster) error {
if c == nil {
return fmt.Errorf("Nil cluster spec")
}
bytes, err := json.Marshal(c)
if err != nil {
return err
}
//writes latest changes to git repo.
git.Write(state.ClusterJSONFile, bytes)
//commits the changes
r, err := g.NewFilesystemReposito... | [
"func",
"(",
"git",
"*",
"JSONGitStore",
")",
"Commit",
"(",
"c",
"*",
"cluster",
".",
"Cluster",
")",
"error",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"Nil cluster spec\"",
")",
"\n",
"}",
"\n",
"bytes",
",",
"err",
... | //Performs a git 'commit' and 'push' of the current cluster changes. | [
"Performs",
"a",
"git",
"commit",
"and",
"push",
"of",
"the",
"current",
"cluster",
"changes",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/state/git/impl.go#L122-L150 | test |
kubicorn/kubicorn | cmd/apply.go | ApplyCmd | func ApplyCmd() *cobra.Command {
var ao = &cli.ApplyOptions{}
var applyCmd = &cobra.Command{
Use: "apply <NAME>",
Short: "Apply a cluster resource to a cloud",
Long: `Use this command to apply an API model in a cloud.
This command will attempt to find an API model in a defined state store, and then apply an... | go | func ApplyCmd() *cobra.Command {
var ao = &cli.ApplyOptions{}
var applyCmd = &cobra.Command{
Use: "apply <NAME>",
Short: "Apply a cluster resource to a cloud",
Long: `Use this command to apply an API model in a cloud.
This command will attempt to find an API model in a defined state store, and then apply an... | [
"func",
"ApplyCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"ao",
"=",
"&",
"cli",
".",
"ApplyOptions",
"{",
"}",
"\n",
"var",
"applyCmd",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"apply <NAME>\"",
",",
"Short",
":",
"\"Apply... | // ApplyCmd represents the apply command | [
"ApplyCmd",
"represents",
"the",
"apply",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/apply.go#L39-L76 | test |
kubicorn/kubicorn | pkg/cli/utils.go | ExpandPath | func ExpandPath(path string) string {
switch path {
case ".":
wd, err := os.Getwd()
if err != nil {
logger.Critical("Unable to get current working directory: %v", err)
return ""
}
path = wd
case "~":
homeVar := os.Getenv("HOME")
if homeVar == "" {
homeUser, err := user.Current()
if err != nil... | go | func ExpandPath(path string) string {
switch path {
case ".":
wd, err := os.Getwd()
if err != nil {
logger.Critical("Unable to get current working directory: %v", err)
return ""
}
path = wd
case "~":
homeVar := os.Getenv("HOME")
if homeVar == "" {
homeUser, err := user.Current()
if err != nil... | [
"func",
"ExpandPath",
"(",
"path",
"string",
")",
"string",
"{",
"switch",
"path",
"{",
"case",
"\".\"",
":",
"wd",
",",
"err",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Critical",
"(",
"\"Unable to get ... | // ExpandPath returns working directory path | [
"ExpandPath",
"returns",
"working",
"directory",
"path"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/cli/utils.go#L25-L47 | test |
kubicorn/kubicorn | cmd/completion.go | CompletionCmd | func CompletionCmd() *cobra.Command {
return &cobra.Command{
Use: "completion",
Short: "Generate completion code for bash and zsh shells.",
Long: `completion is used to output completion code for bash and zsh shells.
Before using completion features, you have to source completion code
from your .profile. T... | go | func CompletionCmd() *cobra.Command {
return &cobra.Command{
Use: "completion",
Short: "Generate completion code for bash and zsh shells.",
Long: `completion is used to output completion code for bash and zsh shells.
Before using completion features, you have to source completion code
from your .profile. T... | [
"func",
"CompletionCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"return",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"completion\"",
",",
"Short",
":",
"\"Generate completion code for bash and zsh shells.\"",
",",
"Long",
":",
"`completion is used to out... | // CompletionCmd represents the completion command | [
"CompletionCmd",
"represents",
"the",
"completion",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/completion.go#L44-L87 | test |
kubicorn/kubicorn | cmd/adopt.go | AdoptCmd | func AdoptCmd() *cobra.Command {
return &cobra.Command{
Use: "adopt",
Short: "Adopt a Kubernetes cluster into a Kubicorn state store",
Long: `Use this command to audit and adopt a Kubernetes cluster into a Kubicorn state store.
This command will query cloud resources and attempt to build a representation of... | go | func AdoptCmd() *cobra.Command {
return &cobra.Command{
Use: "adopt",
Short: "Adopt a Kubernetes cluster into a Kubicorn state store",
Long: `Use this command to audit and adopt a Kubernetes cluster into a Kubicorn state store.
This command will query cloud resources and attempt to build a representation of... | [
"func",
"AdoptCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"return",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"adopt\"",
",",
"Short",
":",
"\"Adopt a Kubernetes cluster into a Kubicorn state store\"",
",",
"Long",
":",
"`Use this command to audit and ... | // AdoptCmd represents the adopt command | [
"AdoptCmd",
"represents",
"the",
"adopt",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/adopt.go#L24-L36 | test |
kubicorn/kubicorn | pkg/cli/env.go | StrEnvDef | func StrEnvDef(env string, def string) string {
val := os.Getenv(env)
if val == "" {
return def
}
return val
} | go | func StrEnvDef(env string, def string) string {
val := os.Getenv(env)
if val == "" {
return def
}
return val
} | [
"func",
"StrEnvDef",
"(",
"env",
"string",
",",
"def",
"string",
")",
"string",
"{",
"val",
":=",
"os",
".",
"Getenv",
"(",
"env",
")",
"\n",
"if",
"val",
"==",
"\"\"",
"{",
"return",
"def",
"\n",
"}",
"\n",
"return",
"val",
"\n",
"}"
] | // StrEnvDef get environment variable, or some default def | [
"StrEnvDef",
"get",
"environment",
"variable",
"or",
"some",
"default",
"def"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/cli/env.go#L23-L29 | test |
kubicorn/kubicorn | pkg/cli/env.go | IntEnvDef | func IntEnvDef(env string, def int) int {
val := os.Getenv(env)
if val == "" {
return def
}
ival, err := strconv.Atoi(val)
if err != nil {
return def
}
return ival
} | go | func IntEnvDef(env string, def int) int {
val := os.Getenv(env)
if val == "" {
return def
}
ival, err := strconv.Atoi(val)
if err != nil {
return def
}
return ival
} | [
"func",
"IntEnvDef",
"(",
"env",
"string",
",",
"def",
"int",
")",
"int",
"{",
"val",
":=",
"os",
".",
"Getenv",
"(",
"env",
")",
"\n",
"if",
"val",
"==",
"\"\"",
"{",
"return",
"def",
"\n",
"}",
"\n",
"ival",
",",
"err",
":=",
"strconv",
".",
... | // IntEnvDef get environment variable, or some default def | [
"IntEnvDef",
"get",
"environment",
"variable",
"or",
"some",
"default",
"def"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/cli/env.go#L32-L42 | test |
kubicorn/kubicorn | pkg/cli/env.go | BoolEnvDef | func BoolEnvDef(env string, def bool) bool {
val := os.Getenv(env)
if val == "" {
return def
}
b, err := strconv.ParseBool(val)
if err != nil {
return def
}
return b
} | go | func BoolEnvDef(env string, def bool) bool {
val := os.Getenv(env)
if val == "" {
return def
}
b, err := strconv.ParseBool(val)
if err != nil {
return def
}
return b
} | [
"func",
"BoolEnvDef",
"(",
"env",
"string",
",",
"def",
"bool",
")",
"bool",
"{",
"val",
":=",
"os",
".",
"Getenv",
"(",
"env",
")",
"\n",
"if",
"val",
"==",
"\"\"",
"{",
"return",
"def",
"\n",
"}",
"\n",
"b",
",",
"err",
":=",
"strconv",
".",
... | // BoolEnvDef get environemnt variable and return bool. | [
"BoolEnvDef",
"get",
"environemnt",
"variable",
"and",
"return",
"bool",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/cli/env.go#L45-L55 | test |
kubicorn/kubicorn | pkg/parser/localresource.go | readFromFS | func readFromFS(sourcePath string) (string, error) {
// If sourcePath starts with ~ we search for $HOME
// and preppend it to the absolutePath overwriting the first character
// TODO: Add Windows support
if strings.HasPrefix(sourcePath, "~") {
homeDir := os.Getenv("HOME")
if homeDir == "" {
return "", fmt.E... | go | func readFromFS(sourcePath string) (string, error) {
// If sourcePath starts with ~ we search for $HOME
// and preppend it to the absolutePath overwriting the first character
// TODO: Add Windows support
if strings.HasPrefix(sourcePath, "~") {
homeDir := os.Getenv("HOME")
if homeDir == "" {
return "", fmt.E... | [
"func",
"readFromFS",
"(",
"sourcePath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"sourcePath",
",",
"\"~\"",
")",
"{",
"homeDir",
":=",
"os",
".",
"Getenv",
"(",
"\"HOME\"",
")",
"\n",
"if",
"homeDi... | // readFromFS reads file from a local path and returns as string | [
"readFromFS",
"reads",
"file",
"from",
"a",
"local",
"path",
"and",
"returns",
"as",
"string"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/parser/localresource.go#L26-L44 | test |
kubicorn/kubicorn | cmd/version.go | VersionCmd | func VersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Verify Kubicorn version",
Long: `Use this command to check the version of Kubicorn.
This command will return the version of the Kubicorn binary.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("%s\n", version.... | go | func VersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Verify Kubicorn version",
Long: `Use this command to check the version of Kubicorn.
This command will return the version of the Kubicorn binary.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("%s\n", version.... | [
"func",
"VersionCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"return",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"version\"",
",",
"Short",
":",
"\"Verify Kubicorn version\"",
",",
"Long",
":",
"`Use this command to check the version of Kubicorn.\t\tThi... | // VersionCmd represents the version command | [
"VersionCmd",
"represents",
"the",
"version",
"command"
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/cmd/version.go#L25-L36 | test |
kubicorn/kubicorn | pkg/signals/signals.go | NewSignalHandler | func NewSignalHandler(timeoutSeconds int) *Handler {
signals := make(chan os.Signal)
signal.Notify(signals, os.Interrupt, os.Kill)
return &Handler{
timeoutSeconds: timeoutSeconds,
signals: signals,
signalReceived: 0,
}
} | go | func NewSignalHandler(timeoutSeconds int) *Handler {
signals := make(chan os.Signal)
signal.Notify(signals, os.Interrupt, os.Kill)
return &Handler{
timeoutSeconds: timeoutSeconds,
signals: signals,
signalReceived: 0,
}
} | [
"func",
"NewSignalHandler",
"(",
"timeoutSeconds",
"int",
")",
"*",
"Handler",
"{",
"signals",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
")",
"\n",
"signal",
".",
"Notify",
"(",
"signals",
",",
"os",
".",
"Interrupt",
",",
"os",
".",
"Kill",
")",... | // NewSignalHandler creates a new Handler using given properties. | [
"NewSignalHandler",
"creates",
"a",
"new",
"Handler",
"using",
"given",
"properties",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/signals/signals.go#L57-L65 | test |
kubicorn/kubicorn | pkg/signals/signals.go | Register | func (h *Handler) Register() {
go func() {
h.timer = time.NewTimer(time.Duration(h.timeoutSeconds) * time.Second)
for {
select {
case s := <-h.signals:
switch {
case s == os.Interrupt:
if h.signalReceived == 0 {
h.signalReceived = 1
logger.Debug("SIGINT Received")
continue
... | go | func (h *Handler) Register() {
go func() {
h.timer = time.NewTimer(time.Duration(h.timeoutSeconds) * time.Second)
for {
select {
case s := <-h.signals:
switch {
case s == os.Interrupt:
if h.signalReceived == 0 {
h.signalReceived = 1
logger.Debug("SIGINT Received")
continue
... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"Register",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"h",
".",
"timer",
"=",
"time",
".",
"NewTimer",
"(",
"time",
".",
"Duration",
"(",
"h",
".",
"timeoutSeconds",
")",
"*",
"time",
".",
"Second",
")",
... | // Register starts handling signals. | [
"Register",
"starts",
"handling",
"signals",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/signals/signals.go#L79-L111 | test |
kubicorn/kubicorn | profiles/openstack/ecs/ubuntu_16_04.go | NewUbuntuCluster | func NewUbuntuCluster(name string) *cluster.Cluster {
var (
masterName = fmt.Sprintf("%s-master", name)
nodeName = fmt.Sprintf("%s-node", name)
)
controlPlaneProviderConfig := &cluster.ControlPlaneProviderConfig{
Cloud: cluster.CloudECS,
Location: "nl-ams1",
SSH: &cluster.SSH{
PublicKeyPath: "~/.ss... | go | func NewUbuntuCluster(name string) *cluster.Cluster {
var (
masterName = fmt.Sprintf("%s-master", name)
nodeName = fmt.Sprintf("%s-node", name)
)
controlPlaneProviderConfig := &cluster.ControlPlaneProviderConfig{
Cloud: cluster.CloudECS,
Location: "nl-ams1",
SSH: &cluster.SSH{
PublicKeyPath: "~/.ss... | [
"func",
"NewUbuntuCluster",
"(",
"name",
"string",
")",
"*",
"cluster",
".",
"Cluster",
"{",
"var",
"(",
"masterName",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"%s-master\"",
",",
"name",
")",
"\n",
"nodeName",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"%s-node\"",
"... | // NewUbuntuCluster creates a simple Ubuntu Openstack cluster. | [
"NewUbuntuCluster",
"creates",
"a",
"simple",
"Ubuntu",
"Openstack",
"cluster",
"."
] | c4a4b80994b4333709c0f8164faabd801866b986 | https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/profiles/openstack/ecs/ubuntu_16_04.go#L25-L126 | test |
jinzhu/now | now.go | BeginningOfHour | func (now *Now) BeginningOfHour() time.Time {
y, m, d := now.Date()
return time.Date(y, m, d, now.Time.Hour(), 0, 0, 0, now.Time.Location())
} | go | func (now *Now) BeginningOfHour() time.Time {
y, m, d := now.Date()
return time.Date(y, m, d, now.Time.Hour(), 0, 0, 0, now.Time.Location())
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"BeginningOfHour",
"(",
")",
"time",
".",
"Time",
"{",
"y",
",",
"m",
",",
"d",
":=",
"now",
".",
"Date",
"(",
")",
"\n",
"return",
"time",
".",
"Date",
"(",
"y",
",",
"m",
",",
"d",
",",
"now",
".",
"Ti... | // BeginningOfHour beginning of hour | [
"BeginningOfHour",
"beginning",
"of",
"hour"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L15-L18 | test |
jinzhu/now | now.go | BeginningOfDay | func (now *Now) BeginningOfDay() time.Time {
y, m, d := now.Date()
return time.Date(y, m, d, 0, 0, 0, 0, now.Time.Location())
} | go | func (now *Now) BeginningOfDay() time.Time {
y, m, d := now.Date()
return time.Date(y, m, d, 0, 0, 0, 0, now.Time.Location())
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"BeginningOfDay",
"(",
")",
"time",
".",
"Time",
"{",
"y",
",",
"m",
",",
"d",
":=",
"now",
".",
"Date",
"(",
")",
"\n",
"return",
"time",
".",
"Date",
"(",
"y",
",",
"m",
",",
"d",
",",
"0",
",",
"0",
... | // BeginningOfDay beginning of day | [
"BeginningOfDay",
"beginning",
"of",
"day"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L21-L24 | test |
jinzhu/now | now.go | BeginningOfWeek | func (now *Now) BeginningOfWeek() time.Time {
t := now.BeginningOfDay()
weekday := int(t.Weekday())
if WeekStartDay != time.Sunday {
weekStartDayInt := int(WeekStartDay)
if weekday < weekStartDayInt {
weekday = weekday + 7 - weekStartDayInt
} else {
weekday = weekday - weekStartDayInt
}
}
return t.... | go | func (now *Now) BeginningOfWeek() time.Time {
t := now.BeginningOfDay()
weekday := int(t.Weekday())
if WeekStartDay != time.Sunday {
weekStartDayInt := int(WeekStartDay)
if weekday < weekStartDayInt {
weekday = weekday + 7 - weekStartDayInt
} else {
weekday = weekday - weekStartDayInt
}
}
return t.... | [
"func",
"(",
"now",
"*",
"Now",
")",
"BeginningOfWeek",
"(",
")",
"time",
".",
"Time",
"{",
"t",
":=",
"now",
".",
"BeginningOfDay",
"(",
")",
"\n",
"weekday",
":=",
"int",
"(",
"t",
".",
"Weekday",
"(",
")",
")",
"\n",
"if",
"WeekStartDay",
"!=",
... | // BeginningOfWeek beginning of week | [
"BeginningOfWeek",
"beginning",
"of",
"week"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L27-L41 | test |
jinzhu/now | now.go | BeginningOfMonth | func (now *Now) BeginningOfMonth() time.Time {
y, m, _ := now.Date()
return time.Date(y, m, 1, 0, 0, 0, 0, now.Location())
} | go | func (now *Now) BeginningOfMonth() time.Time {
y, m, _ := now.Date()
return time.Date(y, m, 1, 0, 0, 0, 0, now.Location())
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"BeginningOfMonth",
"(",
")",
"time",
".",
"Time",
"{",
"y",
",",
"m",
",",
"_",
":=",
"now",
".",
"Date",
"(",
")",
"\n",
"return",
"time",
".",
"Date",
"(",
"y",
",",
"m",
",",
"1",
",",
"0",
",",
"0",... | // BeginningOfMonth beginning of month | [
"BeginningOfMonth",
"beginning",
"of",
"month"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L44-L47 | test |
jinzhu/now | now.go | BeginningOfQuarter | func (now *Now) BeginningOfQuarter() time.Time {
month := now.BeginningOfMonth()
offset := (int(month.Month()) - 1) % 3
return month.AddDate(0, -offset, 0)
} | go | func (now *Now) BeginningOfQuarter() time.Time {
month := now.BeginningOfMonth()
offset := (int(month.Month()) - 1) % 3
return month.AddDate(0, -offset, 0)
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"BeginningOfQuarter",
"(",
")",
"time",
".",
"Time",
"{",
"month",
":=",
"now",
".",
"BeginningOfMonth",
"(",
")",
"\n",
"offset",
":=",
"(",
"int",
"(",
"month",
".",
"Month",
"(",
")",
")",
"-",
"1",
")",
"%... | // BeginningOfQuarter beginning of quarter | [
"BeginningOfQuarter",
"beginning",
"of",
"quarter"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L50-L54 | test |
jinzhu/now | now.go | BeginningOfYear | func (now *Now) BeginningOfYear() time.Time {
y, _, _ := now.Date()
return time.Date(y, time.January, 1, 0, 0, 0, 0, now.Location())
} | go | func (now *Now) BeginningOfYear() time.Time {
y, _, _ := now.Date()
return time.Date(y, time.January, 1, 0, 0, 0, 0, now.Location())
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"BeginningOfYear",
"(",
")",
"time",
".",
"Time",
"{",
"y",
",",
"_",
",",
"_",
":=",
"now",
".",
"Date",
"(",
")",
"\n",
"return",
"time",
".",
"Date",
"(",
"y",
",",
"time",
".",
"January",
",",
"1",
","... | // BeginningOfYear BeginningOfYear beginning of year | [
"BeginningOfYear",
"BeginningOfYear",
"beginning",
"of",
"year"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L57-L60 | test |
jinzhu/now | now.go | EndOfMinute | func (now *Now) EndOfMinute() time.Time {
return now.BeginningOfMinute().Add(time.Minute - time.Nanosecond)
} | go | func (now *Now) EndOfMinute() time.Time {
return now.BeginningOfMinute().Add(time.Minute - time.Nanosecond)
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfMinute",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"now",
".",
"BeginningOfMinute",
"(",
")",
".",
"Add",
"(",
"time",
".",
"Minute",
"-",
"time",
".",
"Nanosecond",
")",
"\n",
"}"
] | // EndOfMinute end of minute | [
"EndOfMinute",
"end",
"of",
"minute"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L63-L65 | test |
jinzhu/now | now.go | EndOfHour | func (now *Now) EndOfHour() time.Time {
return now.BeginningOfHour().Add(time.Hour - time.Nanosecond)
} | go | func (now *Now) EndOfHour() time.Time {
return now.BeginningOfHour().Add(time.Hour - time.Nanosecond)
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfHour",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"now",
".",
"BeginningOfHour",
"(",
")",
".",
"Add",
"(",
"time",
".",
"Hour",
"-",
"time",
".",
"Nanosecond",
")",
"\n",
"}"
] | // EndOfHour end of hour | [
"EndOfHour",
"end",
"of",
"hour"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L68-L70 | test |
jinzhu/now | now.go | EndOfDay | func (now *Now) EndOfDay() time.Time {
y, m, d := now.Date()
return time.Date(y, m, d, 23, 59, 59, int(time.Second-time.Nanosecond), now.Location())
} | go | func (now *Now) EndOfDay() time.Time {
y, m, d := now.Date()
return time.Date(y, m, d, 23, 59, 59, int(time.Second-time.Nanosecond), now.Location())
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfDay",
"(",
")",
"time",
".",
"Time",
"{",
"y",
",",
"m",
",",
"d",
":=",
"now",
".",
"Date",
"(",
")",
"\n",
"return",
"time",
".",
"Date",
"(",
"y",
",",
"m",
",",
"d",
",",
"23",
",",
"59",
","... | // EndOfDay end of day | [
"EndOfDay",
"end",
"of",
"day"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L73-L76 | test |
jinzhu/now | now.go | EndOfWeek | func (now *Now) EndOfWeek() time.Time {
return now.BeginningOfWeek().AddDate(0, 0, 7).Add(-time.Nanosecond)
} | go | func (now *Now) EndOfWeek() time.Time {
return now.BeginningOfWeek().AddDate(0, 0, 7).Add(-time.Nanosecond)
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfWeek",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"now",
".",
"BeginningOfWeek",
"(",
")",
".",
"AddDate",
"(",
"0",
",",
"0",
",",
"7",
")",
".",
"Add",
"(",
"-",
"time",
".",
"Nanosecond",
")",
"\... | // EndOfWeek end of week | [
"EndOfWeek",
"end",
"of",
"week"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L79-L81 | test |
jinzhu/now | now.go | EndOfMonth | func (now *Now) EndOfMonth() time.Time {
return now.BeginningOfMonth().AddDate(0, 1, 0).Add(-time.Nanosecond)
} | go | func (now *Now) EndOfMonth() time.Time {
return now.BeginningOfMonth().AddDate(0, 1, 0).Add(-time.Nanosecond)
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfMonth",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"now",
".",
"BeginningOfMonth",
"(",
")",
".",
"AddDate",
"(",
"0",
",",
"1",
",",
"0",
")",
".",
"Add",
"(",
"-",
"time",
".",
"Nanosecond",
")",
... | // EndOfMonth end of month | [
"EndOfMonth",
"end",
"of",
"month"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L84-L86 | test |
jinzhu/now | now.go | EndOfQuarter | func (now *Now) EndOfQuarter() time.Time {
return now.BeginningOfQuarter().AddDate(0, 3, 0).Add(-time.Nanosecond)
} | go | func (now *Now) EndOfQuarter() time.Time {
return now.BeginningOfQuarter().AddDate(0, 3, 0).Add(-time.Nanosecond)
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfQuarter",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"now",
".",
"BeginningOfQuarter",
"(",
")",
".",
"AddDate",
"(",
"0",
",",
"3",
",",
"0",
")",
".",
"Add",
"(",
"-",
"time",
".",
"Nanosecond",
")"... | // EndOfQuarter end of quarter | [
"EndOfQuarter",
"end",
"of",
"quarter"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L89-L91 | test |
jinzhu/now | now.go | EndOfYear | func (now *Now) EndOfYear() time.Time {
return now.BeginningOfYear().AddDate(1, 0, 0).Add(-time.Nanosecond)
} | go | func (now *Now) EndOfYear() time.Time {
return now.BeginningOfYear().AddDate(1, 0, 0).Add(-time.Nanosecond)
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfYear",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"now",
".",
"BeginningOfYear",
"(",
")",
".",
"AddDate",
"(",
"1",
",",
"0",
",",
"0",
")",
".",
"Add",
"(",
"-",
"time",
".",
"Nanosecond",
")",
"\... | // EndOfYear end of year | [
"EndOfYear",
"end",
"of",
"year"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L94-L96 | test |
jinzhu/now | now.go | MustParse | func (now *Now) MustParse(strs ...string) (t time.Time) {
t, err := now.Parse(strs...)
if err != nil {
panic(err)
}
return t
} | go | func (now *Now) MustParse(strs ...string) (t time.Time) {
t, err := now.Parse(strs...)
if err != nil {
panic(err)
}
return t
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"MustParse",
"(",
"strs",
"...",
"string",
")",
"(",
"t",
"time",
".",
"Time",
")",
"{",
"t",
",",
"err",
":=",
"now",
".",
"Parse",
"(",
"strs",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"... | // MustParse must parse string to time or it will panic | [
"MustParse",
"must",
"parse",
"string",
"to",
"time",
"or",
"it",
"will",
"panic"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L190-L196 | test |
jinzhu/now | now.go | Between | func (now *Now) Between(begin, end string) bool {
beginTime := now.MustParse(begin)
endTime := now.MustParse(end)
return now.After(beginTime) && now.Before(endTime)
} | go | func (now *Now) Between(begin, end string) bool {
beginTime := now.MustParse(begin)
endTime := now.MustParse(end)
return now.After(beginTime) && now.Before(endTime)
} | [
"func",
"(",
"now",
"*",
"Now",
")",
"Between",
"(",
"begin",
",",
"end",
"string",
")",
"bool",
"{",
"beginTime",
":=",
"now",
".",
"MustParse",
"(",
"begin",
")",
"\n",
"endTime",
":=",
"now",
".",
"MustParse",
"(",
"end",
")",
"\n",
"return",
"n... | // Between check time between the begin, end time or not | [
"Between",
"check",
"time",
"between",
"the",
"begin",
"end",
"time",
"or",
"not"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/now.go#L199-L203 | test |
jinzhu/now | main.go | ParseInLocation | func ParseInLocation(loc *time.Location, strs ...string) (time.Time, error) {
return New(time.Now().In(loc)).Parse(strs...)
} | go | func ParseInLocation(loc *time.Location, strs ...string) (time.Time, error) {
return New(time.Now().In(loc)).Parse(strs...)
} | [
"func",
"ParseInLocation",
"(",
"loc",
"*",
"time",
".",
"Location",
",",
"strs",
"...",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"return",
"New",
"(",
"time",
".",
"Now",
"(",
")",
".",
"In",
"(",
"loc",
")",
")",
".",
... | // ParseInLocation parse string to time in location | [
"ParseInLocation",
"parse",
"string",
"to",
"time",
"in",
"location"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/main.go#L121-L123 | test |
jinzhu/now | main.go | MustParse | func MustParse(strs ...string) time.Time {
return New(time.Now()).MustParse(strs...)
} | go | func MustParse(strs ...string) time.Time {
return New(time.Now()).MustParse(strs...)
} | [
"func",
"MustParse",
"(",
"strs",
"...",
"string",
")",
"time",
".",
"Time",
"{",
"return",
"New",
"(",
"time",
".",
"Now",
"(",
")",
")",
".",
"MustParse",
"(",
"strs",
"...",
")",
"\n",
"}"
] | // MustParse must parse string to time or will panic | [
"MustParse",
"must",
"parse",
"string",
"to",
"time",
"or",
"will",
"panic"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/main.go#L126-L128 | test |
jinzhu/now | main.go | MustParseInLocation | func MustParseInLocation(loc *time.Location, strs ...string) time.Time {
return New(time.Now().In(loc)).MustParse(strs...)
} | go | func MustParseInLocation(loc *time.Location, strs ...string) time.Time {
return New(time.Now().In(loc)).MustParse(strs...)
} | [
"func",
"MustParseInLocation",
"(",
"loc",
"*",
"time",
".",
"Location",
",",
"strs",
"...",
"string",
")",
"time",
".",
"Time",
"{",
"return",
"New",
"(",
"time",
".",
"Now",
"(",
")",
".",
"In",
"(",
"loc",
")",
")",
".",
"MustParse",
"(",
"strs"... | // MustParseInLocation must parse string to time in location or will panic | [
"MustParseInLocation",
"must",
"parse",
"string",
"to",
"time",
"in",
"location",
"or",
"will",
"panic"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/main.go#L131-L133 | test |
jinzhu/now | main.go | Between | func Between(time1, time2 string) bool {
return New(time.Now()).Between(time1, time2)
} | go | func Between(time1, time2 string) bool {
return New(time.Now()).Between(time1, time2)
} | [
"func",
"Between",
"(",
"time1",
",",
"time2",
"string",
")",
"bool",
"{",
"return",
"New",
"(",
"time",
".",
"Now",
"(",
")",
")",
".",
"Between",
"(",
"time1",
",",
"time2",
")",
"\n",
"}"
] | // Between check now between the begin, end time or not | [
"Between",
"check",
"now",
"between",
"the",
"begin",
"end",
"time",
"or",
"not"
] | 8ec929ed50c3ac25ce77ba4486e1f277c552c591 | https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/main.go#L136-L138 | test |
op/go-logging | memory.go | NewChannelMemoryBackend | func NewChannelMemoryBackend(size int) *ChannelMemoryBackend {
backend := &ChannelMemoryBackend{
maxSize: size,
incoming: make(chan *Record, 1024),
events: make(chan event),
}
backend.Start()
return backend
} | go | func NewChannelMemoryBackend(size int) *ChannelMemoryBackend {
backend := &ChannelMemoryBackend{
maxSize: size,
incoming: make(chan *Record, 1024),
events: make(chan event),
}
backend.Start()
return backend
} | [
"func",
"NewChannelMemoryBackend",
"(",
"size",
"int",
")",
"*",
"ChannelMemoryBackend",
"{",
"backend",
":=",
"&",
"ChannelMemoryBackend",
"{",
"maxSize",
":",
"size",
",",
"incoming",
":",
"make",
"(",
"chan",
"*",
"Record",
",",
"1024",
")",
",",
"events"... | // NewChannelMemoryBackend creates a simple in-memory logging backend which
// utilizes a go channel for communication.
//
// Start will automatically be called by this function. | [
"NewChannelMemoryBackend",
"creates",
"a",
"simple",
"in",
"-",
"memory",
"logging",
"backend",
"which",
"utilizes",
"a",
"go",
"channel",
"for",
"communication",
".",
"Start",
"will",
"automatically",
"be",
"called",
"by",
"this",
"function",
"."
] | 970db520ece77730c7e4724c61121037378659d9 | https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/memory.go#L146-L154 | test |
op/go-logging | memory.go | Start | func (b *ChannelMemoryBackend) Start() {
b.mu.Lock()
defer b.mu.Unlock()
// Launch the goroutine unless it's already running.
if b.running != true {
b.running = true
b.stopWg.Add(1)
go b.process()
}
} | go | func (b *ChannelMemoryBackend) Start() {
b.mu.Lock()
defer b.mu.Unlock()
// Launch the goroutine unless it's already running.
if b.running != true {
b.running = true
b.stopWg.Add(1)
go b.process()
}
} | [
"func",
"(",
"b",
"*",
"ChannelMemoryBackend",
")",
"Start",
"(",
")",
"{",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"b",
".",
"running",
"!=",
"true",
"{",
"b",
".",
"running",
... | // Start launches the internal goroutine which starts processing data from the
// input channel. | [
"Start",
"launches",
"the",
"internal",
"goroutine",
"which",
"starts",
"processing",
"data",
"from",
"the",
"input",
"channel",
"."
] | 970db520ece77730c7e4724c61121037378659d9 | https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/memory.go#L158-L168 | test |
op/go-logging | memory.go | Flush | func (b *ChannelMemoryBackend) Flush() {
b.flushWg.Add(1)
b.events <- eventFlush
b.flushWg.Wait()
} | go | func (b *ChannelMemoryBackend) Flush() {
b.flushWg.Add(1)
b.events <- eventFlush
b.flushWg.Wait()
} | [
"func",
"(",
"b",
"*",
"ChannelMemoryBackend",
")",
"Flush",
"(",
")",
"{",
"b",
".",
"flushWg",
".",
"Add",
"(",
"1",
")",
"\n",
"b",
".",
"events",
"<-",
"eventFlush",
"\n",
"b",
".",
"flushWg",
".",
"Wait",
"(",
")",
"\n",
"}"
] | // Flush waits until all records in the buffered channel have been processed. | [
"Flush",
"waits",
"until",
"all",
"records",
"in",
"the",
"buffered",
"channel",
"have",
"been",
"processed",
"."
] | 970db520ece77730c7e4724c61121037378659d9 | https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/memory.go#L207-L211 | test |
op/go-logging | memory.go | Stop | func (b *ChannelMemoryBackend) Stop() {
b.mu.Lock()
if b.running == true {
b.running = false
b.events <- eventStop
}
b.mu.Unlock()
b.stopWg.Wait()
} | go | func (b *ChannelMemoryBackend) Stop() {
b.mu.Lock()
if b.running == true {
b.running = false
b.events <- eventStop
}
b.mu.Unlock()
b.stopWg.Wait()
} | [
"func",
"(",
"b",
"*",
"ChannelMemoryBackend",
")",
"Stop",
"(",
")",
"{",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"b",
".",
"running",
"==",
"true",
"{",
"b",
".",
"running",
"=",
"false",
"\n",
"b",
".",
"events",
"<-",
"eventStop",
... | // Stop signals the internal goroutine to exit and waits until it have. | [
"Stop",
"signals",
"the",
"internal",
"goroutine",
"to",
"exit",
"and",
"waits",
"until",
"it",
"have",
"."
] | 970db520ece77730c7e4724c61121037378659d9 | https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/memory.go#L214-L222 | test |
op/go-logging | logger.go | Formatted | func (r *Record) Formatted(calldepth int) string {
if r.formatted == "" {
var buf bytes.Buffer
r.formatter.Format(calldepth+1, r, &buf)
r.formatted = buf.String()
}
return r.formatted
} | go | func (r *Record) Formatted(calldepth int) string {
if r.formatted == "" {
var buf bytes.Buffer
r.formatter.Format(calldepth+1, r, &buf)
r.formatted = buf.String()
}
return r.formatted
} | [
"func",
"(",
"r",
"*",
"Record",
")",
"Formatted",
"(",
"calldepth",
"int",
")",
"string",
"{",
"if",
"r",
".",
"formatted",
"==",
"\"\"",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"r",
".",
"formatter",
".",
"Format",
"(",
"calldepth",
"+",
... | // Formatted returns the formatted log record string. | [
"Formatted",
"returns",
"the",
"formatted",
"log",
"record",
"string",
"."
] | 970db520ece77730c7e4724c61121037378659d9 | https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/logger.go#L59-L66 | test |
op/go-logging | logger.go | Message | func (r *Record) Message() string {
if r.message == nil {
// Redact the arguments that implements the Redactor interface
for i, arg := range r.Args {
if redactor, ok := arg.(Redactor); ok == true {
r.Args[i] = redactor.Redacted()
}
}
var buf bytes.Buffer
if r.fmt != nil {
fmt.Fprintf(&buf, *r.fm... | go | func (r *Record) Message() string {
if r.message == nil {
// Redact the arguments that implements the Redactor interface
for i, arg := range r.Args {
if redactor, ok := arg.(Redactor); ok == true {
r.Args[i] = redactor.Redacted()
}
}
var buf bytes.Buffer
if r.fmt != nil {
fmt.Fprintf(&buf, *r.fm... | [
"func",
"(",
"r",
"*",
"Record",
")",
"Message",
"(",
")",
"string",
"{",
"if",
"r",
".",
"message",
"==",
"nil",
"{",
"for",
"i",
",",
"arg",
":=",
"range",
"r",
".",
"Args",
"{",
"if",
"redactor",
",",
"ok",
":=",
"arg",
".",
"(",
"Redactor",... | // Message returns the log record message. | [
"Message",
"returns",
"the",
"log",
"record",
"message",
"."
] | 970db520ece77730c7e4724c61121037378659d9 | https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/logger.go#L69-L89 | test |
op/go-logging | logger.go | SetBackend | func (l *Logger) SetBackend(backend LeveledBackend) {
l.backend = backend
l.haveBackend = true
} | go | func (l *Logger) SetBackend(backend LeveledBackend) {
l.backend = backend
l.haveBackend = true
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"SetBackend",
"(",
"backend",
"LeveledBackend",
")",
"{",
"l",
".",
"backend",
"=",
"backend",
"\n",
"l",
".",
"haveBackend",
"=",
"true",
"\n",
"}"
] | // SetBackend overrides any previously defined backend for this logger. | [
"SetBackend",
"overrides",
"any",
"previously",
"defined",
"backend",
"for",
"this",
"logger",
"."
] | 970db520ece77730c7e4724c61121037378659d9 | https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/logger.go#L104-L107 | test |
op/go-logging | logger.go | MustGetLogger | func MustGetLogger(module string) *Logger {
logger, err := GetLogger(module)
if err != nil {
panic("logger: " + module + ": " + err.Error())
}
return logger
} | go | func MustGetLogger(module string) *Logger {
logger, err := GetLogger(module)
if err != nil {
panic("logger: " + module + ": " + err.Error())
}
return logger
} | [
"func",
"MustGetLogger",
"(",
"module",
"string",
")",
"*",
"Logger",
"{",
"logger",
",",
"err",
":=",
"GetLogger",
"(",
"module",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"logger: \"",
"+",
"module",
"+",
"\": \"",
"+",
"err",
".",
... | // MustGetLogger is like GetLogger but panics if the logger can't be created.
// It simplifies safe initialization of a global logger for eg. a package. | [
"MustGetLogger",
"is",
"like",
"GetLogger",
"but",
"panics",
"if",
"the",
"logger",
"can",
"t",
"be",
"created",
".",
"It",
"simplifies",
"safe",
"initialization",
"of",
"a",
"global",
"logger",
"for",
"eg",
".",
"a",
"package",
"."
] | 970db520ece77730c7e4724c61121037378659d9 | https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/logger.go#L118-L124 | test |
op/go-logging | logger.go | Reset | func Reset() {
// TODO make a global Init() method to be less magic? or make it such that
// if there's no backends at all configured, we could use some tricks to
// automatically setup backends based if we have a TTY or not.
sequenceNo = 0
b := SetBackend(NewLogBackend(os.Stderr, "", log.LstdFlags))
b.SetLevel(D... | go | func Reset() {
// TODO make a global Init() method to be less magic? or make it such that
// if there's no backends at all configured, we could use some tricks to
// automatically setup backends based if we have a TTY or not.
sequenceNo = 0
b := SetBackend(NewLogBackend(os.Stderr, "", log.LstdFlags))
b.SetLevel(D... | [
"func",
"Reset",
"(",
")",
"{",
"sequenceNo",
"=",
"0",
"\n",
"b",
":=",
"SetBackend",
"(",
"NewLogBackend",
"(",
"os",
".",
"Stderr",
",",
"\"\"",
",",
"log",
".",
"LstdFlags",
")",
")",
"\n",
"b",
".",
"SetLevel",
"(",
"DEBUG",
",",
"\"\"",
")",
... | // Reset restores the internal state of the logging library. | [
"Reset",
"restores",
"the",
"internal",
"state",
"of",
"the",
"logging",
"library",
"."
] | 970db520ece77730c7e4724c61121037378659d9 | https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/logger.go#L127-L136 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.