id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1,200 | mweagle/Sparta | aws/step/step.go | WithRetriers | func (ps *ParallelState) WithRetriers(retries ...*TaskRetry) *ParallelState {
if ps.Retriers == nil {
ps.Retriers = make([]*TaskRetry, 0)
}
ps.Retriers = append(ps.Retriers, retries...)
return ps
} | go | func (ps *ParallelState) WithRetriers(retries ...*TaskRetry) *ParallelState {
if ps.Retriers == nil {
ps.Retriers = make([]*TaskRetry, 0)
}
ps.Retriers = append(ps.Retriers, retries...)
return ps
} | [
"func",
"(",
"ps",
"*",
"ParallelState",
")",
"WithRetriers",
"(",
"retries",
"...",
"*",
"TaskRetry",
")",
"*",
"ParallelState",
"{",
"if",
"ps",
".",
"Retriers",
"==",
"nil",
"{",
"ps",
".",
"Retriers",
"=",
"make",
"(",
"[",
"]",
"*",
"TaskRetry",
... | // WithRetriers is the fluent builder for TaskState | [
"WithRetriers",
"is",
"the",
"fluent",
"builder",
"for",
"TaskState"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/step.go#L1360-L1366 |
1,201 | mweagle/Sparta | aws/step/step.go | WithCatchers | func (ps *ParallelState) WithCatchers(catch ...*TaskCatch) *ParallelState {
if ps.Catchers == nil {
ps.Catchers = make([]*TaskCatch, 0)
}
ps.Catchers = append(ps.Catchers, catch...)
return ps
} | go | func (ps *ParallelState) WithCatchers(catch ...*TaskCatch) *ParallelState {
if ps.Catchers == nil {
ps.Catchers = make([]*TaskCatch, 0)
}
ps.Catchers = append(ps.Catchers, catch...)
return ps
} | [
"func",
"(",
"ps",
"*",
"ParallelState",
")",
"WithCatchers",
"(",
"catch",
"...",
"*",
"TaskCatch",
")",
"*",
"ParallelState",
"{",
"if",
"ps",
".",
"Catchers",
"==",
"nil",
"{",
"ps",
".",
"Catchers",
"=",
"make",
"(",
"[",
"]",
"*",
"TaskCatch",
"... | // WithCatchers is the fluent builder for TaskState | [
"WithCatchers",
"is",
"the",
"fluent",
"builder",
"for",
"TaskState"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/step.go#L1369-L1375 |
1,202 | mweagle/Sparta | aws/step/step.go | NewParallelState | func NewParallelState(parallelStateName string, states StateMachine) *ParallelState {
return &ParallelState{
baseInnerState: baseInnerState{
name: parallelStateName,
id: rand.Int63(),
},
States: states,
}
} | go | func NewParallelState(parallelStateName string, states StateMachine) *ParallelState {
return &ParallelState{
baseInnerState: baseInnerState{
name: parallelStateName,
id: rand.Int63(),
},
States: states,
}
} | [
"func",
"NewParallelState",
"(",
"parallelStateName",
"string",
",",
"states",
"StateMachine",
")",
"*",
"ParallelState",
"{",
"return",
"&",
"ParallelState",
"{",
"baseInnerState",
":",
"baseInnerState",
"{",
"name",
":",
"parallelStateName",
",",
"id",
":",
"ran... | // NewParallelState returns a "ParallelState" with the supplied
// information | [
"NewParallelState",
"returns",
"a",
"ParallelState",
"with",
"the",
"supplied",
"information"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/step.go#L1436-L1444 |
1,203 | mweagle/Sparta | aws/step/step.go | Comment | func (sm *StateMachine) Comment(comment string) *StateMachine {
sm.comment = comment
return sm
} | go | func (sm *StateMachine) Comment(comment string) *StateMachine {
sm.comment = comment
return sm
} | [
"func",
"(",
"sm",
"*",
"StateMachine",
")",
"Comment",
"(",
"comment",
"string",
")",
"*",
"StateMachine",
"{",
"sm",
".",
"comment",
"=",
"comment",
"\n",
"return",
"sm",
"\n",
"}"
] | //Comment sets the StateMachine comment | [
"Comment",
"sets",
"the",
"StateMachine",
"comment"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/step.go#L1461-L1464 |
1,204 | mweagle/Sparta | aws/step/step.go | WithRoleArn | func (sm *StateMachine) WithRoleArn(roleArn gocf.Stringable) *StateMachine {
sm.roleArn = roleArn
return sm
} | go | func (sm *StateMachine) WithRoleArn(roleArn gocf.Stringable) *StateMachine {
sm.roleArn = roleArn
return sm
} | [
"func",
"(",
"sm",
"*",
"StateMachine",
")",
"WithRoleArn",
"(",
"roleArn",
"gocf",
".",
"Stringable",
")",
"*",
"StateMachine",
"{",
"sm",
".",
"roleArn",
"=",
"roleArn",
"\n",
"return",
"sm",
"\n",
"}"
] | //WithRoleArn sets the state machine roleArn | [
"WithRoleArn",
"sets",
"the",
"state",
"machine",
"roleArn"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/step.go#L1467-L1470 |
1,205 | mweagle/Sparta | aws/step/step.go | validate | func (sm *StateMachine) validate() []error {
validationErrors := make([]error, 0)
if sm.stateDefinitionError != nil {
validationErrors = append(validationErrors, sm.stateDefinitionError)
}
// TODO - add Catcher validator
/*
Each Catcher MUST contain a field named “ErrorEquals”, specified exactly as with the R... | go | func (sm *StateMachine) validate() []error {
validationErrors := make([]error, 0)
if sm.stateDefinitionError != nil {
validationErrors = append(validationErrors, sm.stateDefinitionError)
}
// TODO - add Catcher validator
/*
Each Catcher MUST contain a field named “ErrorEquals”, specified exactly as with the R... | [
"func",
"(",
"sm",
"*",
"StateMachine",
")",
"validate",
"(",
")",
"[",
"]",
"error",
"{",
"validationErrors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"if",
"sm",
".",
"stateDefinitionError",
"!=",
"nil",
"{",
"validationErrors",
"="... | // validate performs any validation against the state machine
// prior to marshaling | [
"validate",
"performs",
"any",
"validation",
"against",
"the",
"state",
"machine",
"prior",
"to",
"marshaling"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/step.go#L1474-L1489 |
1,206 | mweagle/Sparta | aws/step/step.go | StateMachineDecorator | func (sm *StateMachine) StateMachineDecorator() sparta.ServiceDecoratorHookFunc {
cfName := sparta.CloudFormationResourceName("StateMachine", "StateMachine")
return sm.StateMachineNamedDecorator(cfName)
} | go | func (sm *StateMachine) StateMachineDecorator() sparta.ServiceDecoratorHookFunc {
cfName := sparta.CloudFormationResourceName("StateMachine", "StateMachine")
return sm.StateMachineNamedDecorator(cfName)
} | [
"func",
"(",
"sm",
"*",
"StateMachine",
")",
"StateMachineDecorator",
"(",
")",
"sparta",
".",
"ServiceDecoratorHookFunc",
"{",
"cfName",
":=",
"sparta",
".",
"CloudFormationResourceName",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"sm",
".",
"St... | // StateMachineDecorator is a decorator that returns a default
// CloudFormationResource named decorator | [
"StateMachineDecorator",
"is",
"a",
"decorator",
"that",
"returns",
"a",
"default",
"CloudFormationResource",
"named",
"decorator"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/step.go#L1493-L1496 |
1,207 | mweagle/Sparta | aws/step/step.go | NewStateMachine | func NewStateMachine(stateMachineName string,
startState TransitionState) *StateMachine {
uniqueStates := make(map[string]MachineState)
pendingStates := []MachineState{startState}
duplicateStateNames := make(map[string]bool)
nodeVisited := func(node MachineState) bool {
if node == nil {
return true
}
_, ... | go | func NewStateMachine(stateMachineName string,
startState TransitionState) *StateMachine {
uniqueStates := make(map[string]MachineState)
pendingStates := []MachineState{startState}
duplicateStateNames := make(map[string]bool)
nodeVisited := func(node MachineState) bool {
if node == nil {
return true
}
_, ... | [
"func",
"NewStateMachine",
"(",
"stateMachineName",
"string",
",",
"startState",
"TransitionState",
")",
"*",
"StateMachine",
"{",
"uniqueStates",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"MachineState",
")",
"\n",
"pendingStates",
":=",
"[",
"]",
"MachineS... | // NewStateMachine returns a new StateMachine instance | [
"NewStateMachine",
"returns",
"a",
"new",
"StateMachine",
"instance"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/step.go#L1629-L1680 |
1,208 | mweagle/Sparta | magefile/actions.go | Log | func Log(formatSpecifier string, args ...interface{}) {
if mg.Verbose() {
if len(args) != 0 {
log.Printf(formatSpecifier, args...)
} else {
log.Print(formatSpecifier)
}
}
} | go | func Log(formatSpecifier string, args ...interface{}) {
if mg.Verbose() {
if len(args) != 0 {
log.Printf(formatSpecifier, args...)
} else {
log.Print(formatSpecifier)
}
}
} | [
"func",
"Log",
"(",
"formatSpecifier",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"mg",
".",
"Verbose",
"(",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"0",
"{",
"log",
".",
"Printf",
"(",
"formatSpecifier",
",",
"args... | // Log is a mage verbose aware log function | [
"Log",
"is",
"a",
"mage",
"verbose",
"aware",
"log",
"function"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/magefile/actions.go#L14-L22 |
1,209 | mweagle/Sparta | magefile/actions.go | Script | func Script(commands [][]string) error {
for _, eachCommand := range commands {
var commandErr error
if len(eachCommand) <= 1 {
commandErr = sh.Run(eachCommand[0])
} else {
commandErr = sh.Run(eachCommand[0], eachCommand[1:]...)
}
if commandErr != nil {
return commandErr
}
}
return nil
} | go | func Script(commands [][]string) error {
for _, eachCommand := range commands {
var commandErr error
if len(eachCommand) <= 1 {
commandErr = sh.Run(eachCommand[0])
} else {
commandErr = sh.Run(eachCommand[0], eachCommand[1:]...)
}
if commandErr != nil {
return commandErr
}
}
return nil
} | [
"func",
"Script",
"(",
"commands",
"[",
"]",
"[",
"]",
"string",
")",
"error",
"{",
"for",
"_",
",",
"eachCommand",
":=",
"range",
"commands",
"{",
"var",
"commandErr",
"error",
"\n",
"if",
"len",
"(",
"eachCommand",
")",
"<=",
"1",
"{",
"commandErr",
... | // Script is a 2d array of commands to run as a script | [
"Script",
"is",
"a",
"2d",
"array",
"of",
"commands",
"to",
"run",
"as",
"a",
"script"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/magefile/actions.go#L25-L38 |
1,210 | mweagle/Sparta | magefile/actions.go | ApplyToSource | func ApplyToSource(fileExtension string,
ignoredSubdirectories []string,
commandParts ...string) error {
if len(commandParts) <= 0 {
return errors.New("applyToSource requires a command to apply to source files")
}
eligibleSourceFiles, eligibleSourceFilesErr := sourceFilesOfType(fileExtension, ignoredSubdirectori... | go | func ApplyToSource(fileExtension string,
ignoredSubdirectories []string,
commandParts ...string) error {
if len(commandParts) <= 0 {
return errors.New("applyToSource requires a command to apply to source files")
}
eligibleSourceFiles, eligibleSourceFilesErr := sourceFilesOfType(fileExtension, ignoredSubdirectori... | [
"func",
"ApplyToSource",
"(",
"fileExtension",
"string",
",",
"ignoredSubdirectories",
"[",
"]",
"string",
",",
"commandParts",
"...",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"commandParts",
")",
"<=",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
... | // ApplyToSource is a mage compatible function that applies a
// command to your source tree | [
"ApplyToSource",
"is",
"a",
"mage",
"compatible",
"function",
"that",
"applies",
"a",
"command",
"to",
"your",
"source",
"tree"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/magefile/actions.go#L42-L69 |
1,211 | mweagle/Sparta | magefile/actions.go | SpartaCommand | func SpartaCommand(commandParts ...string) error {
noopValue := ""
parsedBool, parsedBoolErr := strconv.ParseBool(os.Getenv("NOOP"))
if parsedBoolErr == nil && parsedBool {
noopValue = "--noop"
}
curDir, curDirErr := os.Getwd()
if curDirErr != nil {
return errors.New("Failed to get current directory. Error: "... | go | func SpartaCommand(commandParts ...string) error {
noopValue := ""
parsedBool, parsedBoolErr := strconv.ParseBool(os.Getenv("NOOP"))
if parsedBoolErr == nil && parsedBool {
noopValue = "--noop"
}
curDir, curDirErr := os.Getwd()
if curDirErr != nil {
return errors.New("Failed to get current directory. Error: "... | [
"func",
"SpartaCommand",
"(",
"commandParts",
"...",
"string",
")",
"error",
"{",
"noopValue",
":=",
"\"",
"\"",
"\n",
"parsedBool",
",",
"parsedBoolErr",
":=",
"strconv",
".",
"ParseBool",
"(",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
")",
"\n",
"if",... | // SpartaCommand issues a go run command that encapsulates resolving
// global env vars that can be translated into Sparta command line options | [
"SpartaCommand",
"issues",
"a",
"go",
"run",
"command",
"that",
"encapsulates",
"resolving",
"global",
"env",
"vars",
"that",
"can",
"be",
"translated",
"into",
"Sparta",
"command",
"line",
"options"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/magefile/actions.go#L73-L97 |
1,212 | mweagle/Sparta | magefile/actions.go | Provision | func Provision() error {
// Get the bucketName
bucketName := os.Getenv("S3_BUCKET")
if bucketName == "" {
return errors.New("Provision requires env.S3_BUCKET to be defined")
}
return SpartaCommand("provision", "--s3Bucket", bucketName)
} | go | func Provision() error {
// Get the bucketName
bucketName := os.Getenv("S3_BUCKET")
if bucketName == "" {
return errors.New("Provision requires env.S3_BUCKET to be defined")
}
return SpartaCommand("provision", "--s3Bucket", bucketName)
} | [
"func",
"Provision",
"(",
")",
"error",
"{",
"// Get the bucketName",
"bucketName",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"bucketName",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n... | // Provision deploys the given service | [
"Provision",
"deploys",
"the",
"given",
"service"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/magefile/actions.go#L100-L107 |
1,213 | mweagle/Sparta | magefile/actions.go | Describe | func Describe() error {
// Get the bucketName
bucketName := os.Getenv("S3_BUCKET")
if bucketName == "" {
return errors.New("Describe requires env.S3_BUCKET to be defined")
}
return SpartaCommand("describe", "--s3Bucket", bucketName, "--out", "graph.html")
} | go | func Describe() error {
// Get the bucketName
bucketName := os.Getenv("S3_BUCKET")
if bucketName == "" {
return errors.New("Describe requires env.S3_BUCKET to be defined")
}
return SpartaCommand("describe", "--s3Bucket", bucketName, "--out", "graph.html")
} | [
"func",
"Describe",
"(",
")",
"error",
"{",
"// Get the bucketName",
"bucketName",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"bucketName",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n"... | // Describe deploys the given service | [
"Describe",
"deploys",
"the",
"given",
"service"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/magefile/actions.go#L110-L117 |
1,214 | mweagle/Sparta | util.go | describeInfoValue | func describeInfoValue(dynamicValue interface{}) string {
switch typedArn := dynamicValue.(type) {
case string:
return typedArn
case gocf.Stringable:
data, dataErr := json.Marshal(typedArn)
if dataErr != nil {
data = []byte(fmt.Sprintf("%v", typedArn))
}
return string(data)
default:
panic(fmt.Sprintf... | go | func describeInfoValue(dynamicValue interface{}) string {
switch typedArn := dynamicValue.(type) {
case string:
return typedArn
case gocf.Stringable:
data, dataErr := json.Marshal(typedArn)
if dataErr != nil {
data = []byte(fmt.Sprintf("%v", typedArn))
}
return string(data)
default:
panic(fmt.Sprintf... | [
"func",
"describeInfoValue",
"(",
"dynamicValue",
"interface",
"{",
"}",
")",
"string",
"{",
"switch",
"typedArn",
":=",
"dynamicValue",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"return",
"typedArn",
"\n",
"case",
"gocf",
".",
"Stringable",
":",
... | // describeInfoValue is a utility function that accepts
// some type of dynamic gocf value and transforms it into
// something that is `describe` output compatible | [
"describeInfoValue",
"is",
"a",
"utility",
"function",
"that",
"accepts",
"some",
"type",
"of",
"dynamic",
"gocf",
"value",
"and",
"transforms",
"it",
"into",
"something",
"that",
"is",
"describe",
"output",
"compatible"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/util.go#L38-L51 |
1,215 | mweagle/Sparta | util.go | relativePath | func relativePath(logPath string) string {
cwd, cwdErr := os.Getwd()
if cwdErr == nil {
relPath := strings.TrimPrefix(logPath, cwd)
if relPath != logPath {
logPath = fmt.Sprintf(".%s", relPath)
}
}
return logPath
} | go | func relativePath(logPath string) string {
cwd, cwdErr := os.Getwd()
if cwdErr == nil {
relPath := strings.TrimPrefix(logPath, cwd)
if relPath != logPath {
logPath = fmt.Sprintf(".%s", relPath)
}
}
return logPath
} | [
"func",
"relativePath",
"(",
"logPath",
"string",
")",
"string",
"{",
"cwd",
",",
"cwdErr",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"if",
"cwdErr",
"==",
"nil",
"{",
"relPath",
":=",
"strings",
".",
"TrimPrefix",
"(",
"logPath",
",",
"cwd",
")",
"\... | // relativePath returns the relative path of logPath if it's relative to the current
// workint directory | [
"relativePath",
"returns",
"the",
"relative",
"path",
"of",
"logPath",
"if",
"it",
"s",
"relative",
"to",
"the",
"current",
"workint",
"directory"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/util.go#L55-L64 |
1,216 | mweagle/Sparta | util.go | Run | func (t *workTask) Run(wg *sync.WaitGroup) {
t.Result = t.task()
wg.Done()
} | go | func (t *workTask) Run(wg *sync.WaitGroup) {
t.Result = t.task()
wg.Done()
} | [
"func",
"(",
"t",
"*",
"workTask",
")",
"Run",
"(",
"wg",
"*",
"sync",
".",
"WaitGroup",
")",
"{",
"t",
".",
"Result",
"=",
"t",
".",
"task",
"(",
")",
"\n",
"wg",
".",
"Done",
"(",
")",
"\n",
"}"
] | // Run runs a Task and does appropriate accounting via a given sync.WorkGroup. | [
"Run",
"runs",
"a",
"Task",
"and",
"does",
"appropriate",
"accounting",
"via",
"a",
"given",
"sync",
".",
"WorkGroup",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/util.go#L144-L147 |
1,217 | mweagle/Sparta | util.go | newWorkerPool | func newWorkerPool(tasks []*workTask, concurrency int) *workerPool {
return &workerPool{
Tasks: tasks,
concurrency: concurrency,
tasksChan: make(chan *workTask),
}
} | go | func newWorkerPool(tasks []*workTask, concurrency int) *workerPool {
return &workerPool{
Tasks: tasks,
concurrency: concurrency,
tasksChan: make(chan *workTask),
}
} | [
"func",
"newWorkerPool",
"(",
"tasks",
"[",
"]",
"*",
"workTask",
",",
"concurrency",
"int",
")",
"*",
"workerPool",
"{",
"return",
"&",
"workerPool",
"{",
"Tasks",
":",
"tasks",
",",
"concurrency",
":",
"concurrency",
",",
"tasksChan",
":",
"make",
"(",
... | // newWorkerPool initializes a new pool with the given tasks and at the given
// concurrency. | [
"newWorkerPool",
"initializes",
"a",
"new",
"pool",
"with",
"the",
"given",
"tasks",
"and",
"at",
"the",
"given",
"concurrency",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/util.go#L166-L172 |
1,218 | mweagle/Sparta | util.go | workResults | func (p *workerPool) workResults() ([]interface{}, []error) {
result := []interface{}{}
errors := []error{}
for _, eachResult := range p.Tasks {
if eachResult.Result.Error() != nil {
errors = append(errors, eachResult.Result.Error())
} else {
result = append(result, eachResult.Result.Result())
}
}
ret... | go | func (p *workerPool) workResults() ([]interface{}, []error) {
result := []interface{}{}
errors := []error{}
for _, eachResult := range p.Tasks {
if eachResult.Result.Error() != nil {
errors = append(errors, eachResult.Result.Error())
} else {
result = append(result, eachResult.Result.Result())
}
}
ret... | [
"func",
"(",
"p",
"*",
"workerPool",
")",
"workResults",
"(",
")",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"[",
"]",
"error",
")",
"{",
"result",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"errors",
":=",
"[",
"]",
"error",
"{",
... | // HasErrors indicates whether there were any errors from tasks run. Its result
// is only meaningful after Run has been called. | [
"HasErrors",
"indicates",
"whether",
"there",
"were",
"any",
"errors",
"from",
"tasks",
"run",
".",
"Its",
"result",
"is",
"only",
"meaningful",
"after",
"Run",
"has",
"been",
"called",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/util.go#L176-L188 |
1,219 | mweagle/Sparta | util.go | Run | func (p *workerPool) Run() ([]interface{}, []error) {
for i := 0; i < p.concurrency; i++ {
go p.work()
}
p.wg.Add(len(p.Tasks))
for _, task := range p.Tasks {
p.tasksChan <- task
}
// all workers return
close(p.tasksChan)
p.wg.Wait()
return p.workResults()
} | go | func (p *workerPool) Run() ([]interface{}, []error) {
for i := 0; i < p.concurrency; i++ {
go p.work()
}
p.wg.Add(len(p.Tasks))
for _, task := range p.Tasks {
p.tasksChan <- task
}
// all workers return
close(p.tasksChan)
p.wg.Wait()
return p.workResults()
} | [
"func",
"(",
"p",
"*",
"workerPool",
")",
"Run",
"(",
")",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"[",
"]",
"error",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"p",
".",
"concurrency",
";",
"i",
"++",
"{",
"go",
"p",
".",
"work",
... | // Run runs all work within the pool and blocks until it's finished. | [
"Run",
"runs",
"all",
"work",
"within",
"the",
"pool",
"and",
"blocks",
"until",
"it",
"s",
"finished",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/util.go#L191-L206 |
1,220 | mweagle/Sparta | util.go | work | func (p *workerPool) work() {
for task := range p.tasksChan {
task.Run(&p.wg)
}
} | go | func (p *workerPool) work() {
for task := range p.tasksChan {
task.Run(&p.wg)
}
} | [
"func",
"(",
"p",
"*",
"workerPool",
")",
"work",
"(",
")",
"{",
"for",
"task",
":=",
"range",
"p",
".",
"tasksChan",
"{",
"task",
".",
"Run",
"(",
"&",
"p",
".",
"wg",
")",
"\n",
"}",
"\n",
"}"
] | // The work loop for any single goroutine. | [
"The",
"work",
"loop",
"for",
"any",
"single",
"goroutine",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/util.go#L209-L213 |
1,221 | mweagle/Sparta | archetype/cloudwatch.go | OnCloudWatchMessage | func (reactorFunc CloudWatchReactorFunc) OnCloudWatchMessage(ctx context.Context,
cwLogs awsLambdaEvents.CloudwatchLogsEvent) (interface{}, error) {
return reactorFunc(ctx, cwLogs)
} | go | func (reactorFunc CloudWatchReactorFunc) OnCloudWatchMessage(ctx context.Context,
cwLogs awsLambdaEvents.CloudwatchLogsEvent) (interface{}, error) {
return reactorFunc(ctx, cwLogs)
} | [
"func",
"(",
"reactorFunc",
"CloudWatchReactorFunc",
")",
"OnCloudWatchMessage",
"(",
"ctx",
"context",
".",
"Context",
",",
"cwLogs",
"awsLambdaEvents",
".",
"CloudwatchLogsEvent",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"reactorFunc",
... | // OnCloudWatchMessage satisfies the CloudWatchReactor interface | [
"OnCloudWatchMessage",
"satisfies",
"the",
"CloudWatchReactor",
"interface"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/cloudwatch.go#L28-L31 |
1,222 | mweagle/Sparta | archetype/cloudwatch.go | NewCloudWatchReactor | func NewCloudWatchReactor(reactor CloudWatchReactor,
subscriptions map[string]sparta.CloudWatchEventsRule,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
if len(subscriptions) <= 0 {
return nil, errors.Errorf("CloudWatchLogs subscription map must not be empty")
}
reactor... | go | func NewCloudWatchReactor(reactor CloudWatchReactor,
subscriptions map[string]sparta.CloudWatchEventsRule,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
if len(subscriptions) <= 0 {
return nil, errors.Errorf("CloudWatchLogs subscription map must not be empty")
}
reactor... | [
"func",
"NewCloudWatchReactor",
"(",
"reactor",
"CloudWatchReactor",
",",
"subscriptions",
"map",
"[",
"string",
"]",
"sparta",
".",
"CloudWatchEventsRule",
",",
"additionalLambdaPermissions",
"[",
"]",
"sparta",
".",
"IAMRolePrivilege",
")",
"(",
"*",
"sparta",
"."... | // NewCloudWatchReactor returns a CloudWatch logs reactor lambda function | [
"NewCloudWatchReactor",
"returns",
"a",
"CloudWatch",
"logs",
"reactor",
"lambda",
"function"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/cloudwatch.go#L81-L108 |
1,223 | mweagle/Sparta | sparta.go | Register | func (lei *LambdaEventInterceptors) Register(provider LambdaInterceptorProvider) *LambdaEventInterceptors {
namedInterceptor := func(interceptor Interceptor) *NamedInterceptor {
return &NamedInterceptor{
Name: fmt.Sprintf("%T", provider),
Interceptor: interceptor,
}
}
if lei.Begin == nil {
lei.Beg... | go | func (lei *LambdaEventInterceptors) Register(provider LambdaInterceptorProvider) *LambdaEventInterceptors {
namedInterceptor := func(interceptor Interceptor) *NamedInterceptor {
return &NamedInterceptor{
Name: fmt.Sprintf("%T", provider),
Interceptor: interceptor,
}
}
if lei.Begin == nil {
lei.Beg... | [
"func",
"(",
"lei",
"*",
"LambdaEventInterceptors",
")",
"Register",
"(",
"provider",
"LambdaInterceptorProvider",
")",
"*",
"LambdaEventInterceptors",
"{",
"namedInterceptor",
":=",
"func",
"(",
"interceptor",
"Interceptor",
")",
"*",
"NamedInterceptor",
"{",
"return... | // Register is a convenience function to register a struct that
// implements the LambdaInterceptorProvider interface | [
"Register",
"is",
"a",
"convenience",
"function",
"to",
"register",
"a",
"struct",
"that",
"implements",
"the",
"LambdaInterceptorProvider",
"interface"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/sparta.go#L621-L658 |
1,224 | mweagle/Sparta | sparta.go | lambdaFunctionName | func (info *LambdaAWSInfo) lambdaFunctionName() string {
if info.cachedLambdaFunctionName != "" {
return info.cachedLambdaFunctionName
}
var lambdaFuncName string
if info.Options != nil &&
info.Options.SpartaOptions != nil &&
info.Options.SpartaOptions.Name != "" {
lambdaFuncName = info.Options.SpartaOptio... | go | func (info *LambdaAWSInfo) lambdaFunctionName() string {
if info.cachedLambdaFunctionName != "" {
return info.cachedLambdaFunctionName
}
var lambdaFuncName string
if info.Options != nil &&
info.Options.SpartaOptions != nil &&
info.Options.SpartaOptions.Name != "" {
lambdaFuncName = info.Options.SpartaOptio... | [
"func",
"(",
"info",
"*",
"LambdaAWSInfo",
")",
"lambdaFunctionName",
"(",
")",
"string",
"{",
"if",
"info",
".",
"cachedLambdaFunctionName",
"!=",
"\"",
"\"",
"{",
"return",
"info",
".",
"cachedLambdaFunctionName",
"\n",
"}",
"\n",
"var",
"lambdaFuncName",
"s... | // lambdaFunctionName returns the internal
// function name for lambda export binding | [
"lambdaFunctionName",
"returns",
"the",
"internal",
"function",
"name",
"for",
"lambda",
"export",
"binding"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/sparta.go#L729-L787 |
1,225 | mweagle/Sparta | sparta.go | LogicalResourceName | func (info *LambdaAWSInfo) LogicalResourceName() string {
// Per http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html,
// we can only use alphanumeric, so we'll take the sanitized name and
// remove all underscores
// Prefer the user-supplied stable name to the internal one... | go | func (info *LambdaAWSInfo) LogicalResourceName() string {
// Per http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html,
// we can only use alphanumeric, so we'll take the sanitized name and
// remove all underscores
// Prefer the user-supplied stable name to the internal one... | [
"func",
"(",
"info",
"*",
"LambdaAWSInfo",
")",
"LogicalResourceName",
"(",
")",
"string",
"{",
"// Per http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html,",
"// we can only use alphanumeric, so we'll take the sanitized name and",
"// remove all ... | // LogicalResourceName returns the stable, content-addressable logical
// name for this LambdaAWSInfo value. This is the CloudFormation
// resource name | [
"LogicalResourceName",
"returns",
"the",
"stable",
"content",
"-",
"addressable",
"logical",
"name",
"for",
"this",
"LambdaAWSInfo",
"value",
".",
"This",
"is",
"the",
"CloudFormation",
"resource",
"name"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/sparta.go#L837-L846 |
1,226 | mweagle/Sparta | sparta.go | LambdaName | func LambdaName(handlerSymbol interface{}) string {
funcPtr := runtime.FuncForPC(reflect.ValueOf(handlerSymbol).Pointer())
return funcPtr.Name()
} | go | func LambdaName(handlerSymbol interface{}) string {
funcPtr := runtime.FuncForPC(reflect.ValueOf(handlerSymbol).Pointer())
return funcPtr.Name()
} | [
"func",
"LambdaName",
"(",
"handlerSymbol",
"interface",
"{",
"}",
")",
"string",
"{",
"funcPtr",
":=",
"runtime",
".",
"FuncForPC",
"(",
"reflect",
".",
"ValueOf",
"(",
"handlerSymbol",
")",
".",
"Pointer",
"(",
")",
")",
"\n",
"return",
"funcPtr",
".",
... | // LambdaName returns the Go-reflection discovered name for a given
// function | [
"LambdaName",
"returns",
"the",
"Go",
"-",
"reflection",
"discovered",
"name",
"for",
"a",
"given",
"function"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/sparta.go#L1193-L1196 |
1,227 | mweagle/Sparta | lambda_permissions.go | BucketArn | func (storage *MessageBodyStorage) BucketArn() *gocf.StringExpr {
return gocf.Join("",
gocf.String("arn:aws:s3:::"),
storage.bucketNameExpr)
} | go | func (storage *MessageBodyStorage) BucketArn() *gocf.StringExpr {
return gocf.Join("",
gocf.String("arn:aws:s3:::"),
storage.bucketNameExpr)
} | [
"func",
"(",
"storage",
"*",
"MessageBodyStorage",
")",
"BucketArn",
"(",
")",
"*",
"gocf",
".",
"StringExpr",
"{",
"return",
"gocf",
".",
"Join",
"(",
"\"",
"\"",
",",
"gocf",
".",
"String",
"(",
"\"",
"\"",
")",
",",
"storage",
".",
"bucketNameExpr",... | // BucketArn returns an Arn value that can be used as an
// lambdaFn.RoleDefinition.Privileges `Resource` value. | [
"BucketArn",
"returns",
"an",
"Arn",
"value",
"that",
"can",
"be",
"used",
"as",
"an",
"lambdaFn",
".",
"RoleDefinition",
".",
"Privileges",
"Resource",
"value",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/lambda_permissions.go#L385-L389 |
1,228 | mweagle/Sparta | lambda_permissions.go | NewMessageBodyStorageResource | func (perm *SESPermission) NewMessageBodyStorageResource(bucketLogicalName string) (*MessageBodyStorage, error) {
if len(bucketLogicalName) <= 0 {
return nil, errors.New("NewMessageBodyStorageResource requires a unique, non-empty `bucketLogicalName` parameter ")
}
store := &MessageBodyStorage{
logicalBucketName:... | go | func (perm *SESPermission) NewMessageBodyStorageResource(bucketLogicalName string) (*MessageBodyStorage, error) {
if len(bucketLogicalName) <= 0 {
return nil, errors.New("NewMessageBodyStorageResource requires a unique, non-empty `bucketLogicalName` parameter ")
}
store := &MessageBodyStorage{
logicalBucketName:... | [
"func",
"(",
"perm",
"*",
"SESPermission",
")",
"NewMessageBodyStorageResource",
"(",
"bucketLogicalName",
"string",
")",
"(",
"*",
"MessageBodyStorage",
",",
"error",
")",
"{",
"if",
"len",
"(",
"bucketLogicalName",
")",
"<=",
"0",
"{",
"return",
"nil",
",",
... | // NewMessageBodyStorageResource provisions a new S3 bucket to store message body
// content. | [
"NewMessageBodyStorageResource",
"provisions",
"a",
"new",
"S3",
"bucket",
"to",
"store",
"message",
"body",
"content",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/lambda_permissions.go#L578-L588 |
1,229 | mweagle/Sparta | lambda_permissions.go | MarshalJSON | func (rule CloudWatchEventsRule) MarshalJSON() ([]byte, error) {
ruleJSON := map[string]interface{}{}
if rule.Description != "" {
ruleJSON["Description"] = rule.Description
}
if nil != rule.EventPattern {
eventPatternString, err := json.Marshal(rule.EventPattern)
if nil != err {
return nil, err
}
rule... | go | func (rule CloudWatchEventsRule) MarshalJSON() ([]byte, error) {
ruleJSON := map[string]interface{}{}
if rule.Description != "" {
ruleJSON["Description"] = rule.Description
}
if nil != rule.EventPattern {
eventPatternString, err := json.Marshal(rule.EventPattern)
if nil != err {
return nil, err
}
rule... | [
"func",
"(",
"rule",
"CloudWatchEventsRule",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"ruleJSON",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n\n",
"if",
"rule",
".",
"Description",
"!=",
"\... | // MarshalJSON customizes the JSON representation used when serializing to the
// CloudFormation template representation. | [
"MarshalJSON",
"customizes",
"the",
"JSON",
"representation",
"used",
"when",
"serializing",
"to",
"the",
"CloudFormation",
"template",
"representation",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/lambda_permissions.go#L757-L777 |
1,230 | mweagle/Sparta | aws/apigateway/response.go | Error | func (apigError *Error) Error() string {
bytes, bytesErr := json.Marshal(apigError)
if bytesErr != nil {
bytes = []byte(http.StatusText(http.StatusInternalServerError))
}
return string(bytes)
} | go | func (apigError *Error) Error() string {
bytes, bytesErr := json.Marshal(apigError)
if bytesErr != nil {
bytes = []byte(http.StatusText(http.StatusInternalServerError))
}
return string(bytes)
} | [
"func",
"(",
"apigError",
"*",
"Error",
")",
"Error",
"(",
")",
"string",
"{",
"bytes",
",",
"bytesErr",
":=",
"json",
".",
"Marshal",
"(",
"apigError",
")",
"\n",
"if",
"bytesErr",
"!=",
"nil",
"{",
"bytes",
"=",
"[",
"]",
"byte",
"(",
"http",
"."... | // Error returns the JSONified version of this error which will
// trigger the appropriate integration mapping. | [
"Error",
"returns",
"the",
"JSONified",
"version",
"of",
"this",
"error",
"which",
"will",
"trigger",
"the",
"appropriate",
"integration",
"mapping",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/apigateway/response.go#L21-L27 |
1,231 | mweagle/Sparta | aws/apigateway/response.go | NewErrorResponse | func NewErrorResponse(statusCode int, messages ...interface{}) *Error {
additionalMessages := make([]string, len(messages))
for eachIndex, eachMessage := range messages {
switch typedValue := eachMessage.(type) {
case error:
additionalMessages[eachIndex] = typedValue.Error()
default:
additionalMessages[e... | go | func NewErrorResponse(statusCode int, messages ...interface{}) *Error {
additionalMessages := make([]string, len(messages))
for eachIndex, eachMessage := range messages {
switch typedValue := eachMessage.(type) {
case error:
additionalMessages[eachIndex] = typedValue.Error()
default:
additionalMessages[e... | [
"func",
"NewErrorResponse",
"(",
"statusCode",
"int",
",",
"messages",
"...",
"interface",
"{",
"}",
")",
"*",
"Error",
"{",
"additionalMessages",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"messages",
")",
")",
"\n",
"for",
"eachIndex",
","... | // NewErrorResponse returns a response that satisfies
// the regular expression used to determine integration mappings
// via the API Gateway. messages is a stringable type. Error interface
// instances will be properly typecast. | [
"NewErrorResponse",
"returns",
"a",
"response",
"that",
"satisfies",
"the",
"regular",
"expression",
"used",
"to",
"determine",
"integration",
"mappings",
"via",
"the",
"API",
"Gateway",
".",
"messages",
"is",
"a",
"stringable",
"type",
".",
"Error",
"interface",
... | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/apigateway/response.go#L33-L56 |
1,232 | mweagle/Sparta | aws/apigateway/response.go | MarshalJSON | func (resp *Response) MarshalJSON() ([]byte, error) {
canonicalResponse := canonicalResponse{
Code: resp.Code,
Body: resp.Body,
}
if len(resp.Headers) != 0 {
canonicalResponse.Headers = make(map[string]string)
for eachKey, eachValue := range resp.Headers {
canonicalResponse.Headers[strings.ToLower(eachKey... | go | func (resp *Response) MarshalJSON() ([]byte, error) {
canonicalResponse := canonicalResponse{
Code: resp.Code,
Body: resp.Body,
}
if len(resp.Headers) != 0 {
canonicalResponse.Headers = make(map[string]string)
for eachKey, eachValue := range resp.Headers {
canonicalResponse.Headers[strings.ToLower(eachKey... | [
"func",
"(",
"resp",
"*",
"Response",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"canonicalResponse",
":=",
"canonicalResponse",
"{",
"Code",
":",
"resp",
".",
"Code",
",",
"Body",
":",
"resp",
".",
"Body",
",",
"}",... | // MarshalJSON is a custom marshaller to ensure that the marshalled
// headers are always lowercase | [
"MarshalJSON",
"is",
"a",
"custom",
"marshaller",
"to",
"ensure",
"that",
"the",
"marshalled",
"headers",
"are",
"always",
"lowercase"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/apigateway/response.go#L79-L91 |
1,233 | mweagle/Sparta | aws/apigateway/response.go | NewResponse | func NewResponse(code int, body interface{}, headers ...map[string]string) *Response {
response := &Response{
Code: code,
Body: body,
}
if len(headers) != 0 {
response.Headers = make(map[string]string)
for _, eachHeaderMap := range headers {
for eachKey, eachValue := range eachHeaderMap {
response.Hea... | go | func NewResponse(code int, body interface{}, headers ...map[string]string) *Response {
response := &Response{
Code: code,
Body: body,
}
if len(headers) != 0 {
response.Headers = make(map[string]string)
for _, eachHeaderMap := range headers {
for eachKey, eachValue := range eachHeaderMap {
response.Hea... | [
"func",
"NewResponse",
"(",
"code",
"int",
",",
"body",
"interface",
"{",
"}",
",",
"headers",
"...",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"Response",
"{",
"response",
":=",
"&",
"Response",
"{",
"Code",
":",
"code",
",",
"Body",
":",
"body... | // NewResponse returns an API Gateway response object | [
"NewResponse",
"returns",
"an",
"API",
"Gateway",
"response",
"object"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/apigateway/response.go#L94-L108 |
1,234 | mweagle/Sparta | aws/step/dynamodb.go | NewDynamoDBGetItemState | func NewDynamoDBGetItemState(stateName string,
parameters DynamoDBGetItemParameters) *DynamoDBGetItemState {
dgis := &DynamoDBGetItemState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return dgis
} | go | func NewDynamoDBGetItemState(stateName string,
parameters DynamoDBGetItemParameters) *DynamoDBGetItemState {
dgis := &DynamoDBGetItemState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return dgis
} | [
"func",
"NewDynamoDBGetItemState",
"(",
"stateName",
"string",
",",
"parameters",
"DynamoDBGetItemParameters",
")",
"*",
"DynamoDBGetItemState",
"{",
"dgis",
":=",
"&",
"DynamoDBGetItemState",
"{",
"BaseTask",
":",
"BaseTask",
"{",
"baseInnerState",
":",
"baseInnerState... | // NewDynamoDBGetItemState returns an initialized DynamoDB GetItem state | [
"NewDynamoDBGetItemState",
"returns",
"an",
"initialized",
"DynamoDB",
"GetItem",
"state"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/dynamodb.go#L47-L60 |
1,235 | mweagle/Sparta | aws/step/dynamodb.go | NewDynamoDBPutItemState | func NewDynamoDBPutItemState(stateName string,
parameters DynamoDBPutItemParameters) *DynamoDBPutItemState {
dpis := &DynamoDBPutItemState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return dpis
} | go | func NewDynamoDBPutItemState(stateName string,
parameters DynamoDBPutItemParameters) *DynamoDBPutItemState {
dpis := &DynamoDBPutItemState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return dpis
} | [
"func",
"NewDynamoDBPutItemState",
"(",
"stateName",
"string",
",",
"parameters",
"DynamoDBPutItemParameters",
")",
"*",
"DynamoDBPutItemState",
"{",
"dpis",
":=",
"&",
"DynamoDBPutItemState",
"{",
"BaseTask",
":",
"BaseTask",
"{",
"baseInnerState",
":",
"baseInnerState... | // NewDynamoDBPutItemState returns an initialized DynamoDB PutItem state | [
"NewDynamoDBPutItemState",
"returns",
"an",
"initialized",
"DynamoDB",
"PutItem",
"state"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/dynamodb.go#L102-L115 |
1,236 | mweagle/Sparta | aws/accessor/interface.go | xrayInit | func xrayInit(awsClient *client.Client) {
if os.Getenv("AWS_XRAY_DAEMON_ADDRESS") != "" &&
os.Getenv("AWS_EXECUTION_ENV") != "" {
xray.AWS(awsClient)
}
} | go | func xrayInit(awsClient *client.Client) {
if os.Getenv("AWS_XRAY_DAEMON_ADDRESS") != "" &&
os.Getenv("AWS_EXECUTION_ENV") != "" {
xray.AWS(awsClient)
}
} | [
"func",
"xrayInit",
"(",
"awsClient",
"*",
"client",
".",
"Client",
")",
"{",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"!=",
"\"",
"\"",
"&&",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"!=",
"\"",
"\"",
"{",
"xray",
".",
"AWS",
"(",
... | // Conditionally attach XRay if it seems like the right thing to do | [
"Conditionally",
"attach",
"XRay",
"if",
"it",
"seems",
"like",
"the",
"right",
"thing",
"to",
"do"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/accessor/interface.go#L12-L17 |
1,237 | mweagle/Sparta | archetype/codecommit.go | OnCodeCommitEvent | func (reactorFunc CodeCommitReactorFunc) OnCodeCommitEvent(ctx context.Context,
codeCommitEvent awsLambdaEvents.CodeCommitEvent) (interface{}, error) {
return reactorFunc(ctx, codeCommitEvent)
} | go | func (reactorFunc CodeCommitReactorFunc) OnCodeCommitEvent(ctx context.Context,
codeCommitEvent awsLambdaEvents.CodeCommitEvent) (interface{}, error) {
return reactorFunc(ctx, codeCommitEvent)
} | [
"func",
"(",
"reactorFunc",
"CodeCommitReactorFunc",
")",
"OnCodeCommitEvent",
"(",
"ctx",
"context",
".",
"Context",
",",
"codeCommitEvent",
"awsLambdaEvents",
".",
"CodeCommitEvent",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"reactorFunc... | // OnCodeCommitEvent satisfies the CodeCommitReactor interface | [
"OnCodeCommitEvent",
"satisfies",
"the",
"CodeCommitReactor",
"interface"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/codecommit.go#L28-L31 |
1,238 | mweagle/Sparta | archetype/codecommit.go | NewCodeCommitReactor | func NewCodeCommitReactor(reactor CodeCommitReactor,
repositoryName gocf.Stringable,
branches []string,
events []string,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
reactorLambda := func(ctx context.Context, codeCommitEvent awsLambdaEvents.CodeCommitEvent) (interface{},... | go | func NewCodeCommitReactor(reactor CodeCommitReactor,
repositoryName gocf.Stringable,
branches []string,
events []string,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
reactorLambda := func(ctx context.Context, codeCommitEvent awsLambdaEvents.CodeCommitEvent) (interface{},... | [
"func",
"NewCodeCommitReactor",
"(",
"reactor",
"CodeCommitReactor",
",",
"repositoryName",
"gocf",
".",
"Stringable",
",",
"branches",
"[",
"]",
"string",
",",
"events",
"[",
"]",
"string",
",",
"additionalLambdaPermissions",
"[",
"]",
"sparta",
".",
"IAMRolePriv... | // NewCodeCommitReactor returns an SNS reactor lambda function | [
"NewCodeCommitReactor",
"returns",
"an",
"SNS",
"reactor",
"lambda",
"function"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/codecommit.go#L39-L68 |
1,239 | mweagle/Sparta | aws/accessor/s3.go | BucketPrivilege | func (svc *S3Accessor) BucketPrivilege(bucketPrivs ...string) sparta.IAMRolePrivilege {
return sparta.IAMRolePrivilege{
Actions: bucketPrivs,
Resource: spartaCF.S3ArnForBucket(gocf.Ref(svc.S3BucketResourceName)),
}
} | go | func (svc *S3Accessor) BucketPrivilege(bucketPrivs ...string) sparta.IAMRolePrivilege {
return sparta.IAMRolePrivilege{
Actions: bucketPrivs,
Resource: spartaCF.S3ArnForBucket(gocf.Ref(svc.S3BucketResourceName)),
}
} | [
"func",
"(",
"svc",
"*",
"S3Accessor",
")",
"BucketPrivilege",
"(",
"bucketPrivs",
"...",
"string",
")",
"sparta",
".",
"IAMRolePrivilege",
"{",
"return",
"sparta",
".",
"IAMRolePrivilege",
"{",
"Actions",
":",
"bucketPrivs",
",",
"Resource",
":",
"spartaCF",
... | // BucketPrivilege returns a privilege that targets the Bucket | [
"BucketPrivilege",
"returns",
"a",
"privilege",
"that",
"targets",
"the",
"Bucket"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/accessor/s3.go#L26-L31 |
1,240 | mweagle/Sparta | aws/accessor/s3.go | KeysPrivilege | func (svc *S3Accessor) KeysPrivilege(keyPrivileges ...string) sparta.IAMRolePrivilege {
return sparta.IAMRolePrivilege{
Actions: keyPrivileges,
Resource: spartaCF.S3AllKeysArnForBucket(gocf.Ref(svc.S3BucketResourceName)),
}
} | go | func (svc *S3Accessor) KeysPrivilege(keyPrivileges ...string) sparta.IAMRolePrivilege {
return sparta.IAMRolePrivilege{
Actions: keyPrivileges,
Resource: spartaCF.S3AllKeysArnForBucket(gocf.Ref(svc.S3BucketResourceName)),
}
} | [
"func",
"(",
"svc",
"*",
"S3Accessor",
")",
"KeysPrivilege",
"(",
"keyPrivileges",
"...",
"string",
")",
"sparta",
".",
"IAMRolePrivilege",
"{",
"return",
"sparta",
".",
"IAMRolePrivilege",
"{",
"Actions",
":",
"keyPrivileges",
",",
"Resource",
":",
"spartaCF",
... | // KeysPrivilege returns a privilege that targets the Bucket objects | [
"KeysPrivilege",
"returns",
"a",
"privilege",
"that",
"targets",
"the",
"Bucket",
"objects"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/accessor/s3.go#L34-L39 |
1,241 | mweagle/Sparta | execute_build.go | awsLambdaFunctionName | func awsLambdaFunctionName(internalFunctionName string) gocf.Stringable {
sanitizedName := awsLambdaInternalName(internalFunctionName)
// When we build, we return a gocf.Join that
// will use the stack name and the internal name. When we run, we're going
// to use the name discovered from the environment.
return g... | go | func awsLambdaFunctionName(internalFunctionName string) gocf.Stringable {
sanitizedName := awsLambdaInternalName(internalFunctionName)
// When we build, we return a gocf.Join that
// will use the stack name and the internal name. When we run, we're going
// to use the name discovered from the environment.
return g... | [
"func",
"awsLambdaFunctionName",
"(",
"internalFunctionName",
"string",
")",
"gocf",
".",
"Stringable",
"{",
"sanitizedName",
":=",
"awsLambdaInternalName",
"(",
"internalFunctionName",
")",
"\n",
"// When we build, we return a gocf.Join that",
"// will use the stack name and the... | // awsLambdaFunctionName returns the name of the function, which
// is set in the CloudFormation template that is published
// into the container as `AWS_LAMBDA_FUNCTION_NAME`. The function name
// is dependent on the CloudFormation stack name so that
// CodePipeline based builds can properly create unique FunctionNAm... | [
"awsLambdaFunctionName",
"returns",
"the",
"name",
"of",
"the",
"function",
"which",
"is",
"set",
"in",
"the",
"CloudFormation",
"template",
"that",
"is",
"published",
"into",
"the",
"container",
"as",
"AWS_LAMBDA_FUNCTION_NAME",
".",
"The",
"function",
"name",
"i... | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/execute_build.go#L31-L40 |
1,242 | mweagle/Sparta | archetype/dynamodb.go | OnDynamoEvent | func (reactorFunc DynamoDBReactorFunc) OnDynamoEvent(ctx context.Context,
dynamoEvent awsLambdaEvents.DynamoDBEvent) (interface{}, error) {
return reactorFunc(ctx, dynamoEvent)
} | go | func (reactorFunc DynamoDBReactorFunc) OnDynamoEvent(ctx context.Context,
dynamoEvent awsLambdaEvents.DynamoDBEvent) (interface{}, error) {
return reactorFunc(ctx, dynamoEvent)
} | [
"func",
"(",
"reactorFunc",
"DynamoDBReactorFunc",
")",
"OnDynamoEvent",
"(",
"ctx",
"context",
".",
"Context",
",",
"dynamoEvent",
"awsLambdaEvents",
".",
"DynamoDBEvent",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"reactorFunc",
"(",
... | // OnDynamoEvent satisfies the DynamoDBReactor interface | [
"OnDynamoEvent",
"satisfies",
"the",
"DynamoDBReactor",
"interface"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/dynamodb.go#L29-L32 |
1,243 | mweagle/Sparta | archetype/dynamodb.go | ReactorName | func (reactorFunc DynamoDBReactorFunc) ReactorName() string {
return runtime.FuncForPC(reflect.ValueOf(reactorFunc).Pointer()).Name()
} | go | func (reactorFunc DynamoDBReactorFunc) ReactorName() string {
return runtime.FuncForPC(reflect.ValueOf(reactorFunc).Pointer()).Name()
} | [
"func",
"(",
"reactorFunc",
"DynamoDBReactorFunc",
")",
"ReactorName",
"(",
")",
"string",
"{",
"return",
"runtime",
".",
"FuncForPC",
"(",
"reflect",
".",
"ValueOf",
"(",
"reactorFunc",
")",
".",
"Pointer",
"(",
")",
")",
".",
"Name",
"(",
")",
"\n",
"}... | // ReactorName provides the name of the reactor func | [
"ReactorName",
"provides",
"the",
"name",
"of",
"the",
"reactor",
"func"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/dynamodb.go#L35-L37 |
1,244 | mweagle/Sparta | archetype/dynamodb.go | NewDynamoDBReactor | func NewDynamoDBReactor(reactor DynamoDBReactor,
dynamoDBARN gocf.Stringable,
startingPosition string,
batchSize int64,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
reactorLambda := func(ctx context.Context, dynamoEvent awsLambdaEvents.DynamoDBEvent) (interface{}, error)... | go | func NewDynamoDBReactor(reactor DynamoDBReactor,
dynamoDBARN gocf.Stringable,
startingPosition string,
batchSize int64,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
reactorLambda := func(ctx context.Context, dynamoEvent awsLambdaEvents.DynamoDBEvent) (interface{}, error)... | [
"func",
"NewDynamoDBReactor",
"(",
"reactor",
"DynamoDBReactor",
",",
"dynamoDBARN",
"gocf",
".",
"Stringable",
",",
"startingPosition",
"string",
",",
"batchSize",
"int64",
",",
"additionalLambdaPermissions",
"[",
"]",
"sparta",
".",
"IAMRolePrivilege",
")",
"(",
"... | // NewDynamoDBReactor returns an Kinesis reactor lambda function | [
"NewDynamoDBReactor",
"returns",
"an",
"Kinesis",
"reactor",
"lambda",
"function"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/dynamodb.go#L40-L67 |
1,245 | mweagle/Sparta | aws/step/batch.go | NewBatchTaskState | func NewBatchTaskState(stateName string,
parameters BatchTaskParameters) *BatchTaskState {
sns := &BatchTaskState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return sns
} | go | func NewBatchTaskState(stateName string,
parameters BatchTaskParameters) *BatchTaskState {
sns := &BatchTaskState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return sns
} | [
"func",
"NewBatchTaskState",
"(",
"stateName",
"string",
",",
"parameters",
"BatchTaskParameters",
")",
"*",
"BatchTaskState",
"{",
"sns",
":=",
"&",
"BatchTaskState",
"{",
"BaseTask",
":",
"BaseTask",
"{",
"baseInnerState",
":",
"baseInnerState",
"{",
"name",
":"... | // NewBatchTaskState returns an initialized BatchTaskState | [
"NewBatchTaskState",
"returns",
"an",
"initialized",
"BatchTaskState"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/batch.go#L39-L52 |
1,246 | mweagle/Sparta | resource_references.go | resolveResourceRef | func resolveResourceRef(expr interface{}) (*resourceRef, error) {
// Is there any chance it's just a string?
typedString, typedStringOk := expr.(string)
if typedStringOk {
return &resourceRef{
RefType: resourceLiteral,
ResourceName: typedString,
}, nil
}
// Some type of intrinsic function?
marshal... | go | func resolveResourceRef(expr interface{}) (*resourceRef, error) {
// Is there any chance it's just a string?
typedString, typedStringOk := expr.(string)
if typedStringOk {
return &resourceRef{
RefType: resourceLiteral,
ResourceName: typedString,
}, nil
}
// Some type of intrinsic function?
marshal... | [
"func",
"resolveResourceRef",
"(",
"expr",
"interface",
"{",
"}",
")",
"(",
"*",
"resourceRef",
",",
"error",
")",
"{",
"// Is there any chance it's just a string?",
"typedString",
",",
"typedStringOk",
":=",
"expr",
".",
"(",
"string",
")",
"\n",
"if",
"typedSt... | // resolveResourceRef takes an interface representing a dynamic ARN
// and tries to determine the CloudFormation resource name it resolves to | [
"resolveResourceRef",
"takes",
"an",
"interface",
"representing",
"a",
"dynamic",
"ARN",
"and",
"tries",
"to",
"determine",
"the",
"CloudFormation",
"resource",
"name",
"it",
"resolves",
"to"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/resource_references.go#L38-L80 |
1,247 | mweagle/Sparta | resource_references.go | visitResolvedEventSourceMapping | func visitResolvedEventSourceMapping(visitor resolvedResourceVisitor,
lambdaAWSInfos []*LambdaAWSInfo,
template *gocf.Template,
logger *logrus.Logger) error {
//
// BEGIN
// Inline closure to wrap the visitor function so that we can provide
// specific error messages
visitEventSourceMappingRef := func(lambdaAW... | go | func visitResolvedEventSourceMapping(visitor resolvedResourceVisitor,
lambdaAWSInfos []*LambdaAWSInfo,
template *gocf.Template,
logger *logrus.Logger) error {
//
// BEGIN
// Inline closure to wrap the visitor function so that we can provide
// specific error messages
visitEventSourceMappingRef := func(lambdaAW... | [
"func",
"visitResolvedEventSourceMapping",
"(",
"visitor",
"resolvedResourceVisitor",
",",
"lambdaAWSInfos",
"[",
"]",
"*",
"LambdaAWSInfo",
",",
"template",
"*",
"gocf",
".",
"Template",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"error",
"{",
"//",
"// ... | // visitResolvedEventSourceMapping is a utility function that visits all the EventSourceMapping
// entries for the given lambdaAWSInfo struct | [
"visitResolvedEventSourceMapping",
"is",
"a",
"utility",
"function",
"that",
"visits",
"all",
"the",
"EventSourceMapping",
"entries",
"for",
"the",
"given",
"lambdaAWSInfo",
"struct"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/resource_references.go#L110-L171 |
1,248 | mweagle/Sparta | provision_annotations.go | eventSourceMappingPoliciesForResource | func eventSourceMappingPoliciesForResource(resource *resourceRef,
template *gocf.Template,
logger *logrus.Logger) ([]spartaIAM.PolicyStatement, error) {
policyStatements := []spartaIAM.PolicyStatement{}
if isResolvedResourceType(resource, template, ":dynamodb:", &gocf.DynamoDBTable{}) {
policyStatements = appen... | go | func eventSourceMappingPoliciesForResource(resource *resourceRef,
template *gocf.Template,
logger *logrus.Logger) ([]spartaIAM.PolicyStatement, error) {
policyStatements := []spartaIAM.PolicyStatement{}
if isResolvedResourceType(resource, template, ":dynamodb:", &gocf.DynamoDBTable{}) {
policyStatements = appen... | [
"func",
"eventSourceMappingPoliciesForResource",
"(",
"resource",
"*",
"resourceRef",
",",
"template",
"*",
"gocf",
".",
"Template",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"(",
"[",
"]",
"spartaIAM",
".",
"PolicyStatement",
",",
"error",
")",
"{",
... | // eventSourceMappingPoliciesForResource returns the IAM specific privileges for each
// type of supported AWS Lambda EventSourceMapping | [
"eventSourceMappingPoliciesForResource",
"returns",
"the",
"IAM",
"specific",
"privileges",
"for",
"each",
"type",
"of",
"supported",
"AWS",
"Lambda",
"EventSourceMapping"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/provision_annotations.go#L18-L36 |
1,249 | mweagle/Sparta | aws/step/sns.go | NewSNSTaskState | func NewSNSTaskState(stateName string,
parameters SNSTaskParameters) *SNSTaskState {
sns := &SNSTaskState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return sns
} | go | func NewSNSTaskState(stateName string,
parameters SNSTaskParameters) *SNSTaskState {
sns := &SNSTaskState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return sns
} | [
"func",
"NewSNSTaskState",
"(",
"stateName",
"string",
",",
"parameters",
"SNSTaskParameters",
")",
"*",
"SNSTaskState",
"{",
"sns",
":=",
"&",
"SNSTaskState",
"{",
"BaseTask",
":",
"BaseTask",
"{",
"baseInnerState",
":",
"baseInnerState",
"{",
"name",
":",
"sta... | // NewSNSTaskState returns an initialized SNSTaskState | [
"NewSNSTaskState",
"returns",
"an",
"initialized",
"SNSTaskState"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/sns.go#L37-L50 |
1,250 | mweagle/Sparta | decorator/outputs.go | PublishRefOutputDecorator | func PublishRefOutputDecorator(keyName string, description string) sparta.TemplateDecoratorHookFunc {
attrDecorator := func(serviceName string,
lambdaResourceName string,
lambdaResource gocf.LambdaFunction,
resourceMetadata map[string]interface{},
S3Bucket string,
S3Key string,
buildID string,
template *... | go | func PublishRefOutputDecorator(keyName string, description string) sparta.TemplateDecoratorHookFunc {
attrDecorator := func(serviceName string,
lambdaResourceName string,
lambdaResource gocf.LambdaFunction,
resourceMetadata map[string]interface{},
S3Bucket string,
S3Key string,
buildID string,
template *... | [
"func",
"PublishRefOutputDecorator",
"(",
"keyName",
"string",
",",
"description",
"string",
")",
"sparta",
".",
"TemplateDecoratorHookFunc",
"{",
"attrDecorator",
":=",
"func",
"(",
"serviceName",
"string",
",",
"lambdaResourceName",
"string",
",",
"lambdaResource",
... | // PublishRefOutputDecorator returns an TemplateDecoratorHookFunc
// that publishes the Ref value for a given lambda | [
"PublishRefOutputDecorator",
"returns",
"an",
"TemplateDecoratorHookFunc",
"that",
"publishes",
"the",
"Ref",
"value",
"for",
"a",
"given",
"lambda"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/decorator/outputs.go#L81-L102 |
1,251 | mweagle/Sparta | aws/session.go | NewSessionWithConfig | func NewSessionWithConfig(awsConfig *aws.Config, logger *logrus.Logger) *session.Session {
return NewSessionWithConfigLevel(awsConfig, aws.LogDebugWithRequestErrors, logger)
} | go | func NewSessionWithConfig(awsConfig *aws.Config, logger *logrus.Logger) *session.Session {
return NewSessionWithConfigLevel(awsConfig, aws.LogDebugWithRequestErrors, logger)
} | [
"func",
"NewSessionWithConfig",
"(",
"awsConfig",
"*",
"aws",
".",
"Config",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"*",
"session",
".",
"Session",
"{",
"return",
"NewSessionWithConfigLevel",
"(",
"awsConfig",
",",
"aws",
".",
"LogDebugWithRequestErro... | // NewSessionWithConfig returns an awsSession that includes the user supplied
// configuration information | [
"NewSessionWithConfig",
"returns",
"an",
"awsSession",
"that",
"includes",
"the",
"user",
"supplied",
"configuration",
"information"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/session.go#L21-L23 |
1,252 | mweagle/Sparta | aws/session.go | NewSession | func NewSession(logger *logrus.Logger) *session.Session {
return NewSessionWithLevel(aws.LogDebugWithRequestErrors, logger)
} | go | func NewSession(logger *logrus.Logger) *session.Session {
return NewSessionWithLevel(aws.LogDebugWithRequestErrors, logger)
} | [
"func",
"NewSession",
"(",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"*",
"session",
".",
"Session",
"{",
"return",
"NewSessionWithLevel",
"(",
"aws",
".",
"LogDebugWithRequestErrors",
",",
"logger",
")",
"\n",
"}"
] | // NewSession that attaches a debug level handler to all AWS requests from services
// sharing the session value. | [
"NewSession",
"that",
"attaches",
"a",
"debug",
"level",
"handler",
"to",
"all",
"AWS",
"requests",
"from",
"services",
"sharing",
"the",
"session",
"value",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/session.go#L27-L29 |
1,253 | mweagle/Sparta | decorator/s3_artifact_publisher.go | S3ArtifactPublisherDecorator | func S3ArtifactPublisherDecorator(bucket gocf.Stringable,
key gocf.Stringable,
data map[string]interface{}) sparta.ServiceDecoratorHookHandler {
// Setup the CF distro
artifactDecorator := func(context map[string]interface{},
serviceName string,
template *gocf.Template,
S3Bucket string,
S3Key string,
bui... | go | func S3ArtifactPublisherDecorator(bucket gocf.Stringable,
key gocf.Stringable,
data map[string]interface{}) sparta.ServiceDecoratorHookHandler {
// Setup the CF distro
artifactDecorator := func(context map[string]interface{},
serviceName string,
template *gocf.Template,
S3Bucket string,
S3Key string,
bui... | [
"func",
"S3ArtifactPublisherDecorator",
"(",
"bucket",
"gocf",
".",
"Stringable",
",",
"key",
"gocf",
".",
"Stringable",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"sparta",
".",
"ServiceDecoratorHookHandler",
"{",
"// Setup the CF distro"... | // S3ArtifactPublisherDecorator returns a ServiceDecoratorHookHandler
// function that publishes the given data to an S3 Bucket
// using the given bucket and key. | [
"S3ArtifactPublisherDecorator",
"returns",
"a",
"ServiceDecoratorHookHandler",
"function",
"that",
"publishes",
"the",
"given",
"data",
"to",
"an",
"S3",
"Bucket",
"using",
"the",
"given",
"bucket",
"and",
"key",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/decorator/s3_artifact_publisher.go#L16-L67 |
1,254 | mweagle/Sparta | sparta_main_build.go | NewLoggerWithFormatter | func NewLoggerWithFormatter(level string, formatter logrus.Formatter) (*logrus.Logger, error) {
logger := logrus.New()
// If there is an environment override, use that
envLogLevel := os.Getenv(envVarLogLevel)
if envLogLevel != "" {
level = envLogLevel
}
logLevel, err := logrus.ParseLevel(level)
if err != nil ... | go | func NewLoggerWithFormatter(level string, formatter logrus.Formatter) (*logrus.Logger, error) {
logger := logrus.New()
// If there is an environment override, use that
envLogLevel := os.Getenv(envVarLogLevel)
if envLogLevel != "" {
level = envLogLevel
}
logLevel, err := logrus.ParseLevel(level)
if err != nil ... | [
"func",
"NewLoggerWithFormatter",
"(",
"level",
"string",
",",
"formatter",
"logrus",
".",
"Formatter",
")",
"(",
"*",
"logrus",
".",
"Logger",
",",
"error",
")",
"{",
"logger",
":=",
"logrus",
".",
"New",
"(",
")",
"\n",
"// If there is an environment overrid... | // NewLoggerWithFormatter returns a logger with the given formatter. If formatter
// is nil, a TTY-aware formatter is used | [
"NewLoggerWithFormatter",
"returns",
"a",
"logger",
"with",
"the",
"given",
"formatter",
".",
"If",
"formatter",
"is",
"nil",
"a",
"TTY",
"-",
"aware",
"formatter",
"is",
"used"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/sparta_main_build.go#L40-L59 |
1,255 | mweagle/Sparta | delete.go | Delete | func Delete(serviceName string, logger *logrus.Logger) error {
session := spartaAWS.NewSession(logger)
awsCloudFormation := cloudformation.New(session)
exists, err := spartaCF.StackExists(serviceName, session, logger)
if nil != err {
return err
}
logger.WithFields(logrus.Fields{
"Exists": exists,
"Name": ... | go | func Delete(serviceName string, logger *logrus.Logger) error {
session := spartaAWS.NewSession(logger)
awsCloudFormation := cloudformation.New(session)
exists, err := spartaCF.StackExists(serviceName, session, logger)
if nil != err {
return err
}
logger.WithFields(logrus.Fields{
"Exists": exists,
"Name": ... | [
"func",
"Delete",
"(",
"serviceName",
"string",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"error",
"{",
"session",
":=",
"spartaAWS",
".",
"NewSession",
"(",
"logger",
")",
"\n",
"awsCloudFormation",
":=",
"cloudformation",
".",
"New",
"(",
"session"... | // Delete ensures that the provided serviceName is deleted.
// Failing to delete a non-existent service is considered a success. | [
"Delete",
"ensures",
"that",
"the",
"provided",
"serviceName",
"is",
"deleted",
".",
"Failing",
"to",
"delete",
"a",
"non",
"-",
"existent",
"service",
"is",
"considered",
"a",
"success",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/delete.go#L15-L43 |
1,256 | mweagle/Sparta | archetype/kinesis.go | OnKinesisMessage | func (reactorFunc KinesisReactorFunc) OnKinesisMessage(ctx context.Context,
kinesisEvent awsLambdaEvents.KinesisEvent) (interface{}, error) {
return reactorFunc(ctx, kinesisEvent)
} | go | func (reactorFunc KinesisReactorFunc) OnKinesisMessage(ctx context.Context,
kinesisEvent awsLambdaEvents.KinesisEvent) (interface{}, error) {
return reactorFunc(ctx, kinesisEvent)
} | [
"func",
"(",
"reactorFunc",
"KinesisReactorFunc",
")",
"OnKinesisMessage",
"(",
"ctx",
"context",
".",
"Context",
",",
"kinesisEvent",
"awsLambdaEvents",
".",
"KinesisEvent",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"reactorFunc",
"(",
... | // OnKinesisMessage satisfies the KinesisReactor interface | [
"OnKinesisMessage",
"satisfies",
"the",
"KinesisReactor",
"interface"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/kinesis.go#L29-L32 |
1,257 | mweagle/Sparta | archetype/kinesis.go | NewKinesisReactor | func NewKinesisReactor(reactor KinesisReactor,
kinesisStream gocf.Stringable,
startingPosition string,
batchSize int64,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
reactorLambda := func(ctx context.Context, kinesisEvent awsLambdaEvents.KinesisEvent) (interface{}, error)... | go | func NewKinesisReactor(reactor KinesisReactor,
kinesisStream gocf.Stringable,
startingPosition string,
batchSize int64,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
reactorLambda := func(ctx context.Context, kinesisEvent awsLambdaEvents.KinesisEvent) (interface{}, error)... | [
"func",
"NewKinesisReactor",
"(",
"reactor",
"KinesisReactor",
",",
"kinesisStream",
"gocf",
".",
"Stringable",
",",
"startingPosition",
"string",
",",
"batchSize",
"int64",
",",
"additionalLambdaPermissions",
"[",
"]",
"sparta",
".",
"IAMRolePrivilege",
")",
"(",
"... | // NewKinesisReactor returns an Kinesis reactor lambda function | [
"NewKinesisReactor",
"returns",
"an",
"Kinesis",
"reactor",
"lambda",
"function"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/kinesis.go#L40-L67 |
1,258 | mweagle/Sparta | archetype/s3.go | OnS3Event | func (reactorFunc S3ReactorFunc) OnS3Event(ctx context.Context, event awsLambdaEvents.S3Event) (interface{}, error) {
return reactorFunc(ctx, event)
} | go | func (reactorFunc S3ReactorFunc) OnS3Event(ctx context.Context, event awsLambdaEvents.S3Event) (interface{}, error) {
return reactorFunc(ctx, event)
} | [
"func",
"(",
"reactorFunc",
"S3ReactorFunc",
")",
"OnS3Event",
"(",
"ctx",
"context",
".",
"Context",
",",
"event",
"awsLambdaEvents",
".",
"S3Event",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"reactorFunc",
"(",
"ctx",
",",
"event... | // OnS3Event satisfies the S3Reactor interface | [
"OnS3Event",
"satisfies",
"the",
"S3Reactor",
"interface"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/s3.go#L36-L38 |
1,259 | mweagle/Sparta | archetype/s3.go | s3NotificationPrefixBasedPermission | func s3NotificationPrefixBasedPermission(bucketName gocf.Stringable, keyPathPrefix string) sparta.S3Permission {
permission := sparta.S3Permission{
BasePermission: sparta.BasePermission{
SourceArn: bucketName.String(),
},
Events: []string{"s3:ObjectCreated:*",
"s3:ObjectRemoved:*"},
}
if keyPathPrefix ... | go | func s3NotificationPrefixBasedPermission(bucketName gocf.Stringable, keyPathPrefix string) sparta.S3Permission {
permission := sparta.S3Permission{
BasePermission: sparta.BasePermission{
SourceArn: bucketName.String(),
},
Events: []string{"s3:ObjectCreated:*",
"s3:ObjectRemoved:*"},
}
if keyPathPrefix ... | [
"func",
"s3NotificationPrefixBasedPermission",
"(",
"bucketName",
"gocf",
".",
"Stringable",
",",
"keyPathPrefix",
"string",
")",
"sparta",
".",
"S3Permission",
"{",
"permission",
":=",
"sparta",
".",
"S3Permission",
"{",
"BasePermission",
":",
"sparta",
".",
"BaseP... | // s3NotificationPrefixFilter is a DRY spec for setting up a notification configuration
// filter | [
"s3NotificationPrefixFilter",
"is",
"a",
"DRY",
"spec",
"for",
"setting",
"up",
"a",
"notification",
"configuration",
"filter"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/s3.go#L47-L68 |
1,260 | mweagle/Sparta | archetype/s3.go | NewS3Reactor | func NewS3Reactor(reactor S3Reactor, s3Bucket gocf.Stringable, additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
return NewS3ScopedReactor(reactor, s3Bucket, "", additionalLambdaPermissions)
} | go | func NewS3Reactor(reactor S3Reactor, s3Bucket gocf.Stringable, additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
return NewS3ScopedReactor(reactor, s3Bucket, "", additionalLambdaPermissions)
} | [
"func",
"NewS3Reactor",
"(",
"reactor",
"S3Reactor",
",",
"s3Bucket",
"gocf",
".",
"Stringable",
",",
"additionalLambdaPermissions",
"[",
"]",
"sparta",
".",
"IAMRolePrivilege",
")",
"(",
"*",
"sparta",
".",
"LambdaAWSInfo",
",",
"error",
")",
"{",
"return",
"... | // NewS3Reactor returns an S3 reactor lambda function | [
"NewS3Reactor",
"returns",
"an",
"S3",
"reactor",
"lambda",
"function"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/s3.go#L71-L73 |
1,261 | mweagle/Sparta | archetype/s3.go | NewS3ScopedReactor | func NewS3ScopedReactor(reactor S3Reactor,
s3Bucket gocf.Stringable,
keyPathPrefix string,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
reactorLambda := func(ctx context.Context, event awsLambdaEvents.S3Event) (interface{}, error) {
return reactor.OnS3Event(ctx, event)
... | go | func NewS3ScopedReactor(reactor S3Reactor,
s3Bucket gocf.Stringable,
keyPathPrefix string,
additionalLambdaPermissions []sparta.IAMRolePrivilege) (*sparta.LambdaAWSInfo, error) {
reactorLambda := func(ctx context.Context, event awsLambdaEvents.S3Event) (interface{}, error) {
return reactor.OnS3Event(ctx, event)
... | [
"func",
"NewS3ScopedReactor",
"(",
"reactor",
"S3Reactor",
",",
"s3Bucket",
"gocf",
".",
"Stringable",
",",
"keyPathPrefix",
"string",
",",
"additionalLambdaPermissions",
"[",
"]",
"sparta",
".",
"IAMRolePrivilege",
")",
"(",
"*",
"sparta",
".",
"LambdaAWSInfo",
"... | // NewS3ScopedReactor returns an S3 reactor lambda function scoped to the given S3 key prefix | [
"NewS3ScopedReactor",
"returns",
"an",
"S3",
"reactor",
"lambda",
"function",
"scoped",
"to",
"the",
"given",
"S3",
"key",
"prefix"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/archetype/s3.go#L76-L109 |
1,262 | mweagle/Sparta | aws/cloudformation/util.go | init | func init() {
cloudFormationStackTemplateMap = make(map[string]*gocf.Template)
rand.Seed(time.Now().Unix())
} | go | func init() {
cloudFormationStackTemplateMap = make(map[string]*gocf.Template)
rand.Seed(time.Now().Unix())
} | [
"func",
"init",
"(",
")",
"{",
"cloudFormationStackTemplateMap",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"gocf",
".",
"Template",
")",
"\n",
"rand",
".",
"Seed",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Unix",
"(",
")",
")",
"\n",
"}"
] | //var cacheLock sync.Mutex | [
"var",
"cacheLock",
"sync",
".",
"Mutex"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/util.go#L35-L38 |
1,263 | mweagle/Sparta | aws/cloudformation/util.go | StackEvents | func StackEvents(stackID string,
eventFilterLowerBoundInclusive time.Time,
awsSession *session.Session) ([]*cloudformation.StackEvent, error) {
cfService := cloudformation.New(awsSession)
var events []*cloudformation.StackEvent
nextToken := ""
for {
params := &cloudformation.DescribeStackEventsInput{
Stack... | go | func StackEvents(stackID string,
eventFilterLowerBoundInclusive time.Time,
awsSession *session.Session) ([]*cloudformation.StackEvent, error) {
cfService := cloudformation.New(awsSession)
var events []*cloudformation.StackEvent
nextToken := ""
for {
params := &cloudformation.DescribeStackEventsInput{
Stack... | [
"func",
"StackEvents",
"(",
"stackID",
"string",
",",
"eventFilterLowerBoundInclusive",
"time",
".",
"Time",
",",
"awsSession",
"*",
"session",
".",
"Session",
")",
"(",
"[",
"]",
"*",
"cloudformation",
".",
"StackEvent",
",",
"error",
")",
"{",
"cfService",
... | // StackEvents returns the slice of cloudformation.StackEvents for the given stackID or stackName | [
"StackEvents",
"returns",
"the",
"slice",
"of",
"cloudformation",
".",
"StackEvents",
"for",
"the",
"given",
"stackID",
"or",
"stackName"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/util.go#L484-L517 |
1,264 | mweagle/Sparta | aws/cloudformation/util.go | WaitForStackOperationComplete | func WaitForStackOperationComplete(stackID string,
pollingMessage string,
awsCloudFormation *cloudformation.CloudFormation,
logger *logrus.Logger) (*WaitForStackOperationCompleteResult, error) {
result := &WaitForStackOperationCompleteResult{}
startTime := time.Now()
// Startup a spinner...
charSetIndex := 7
... | go | func WaitForStackOperationComplete(stackID string,
pollingMessage string,
awsCloudFormation *cloudformation.CloudFormation,
logger *logrus.Logger) (*WaitForStackOperationCompleteResult, error) {
result := &WaitForStackOperationCompleteResult{}
startTime := time.Now()
// Startup a spinner...
charSetIndex := 7
... | [
"func",
"WaitForStackOperationComplete",
"(",
"stackID",
"string",
",",
"pollingMessage",
"string",
",",
"awsCloudFormation",
"*",
"cloudformation",
".",
"CloudFormation",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"(",
"*",
"WaitForStackOperationCompleteResult",... | // WaitForStackOperationComplete is a blocking, polling based call that
// periodically fetches the stackID set of events and uses the state value
// to determine if an operation is complete | [
"WaitForStackOperationComplete",
"is",
"a",
"blocking",
"polling",
"based",
"call",
"that",
"periodically",
"fetches",
"the",
"stackID",
"set",
"of",
"events",
"and",
"uses",
"the",
"state",
"value",
"to",
"determine",
"if",
"an",
"operation",
"is",
"complete"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/util.go#L529-L601 |
1,265 | mweagle/Sparta | aws/cloudformation/util.go | UploadTemplate | func UploadTemplate(serviceName string,
cfTemplate *gocf.Template,
s3Bucket string,
s3KeyName string,
awsSession *session.Session,
logger *logrus.Logger) (string, error) {
logger.WithFields(logrus.Fields{
"Key": s3KeyName,
"Bucket": s3Bucket,
}).Info("Uploading CloudFormation template")
s3Uploader := s... | go | func UploadTemplate(serviceName string,
cfTemplate *gocf.Template,
s3Bucket string,
s3KeyName string,
awsSession *session.Session,
logger *logrus.Logger) (string, error) {
logger.WithFields(logrus.Fields{
"Key": s3KeyName,
"Bucket": s3Bucket,
}).Info("Uploading CloudFormation template")
s3Uploader := s... | [
"func",
"UploadTemplate",
"(",
"serviceName",
"string",
",",
"cfTemplate",
"*",
"gocf",
".",
"Template",
",",
"s3Bucket",
"string",
",",
"s3KeyName",
"string",
",",
"awsSession",
"*",
"session",
".",
"Session",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")... | // UploadTemplate marshals the given cfTemplate and uploads it to the
// supplied bucket using the given KeyName | [
"UploadTemplate",
"marshals",
"the",
"given",
"cfTemplate",
"and",
"uploads",
"it",
"to",
"the",
"supplied",
"bucket",
"using",
"the",
"given",
"KeyName"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/util.go#L636-L676 |
1,266 | mweagle/Sparta | aws/cloudformation/util.go | StackExists | func StackExists(stackNameOrID string, awsSession *session.Session, logger *logrus.Logger) (bool, error) {
cf := cloudformation.New(awsSession)
describeStacksInput := &cloudformation.DescribeStacksInput{
StackName: aws.String(stackNameOrID),
}
describeStacksOutput, err := cf.DescribeStacks(describeStacksInput)
... | go | func StackExists(stackNameOrID string, awsSession *session.Session, logger *logrus.Logger) (bool, error) {
cf := cloudformation.New(awsSession)
describeStacksInput := &cloudformation.DescribeStacksInput{
StackName: aws.String(stackNameOrID),
}
describeStacksOutput, err := cf.DescribeStacks(describeStacksInput)
... | [
"func",
"StackExists",
"(",
"stackNameOrID",
"string",
",",
"awsSession",
"*",
"session",
".",
"Session",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"(",
"bool",
",",
"error",
")",
"{",
"cf",
":=",
"cloudformation",
".",
"New",
"(",
"awsSession",
... | // StackExists returns whether the given stackName or stackID currently exists | [
"StackExists",
"returns",
"whether",
"the",
"given",
"stackName",
"or",
"stackID",
"currently",
"exists"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/util.go#L679-L706 |
1,267 | mweagle/Sparta | aws/cloudformation/util.go | CreateStackChangeSet | func CreateStackChangeSet(changeSetRequestName string,
serviceName string,
cfTemplate *gocf.Template,
templateURL string,
awsTags []*cloudformation.Tag,
awsCloudFormation *cloudformation.CloudFormation,
logger *logrus.Logger) (*cloudformation.DescribeChangeSetOutput, error) {
capabilities := stackCapabilities(c... | go | func CreateStackChangeSet(changeSetRequestName string,
serviceName string,
cfTemplate *gocf.Template,
templateURL string,
awsTags []*cloudformation.Tag,
awsCloudFormation *cloudformation.CloudFormation,
logger *logrus.Logger) (*cloudformation.DescribeChangeSetOutput, error) {
capabilities := stackCapabilities(c... | [
"func",
"CreateStackChangeSet",
"(",
"changeSetRequestName",
"string",
",",
"serviceName",
"string",
",",
"cfTemplate",
"*",
"gocf",
".",
"Template",
",",
"templateURL",
"string",
",",
"awsTags",
"[",
"]",
"*",
"cloudformation",
".",
"Tag",
",",
"awsCloudFormation... | // CreateStackChangeSet returns the DescribeChangeSetOutput
// for a given stack transformation | [
"CreateStackChangeSet",
"returns",
"the",
"DescribeChangeSetOutput",
"for",
"a",
"given",
"stack",
"transformation"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/util.go#L710-L795 |
1,268 | mweagle/Sparta | aws/cloudformation/util.go | DeleteChangeSet | func DeleteChangeSet(stackName string,
changeSetRequestName string,
awsCloudFormation *cloudformation.CloudFormation) (*cloudformation.DeleteChangeSetOutput, error) {
// Delete request...
deleteChangeSetInput := cloudformation.DeleteChangeSetInput{
ChangeSetName: aws.String(changeSetRequestName),
StackName: ... | go | func DeleteChangeSet(stackName string,
changeSetRequestName string,
awsCloudFormation *cloudformation.CloudFormation) (*cloudformation.DeleteChangeSetOutput, error) {
// Delete request...
deleteChangeSetInput := cloudformation.DeleteChangeSetInput{
ChangeSetName: aws.String(changeSetRequestName),
StackName: ... | [
"func",
"DeleteChangeSet",
"(",
"stackName",
"string",
",",
"changeSetRequestName",
"string",
",",
"awsCloudFormation",
"*",
"cloudformation",
".",
"CloudFormation",
")",
"(",
"*",
"cloudformation",
".",
"DeleteChangeSetOutput",
",",
"error",
")",
"{",
"// Delete requ... | // DeleteChangeSet is a utility function that attempts to delete
// an existing CloudFormation change set, with a bit of retry
// logic in case of EC | [
"DeleteChangeSet",
"is",
"a",
"utility",
"function",
"that",
"attempts",
"to",
"delete",
"an",
"existing",
"CloudFormation",
"change",
"set",
"with",
"a",
"bit",
"of",
"retry",
"logic",
"in",
"case",
"of",
"EC"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/util.go#L800-L827 |
1,269 | mweagle/Sparta | aws/cloudformation/util.go | ListStacks | func ListStacks(session *session.Session,
maxReturned int,
stackFilters ...string) ([]*cloudformation.StackSummary, error) {
listStackInput := &cloudformation.ListStacksInput{
StackStatusFilter: []*string{},
}
for _, eachFilter := range stackFilters {
listStackInput.StackStatusFilter = append(listStackInput.S... | go | func ListStacks(session *session.Session,
maxReturned int,
stackFilters ...string) ([]*cloudformation.StackSummary, error) {
listStackInput := &cloudformation.ListStacksInput{
StackStatusFilter: []*string{},
}
for _, eachFilter := range stackFilters {
listStackInput.StackStatusFilter = append(listStackInput.S... | [
"func",
"ListStacks",
"(",
"session",
"*",
"session",
".",
"Session",
",",
"maxReturned",
"int",
",",
"stackFilters",
"...",
"string",
")",
"(",
"[",
"]",
"*",
"cloudformation",
".",
"StackSummary",
",",
"error",
")",
"{",
"listStackInput",
":=",
"&",
"clo... | // ListStacks returns a slice of stacks that meet the given filter. | [
"ListStacks",
"returns",
"a",
"slice",
"of",
"stacks",
"that",
"meet",
"the",
"given",
"filter",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/util.go#L830-L853 |
1,270 | mweagle/Sparta | provision.go | EnsureCustomResourceHandler | func EnsureCustomResourceHandler(serviceName string,
customResourceCloudFormationTypeName string,
sourceArn *gocf.StringExpr,
dependsOn []string,
template *gocf.Template,
S3Bucket string,
S3Key string,
logger *logrus.Logger) (string, error) {
// Ok, we need a way to round trip this type as the AWS lambda funct... | go | func EnsureCustomResourceHandler(serviceName string,
customResourceCloudFormationTypeName string,
sourceArn *gocf.StringExpr,
dependsOn []string,
template *gocf.Template,
S3Bucket string,
S3Key string,
logger *logrus.Logger) (string, error) {
// Ok, we need a way to round trip this type as the AWS lambda funct... | [
"func",
"EnsureCustomResourceHandler",
"(",
"serviceName",
"string",
",",
"customResourceCloudFormationTypeName",
"string",
",",
"sourceArn",
"*",
"gocf",
".",
"StringExpr",
",",
"dependsOn",
"[",
"]",
"string",
",",
"template",
"*",
"gocf",
".",
"Template",
",",
... | // EnsureCustomResourceHandler handles ensuring that the custom resource responsible
// for supporting the operation is actually part of this stack. The returned
// string value is the CloudFormation resource name that implements this
// resource. The customResourceCloudFormationTypeName must have already
// been regis... | [
"EnsureCustomResourceHandler",
"handles",
"ensuring",
"that",
"the",
"custom",
"resource",
"responsible",
"for",
"supporting",
"the",
"operation",
"is",
"actually",
"part",
"of",
"this",
"stack",
".",
"The",
"returned",
"string",
"value",
"is",
"the",
"CloudFormatio... | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/provision.go#L109-L202 |
1,271 | mweagle/Sparta | system/exec.go | RunOSCommand | func RunOSCommand(cmd *exec.Cmd, logger *logrus.Logger) error {
logger.WithFields(logrus.Fields{
"Arguments": cmd.Args,
"Dir": cmd.Dir,
"Path": cmd.Path,
"Env": cmd.Env,
}).Debug("Running Command")
outputWriter := logger.Writer()
cmdErr := RunAndCaptureOSCommand(cmd,
outputWriter,
outpu... | go | func RunOSCommand(cmd *exec.Cmd, logger *logrus.Logger) error {
logger.WithFields(logrus.Fields{
"Arguments": cmd.Args,
"Dir": cmd.Dir,
"Path": cmd.Path,
"Env": cmd.Env,
}).Debug("Running Command")
outputWriter := logger.Writer()
cmdErr := RunAndCaptureOSCommand(cmd,
outputWriter,
outpu... | [
"func",
"RunOSCommand",
"(",
"cmd",
"*",
"exec",
".",
"Cmd",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"error",
"{",
"logger",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"\"",
"\"",
":",
"cmd",
".",
"Args",
",",
"\"",
"\"",
":",
... | // RunOSCommand properly executes a system command
// and writes the output to the provided logger | [
"RunOSCommand",
"properly",
"executes",
"a",
"system",
"command",
"and",
"writes",
"the",
"output",
"to",
"the",
"provided",
"logger"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/system/exec.go#L12-L29 |
1,272 | mweagle/Sparta | system/exec.go | RunAndCaptureOSCommand | func RunAndCaptureOSCommand(cmd *exec.Cmd,
stdoutWriter io.Writer,
stderrWriter io.Writer,
logger *logrus.Logger) error {
logger.WithFields(logrus.Fields{
"Arguments": cmd.Args,
"Dir": cmd.Dir,
"Path": cmd.Path,
"Env": cmd.Env,
}).Debug("Running Command")
cmd.Stdout = stdoutWriter
cmd.St... | go | func RunAndCaptureOSCommand(cmd *exec.Cmd,
stdoutWriter io.Writer,
stderrWriter io.Writer,
logger *logrus.Logger) error {
logger.WithFields(logrus.Fields{
"Arguments": cmd.Args,
"Dir": cmd.Dir,
"Path": cmd.Path,
"Env": cmd.Env,
}).Debug("Running Command")
cmd.Stdout = stdoutWriter
cmd.St... | [
"func",
"RunAndCaptureOSCommand",
"(",
"cmd",
"*",
"exec",
".",
"Cmd",
",",
"stdoutWriter",
"io",
".",
"Writer",
",",
"stderrWriter",
"io",
".",
"Writer",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"error",
"{",
"logger",
".",
"WithFields",
"(",
"... | // RunAndCaptureOSCommand runs the given command and
// captures the stdout and stderr | [
"RunAndCaptureOSCommand",
"runs",
"the",
"given",
"command",
"and",
"captures",
"the",
"stdout",
"and",
"stderr"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/system/exec.go#L33-L47 |
1,273 | mweagle/Sparta | decorator/dashboard.go | DashboardDecorator | func DashboardDecorator(lambdaAWSInfo []*sparta.LambdaAWSInfo,
timeSeriesPeriod int) sparta.ServiceDecoratorHookFunc {
return func(context map[string]interface{},
serviceName string,
cfTemplate *gocf.Template,
S3Bucket string,
S3Key string,
buildID string,
awsSession *session.Session,
noop bool,
logge... | go | func DashboardDecorator(lambdaAWSInfo []*sparta.LambdaAWSInfo,
timeSeriesPeriod int) sparta.ServiceDecoratorHookFunc {
return func(context map[string]interface{},
serviceName string,
cfTemplate *gocf.Template,
S3Bucket string,
S3Key string,
buildID string,
awsSession *session.Session,
noop bool,
logge... | [
"func",
"DashboardDecorator",
"(",
"lambdaAWSInfo",
"[",
"]",
"*",
"sparta",
".",
"LambdaAWSInfo",
",",
"timeSeriesPeriod",
"int",
")",
"sparta",
".",
"ServiceDecoratorHookFunc",
"{",
"return",
"func",
"(",
"context",
"map",
"[",
"string",
"]",
"interface",
"{",... | // DashboardDecorator returns a ServiceDecoratorHook function that
// can be attached the workflow to create a dashboard | [
"DashboardDecorator",
"returns",
"a",
"ServiceDecoratorHook",
"function",
"that",
"can",
"be",
"attached",
"the",
"workflow",
"to",
"create",
"a",
"dashboard"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/decorator/dashboard.go#L130-L219 |
1,274 | mweagle/Sparta | aws/cloudformation/resources/s3ArtifactPublisherResource.go | Create | func (command S3ArtifactPublisherResource) Create(awsSession *session.Session,
event *CloudFormationLambdaEvent,
logger *logrus.Logger) (map[string]interface{}, error) {
unmarshalErr := json.Unmarshal(event.ResourceProperties, &command)
if unmarshalErr != nil {
return nil, unmarshalErr
}
mapData, mapDataErr :=... | go | func (command S3ArtifactPublisherResource) Create(awsSession *session.Session,
event *CloudFormationLambdaEvent,
logger *logrus.Logger) (map[string]interface{}, error) {
unmarshalErr := json.Unmarshal(event.ResourceProperties, &command)
if unmarshalErr != nil {
return nil, unmarshalErr
}
mapData, mapDataErr :=... | [
"func",
"(",
"command",
"S3ArtifactPublisherResource",
")",
"Create",
"(",
"awsSession",
"*",
"session",
".",
"Session",
",",
"event",
"*",
"CloudFormationLambdaEvent",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"(",
"map",
"[",
"string",
"]",
"interfac... | // Create implements the S3 create operation | [
"Create",
"implements",
"the",
"S3",
"create",
"operation"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/resources/s3ArtifactPublisherResource.go#L35-L61 |
1,275 | mweagle/Sparta | aws/cloudformation/resources/s3ArtifactPublisherResource.go | Update | func (command S3ArtifactPublisherResource) Update(awsSession *session.Session,
event *CloudFormationLambdaEvent,
logger *logrus.Logger) (map[string]interface{}, error) {
return command.Create(awsSession, event, logger)
} | go | func (command S3ArtifactPublisherResource) Update(awsSession *session.Session,
event *CloudFormationLambdaEvent,
logger *logrus.Logger) (map[string]interface{}, error) {
return command.Create(awsSession, event, logger)
} | [
"func",
"(",
"command",
"S3ArtifactPublisherResource",
")",
"Update",
"(",
"awsSession",
"*",
"session",
".",
"Session",
",",
"event",
"*",
"CloudFormationLambdaEvent",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"(",
"map",
"[",
"string",
"]",
"interfac... | // Update implements the S3 update operation | [
"Update",
"implements",
"the",
"S3",
"update",
"operation"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/resources/s3ArtifactPublisherResource.go#L64-L68 |
1,276 | mweagle/Sparta | aws/cloudformation/resources/s3ArtifactPublisherResource.go | Delete | func (command S3ArtifactPublisherResource) Delete(awsSession *session.Session,
event *CloudFormationLambdaEvent,
logger *logrus.Logger) (map[string]interface{}, error) {
unmarshalErr := json.Unmarshal(event.ResourceProperties, &command)
if unmarshalErr != nil {
return nil, unmarshalErr
}
s3DeleteObjectParams :... | go | func (command S3ArtifactPublisherResource) Delete(awsSession *session.Session,
event *CloudFormationLambdaEvent,
logger *logrus.Logger) (map[string]interface{}, error) {
unmarshalErr := json.Unmarshal(event.ResourceProperties, &command)
if unmarshalErr != nil {
return nil, unmarshalErr
}
s3DeleteObjectParams :... | [
"func",
"(",
"command",
"S3ArtifactPublisherResource",
")",
"Delete",
"(",
"awsSession",
"*",
"session",
".",
"Session",
",",
"event",
"*",
"CloudFormationLambdaEvent",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"(",
"map",
"[",
"string",
"]",
"interfac... | // Delete implements the S3 delete operation | [
"Delete",
"implements",
"the",
"S3",
"delete",
"operation"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/cloudformation/resources/s3ArtifactPublisherResource.go#L71-L93 |
1,277 | mweagle/Sparta | aws/s3/util.go | CreateS3RollbackFunc | func CreateS3RollbackFunc(awsSession *session.Session, s3ArtifactURL string) RollbackFunction {
return func(logger *logrus.Logger) error {
logger.WithFields(logrus.Fields{
"URL": s3ArtifactURL,
}).Info("Deleting S3 object")
artifactURLParts, artifactURLPartsErr := url.Parse(s3ArtifactURL)
if nil != artifact... | go | func CreateS3RollbackFunc(awsSession *session.Session, s3ArtifactURL string) RollbackFunction {
return func(logger *logrus.Logger) error {
logger.WithFields(logrus.Fields{
"URL": s3ArtifactURL,
}).Info("Deleting S3 object")
artifactURLParts, artifactURLPartsErr := url.Parse(s3ArtifactURL)
if nil != artifact... | [
"func",
"CreateS3RollbackFunc",
"(",
"awsSession",
"*",
"session",
".",
"Session",
",",
"s3ArtifactURL",
"string",
")",
"RollbackFunction",
"{",
"return",
"func",
"(",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"error",
"{",
"logger",
".",
"WithFields",
"(",... | // CreateS3RollbackFunc creates an S3 rollback function that attempts to delete a previously
// uploaded item. Note that s3ArtifactURL may include a `versionId` query arg
// to denote the specific version to delete. | [
"CreateS3RollbackFunc",
"creates",
"an",
"S3",
"rollback",
"function",
"that",
"attempts",
"to",
"delete",
"a",
"previously",
"uploaded",
"item",
".",
"Note",
"that",
"s3ArtifactURL",
"may",
"include",
"a",
"versionId",
"query",
"arg",
"to",
"denote",
"the",
"sp... | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/s3/util.go#L26-L54 |
1,278 | mweagle/Sparta | aws/s3/util.go | UploadLocalFileToS3 | func UploadLocalFileToS3(localPath string,
awsSession *session.Session,
S3Bucket string,
S3KeyName string,
logger *logrus.Logger) (string, error) {
// Then do the actual work
/* #nosec */
reader, err := os.Open(localPath)
if nil != err {
return "", fmt.Errorf("failed to open local archive for S3 upload: %s",... | go | func UploadLocalFileToS3(localPath string,
awsSession *session.Session,
S3Bucket string,
S3KeyName string,
logger *logrus.Logger) (string, error) {
// Then do the actual work
/* #nosec */
reader, err := os.Open(localPath)
if nil != err {
return "", fmt.Errorf("failed to open local archive for S3 upload: %s",... | [
"func",
"UploadLocalFileToS3",
"(",
"localPath",
"string",
",",
"awsSession",
"*",
"session",
".",
"Session",
",",
"S3Bucket",
"string",
",",
"S3KeyName",
"string",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"(",
"string",
",",
"error",
")",
"{",
"/... | // UploadLocalFileToS3 takes a local path and uploads the content at localPath
// to the given S3Bucket and KeyPrefix. The final S3 keyname is the S3KeyPrefix+
// the basename of the localPath. | [
"UploadLocalFileToS3",
"takes",
"a",
"local",
"path",
"and",
"uploads",
"the",
"content",
"at",
"localPath",
"to",
"the",
"given",
"S3Bucket",
"and",
"KeyPrefix",
".",
"The",
"final",
"S3",
"keyname",
"is",
"the",
"S3KeyPrefix",
"+",
"the",
"basename",
"of",
... | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/s3/util.go#L59-L120 |
1,279 | mweagle/Sparta | aws/s3/util.go | BucketVersioningEnabled | func BucketVersioningEnabled(awsSession *session.Session,
S3Bucket string,
logger *logrus.Logger) (bool, error) {
s3Svc := s3.New(awsSession)
params := &s3.GetBucketVersioningInput{
Bucket: aws.String(S3Bucket), // Required
}
versioningEnabled := false
resp, err := s3Svc.GetBucketVersioning(params)
if err ==... | go | func BucketVersioningEnabled(awsSession *session.Session,
S3Bucket string,
logger *logrus.Logger) (bool, error) {
s3Svc := s3.New(awsSession)
params := &s3.GetBucketVersioningInput{
Bucket: aws.String(S3Bucket), // Required
}
versioningEnabled := false
resp, err := s3Svc.GetBucketVersioning(params)
if err ==... | [
"func",
"BucketVersioningEnabled",
"(",
"awsSession",
"*",
"session",
".",
"Session",
",",
"S3Bucket",
"string",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"(",
"bool",
",",
"error",
")",
"{",
"s3Svc",
":=",
"s3",
".",
"New",
"(",
"awsSession",
")... | // BucketVersioningEnabled determines if a given S3 bucket has object
// versioning enabled. | [
"BucketVersioningEnabled",
"determines",
"if",
"a",
"given",
"S3",
"bucket",
"has",
"object",
"versioning",
"enabled",
"."
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/s3/util.go#L124-L143 |
1,280 | mweagle/Sparta | aws/s3/util.go | BucketRegion | func BucketRegion(awsSession *session.Session,
S3Bucket string,
logger *logrus.Logger) (string, error) {
regionHint := ""
if awsSession.Config.Region != nil {
regionHint = *awsSession.Config.Region
}
awsContext := aws.BackgroundContext()
return s3manager.GetBucketRegion(awsContext,
awsSession,
S3Bucket,
... | go | func BucketRegion(awsSession *session.Session,
S3Bucket string,
logger *logrus.Logger) (string, error) {
regionHint := ""
if awsSession.Config.Region != nil {
regionHint = *awsSession.Config.Region
}
awsContext := aws.BackgroundContext()
return s3manager.GetBucketRegion(awsContext,
awsSession,
S3Bucket,
... | [
"func",
"BucketRegion",
"(",
"awsSession",
"*",
"session",
".",
"Session",
",",
"S3Bucket",
"string",
",",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"(",
"string",
",",
"error",
")",
"{",
"regionHint",
":=",
"\"",
"\"",
"\n",
"if",
"awsSession",
".",
... | // BucketRegion returns the AWS region that hosts the bucket | [
"BucketRegion",
"returns",
"the",
"AWS",
"region",
"that",
"hosts",
"the",
"bucket"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/s3/util.go#L146-L158 |
1,281 | mweagle/Sparta | aws/step/sagemaker.go | NewSageMakerTrainingJob | func NewSageMakerTrainingJob(stateName string,
parameters SageMakerTrainingJobParameters) *SageMakerTrainingJob {
smtj := &SageMakerTrainingJob{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return smtj
} | go | func NewSageMakerTrainingJob(stateName string,
parameters SageMakerTrainingJobParameters) *SageMakerTrainingJob {
smtj := &SageMakerTrainingJob{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return smtj
} | [
"func",
"NewSageMakerTrainingJob",
"(",
"stateName",
"string",
",",
"parameters",
"SageMakerTrainingJobParameters",
")",
"*",
"SageMakerTrainingJob",
"{",
"smtj",
":=",
"&",
"SageMakerTrainingJob",
"{",
"BaseTask",
":",
"BaseTask",
"{",
"baseInnerState",
":",
"baseInner... | // NewSageMakerTrainingJob returns an initialized SQSTaskState | [
"NewSageMakerTrainingJob",
"returns",
"an",
"initialized",
"SQSTaskState"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/sagemaker.go#L56-L68 |
1,282 | mweagle/Sparta | aws/step/sagemaker.go | NewSageMakerTransformJob | func NewSageMakerTransformJob(stateName string,
parameters SageMakerTransformJobParameters) *SageMakerTransformJob {
sns := &SageMakerTransformJob{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return sns
} | go | func NewSageMakerTransformJob(stateName string,
parameters SageMakerTransformJobParameters) *SageMakerTransformJob {
sns := &SageMakerTransformJob{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return sns
} | [
"func",
"NewSageMakerTransformJob",
"(",
"stateName",
"string",
",",
"parameters",
"SageMakerTransformJobParameters",
")",
"*",
"SageMakerTransformJob",
"{",
"sns",
":=",
"&",
"SageMakerTransformJob",
"{",
"BaseTask",
":",
"BaseTask",
"{",
"baseInnerState",
":",
"baseIn... | // NewSageMakerTransformJob returns an initialized SQSTaskState | [
"NewSageMakerTransformJob",
"returns",
"an",
"initialized",
"SQSTaskState"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/sagemaker.go#L110-L122 |
1,283 | mweagle/Sparta | decorator/safe_deploy.go | codeDeployLambdaUpdateDecorator | func codeDeployLambdaUpdateDecorator(updateType string,
codeDeployApplicationName string,
codeDeployRoleName string) sparta.TemplateDecorator {
return func(serviceName string,
lambdaResourceName string,
lambdaResource gocf.LambdaFunction,
resourceMetadata map[string]interface{},
S3Bucket string,
S3Key stri... | go | func codeDeployLambdaUpdateDecorator(updateType string,
codeDeployApplicationName string,
codeDeployRoleName string) sparta.TemplateDecorator {
return func(serviceName string,
lambdaResourceName string,
lambdaResource gocf.LambdaFunction,
resourceMetadata map[string]interface{},
S3Bucket string,
S3Key stri... | [
"func",
"codeDeployLambdaUpdateDecorator",
"(",
"updateType",
"string",
",",
"codeDeployApplicationName",
"string",
",",
"codeDeployRoleName",
"string",
")",
"sparta",
".",
"TemplateDecorator",
"{",
"return",
"func",
"(",
"serviceName",
"string",
",",
"lambdaResourceName"... | // codeDeployLambdaUpdateDecorator is the per-function decorator
// that adds the necessary information for CodeDeploy | [
"codeDeployLambdaUpdateDecorator",
"is",
"the",
"per",
"-",
"function",
"decorator",
"that",
"adds",
"the",
"necessary",
"information",
"for",
"CodeDeploy"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/decorator/safe_deploy.go#L14-L76 |
1,284 | mweagle/Sparta | aws/step/glue.go | NewGlueState | func NewGlueState(stateName string,
parameters GlueParameters) *GlueState {
sns := &GlueState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return sns
} | go | func NewGlueState(stateName string,
parameters GlueParameters) *GlueState {
sns := &GlueState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return sns
} | [
"func",
"NewGlueState",
"(",
"stateName",
"string",
",",
"parameters",
"GlueParameters",
")",
"*",
"GlueState",
"{",
"sns",
":=",
"&",
"GlueState",
"{",
"BaseTask",
":",
"BaseTask",
"{",
"baseInnerState",
":",
"baseInnerState",
"{",
"name",
":",
"stateName",
"... | // NewGlueState returns an initialized GlueState | [
"NewGlueState",
"returns",
"an",
"initialized",
"GlueState"
] | a646ce10a6728e988448dc3f6f79cd3322854c61 | https://github.com/mweagle/Sparta/blob/a646ce10a6728e988448dc3f6f79cd3322854c61/aws/step/glue.go#L37-L50 |
1,285 | mwitkow/go-conntrack | listener_wrapper.go | TrackWithTcpKeepAlive | func TrackWithTcpKeepAlive(keepalive time.Duration) listenerOpt {
return func(opts *listenerOpts) {
opts.tcpKeepAlive = keepalive
}
} | go | func TrackWithTcpKeepAlive(keepalive time.Duration) listenerOpt {
return func(opts *listenerOpts) {
opts.tcpKeepAlive = keepalive
}
} | [
"func",
"TrackWithTcpKeepAlive",
"(",
"keepalive",
"time",
".",
"Duration",
")",
"listenerOpt",
"{",
"return",
"func",
"(",
"opts",
"*",
"listenerOpts",
")",
"{",
"opts",
".",
"tcpKeepAlive",
"=",
"keepalive",
"\n",
"}",
"\n",
"}"
] | // TrackWithTcpKeepAlive makes sure that any `net.TCPConn` that get accepted have a keep-alive.
// This is useful for HTTP servers in order for, for example laptops, to not use up resources on the
// server while they don't utilise their connection.
// A value of 0 disables it. | [
"TrackWithTcpKeepAlive",
"makes",
"sure",
"that",
"any",
"net",
".",
"TCPConn",
"that",
"get",
"accepted",
"have",
"a",
"keep",
"-",
"alive",
".",
"This",
"is",
"useful",
"for",
"HTTP",
"servers",
"in",
"order",
"for",
"for",
"example",
"laptops",
"to",
"n... | cc309e4a22231782e8893f3c35ced0967807a33e | https://github.com/mwitkow/go-conntrack/blob/cc309e4a22231782e8893f3c35ced0967807a33e/listener_wrapper.go#L54-L58 |
1,286 | mwitkow/go-conntrack | listener_wrapper.go | NewListener | func NewListener(inner net.Listener, optFuncs ...listenerOpt) net.Listener {
opts := &listenerOpts{
name: defaultName,
monitoring: true,
tracing: false,
}
for _, f := range optFuncs {
f(opts)
}
if opts.monitoring {
preRegisterListenerMetrics(opts.name)
}
return &connTrackListener{
Listener: ... | go | func NewListener(inner net.Listener, optFuncs ...listenerOpt) net.Listener {
opts := &listenerOpts{
name: defaultName,
monitoring: true,
tracing: false,
}
for _, f := range optFuncs {
f(opts)
}
if opts.monitoring {
preRegisterListenerMetrics(opts.name)
}
return &connTrackListener{
Listener: ... | [
"func",
"NewListener",
"(",
"inner",
"net",
".",
"Listener",
",",
"optFuncs",
"...",
"listenerOpt",
")",
"net",
".",
"Listener",
"{",
"opts",
":=",
"&",
"listenerOpts",
"{",
"name",
":",
"defaultName",
",",
"monitoring",
":",
"true",
",",
"tracing",
":",
... | // NewListener returns the given listener wrapped in connection tracking listener. | [
"NewListener",
"returns",
"the",
"given",
"listener",
"wrapped",
"in",
"connection",
"tracking",
"listener",
"."
] | cc309e4a22231782e8893f3c35ced0967807a33e | https://github.com/mwitkow/go-conntrack/blob/cc309e4a22231782e8893f3c35ced0967807a33e/listener_wrapper.go#L66-L82 |
1,287 | mwitkow/go-conntrack | connhelpers/tls.go | TlsConfigWithHttp2Enabled | func TlsConfigWithHttp2Enabled(config *tls.Config) (*tls.Config, error) {
// mostly based on http2 code in the standards library.
if config.CipherSuites != nil {
// If they already provided a CipherSuite list, return
// an error if it has a bad order or is missing
// ECDHE_RSA_WITH_AES_128_GCM_SHA256.
const r... | go | func TlsConfigWithHttp2Enabled(config *tls.Config) (*tls.Config, error) {
// mostly based on http2 code in the standards library.
if config.CipherSuites != nil {
// If they already provided a CipherSuite list, return
// an error if it has a bad order or is missing
// ECDHE_RSA_WITH_AES_128_GCM_SHA256.
const r... | [
"func",
"TlsConfigWithHttp2Enabled",
"(",
"config",
"*",
"tls",
".",
"Config",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"// mostly based on http2 code in the standards library.",
"if",
"config",
".",
"CipherSuites",
"!=",
"nil",
"{",
"// If the... | // TlsConfigWithHttp2Enabled makes it easy to configure the given `tls.Config` to prefer H2 connections.
// This is useful if you can't use `http.ListenAndServerTLS` when using a custom `net.Listener`. | [
"TlsConfigWithHttp2Enabled",
"makes",
"it",
"easy",
"to",
"configure",
"the",
"given",
"tls",
".",
"Config",
"to",
"prefer",
"H2",
"connections",
".",
"This",
"is",
"useful",
"if",
"you",
"can",
"t",
"use",
"http",
".",
"ListenAndServerTLS",
"when",
"using",
... | cc309e4a22231782e8893f3c35ced0967807a33e | https://github.com/mwitkow/go-conntrack/blob/cc309e4a22231782e8893f3c35ced0967807a33e/connhelpers/tls.go#L26-L60 |
1,288 | mwitkow/go-conntrack | dialer_reporter.go | PreRegisterDialerMetrics | func PreRegisterDialerMetrics(dialerName string) {
dialerAttemptedTotal.WithLabelValues(dialerName)
dialerConnEstablishedTotal.WithLabelValues(dialerName)
for _, reason := range []failureReason{failedTimeout, failedResolution, failedConnRefused, failedUnknown} {
dialerConnFailedTotal.WithLabelValues(dialerName, st... | go | func PreRegisterDialerMetrics(dialerName string) {
dialerAttemptedTotal.WithLabelValues(dialerName)
dialerConnEstablishedTotal.WithLabelValues(dialerName)
for _, reason := range []failureReason{failedTimeout, failedResolution, failedConnRefused, failedUnknown} {
dialerConnFailedTotal.WithLabelValues(dialerName, st... | [
"func",
"PreRegisterDialerMetrics",
"(",
"dialerName",
"string",
")",
"{",
"dialerAttemptedTotal",
".",
"WithLabelValues",
"(",
"dialerName",
")",
"\n",
"dialerConnEstablishedTotal",
".",
"WithLabelValues",
"(",
"dialerName",
")",
"\n",
"for",
"_",
",",
"reason",
":... | // preRegisterDialerMetrics pre-populates Prometheus labels for the given dialer name, to avoid Prometheus missing labels issue. | [
"preRegisterDialerMetrics",
"pre",
"-",
"populates",
"Prometheus",
"labels",
"for",
"the",
"given",
"dialer",
"name",
"to",
"avoid",
"Prometheus",
"missing",
"labels",
"issue",
"."
] | cc309e4a22231782e8893f3c35ced0967807a33e | https://github.com/mwitkow/go-conntrack/blob/cc309e4a22231782e8893f3c35ced0967807a33e/dialer_reporter.go#L66-L73 |
1,289 | mwitkow/go-conntrack | dialer_wrapper.go | DialNameFromContext | func DialNameFromContext(ctx context.Context) string {
val, ok := ctx.Value(dialerNameKey).(string)
if !ok {
return ""
}
return val
} | go | func DialNameFromContext(ctx context.Context) string {
val, ok := ctx.Value(dialerNameKey).(string)
if !ok {
return ""
}
return val
} | [
"func",
"DialNameFromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"string",
"{",
"val",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"dialerNameKey",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
... | // DialNameFromContext returns the name of the dialer from the context of the DialContext func, if any. | [
"DialNameFromContext",
"returns",
"the",
"name",
"of",
"the",
"dialer",
"from",
"the",
"context",
"of",
"the",
"DialContext",
"func",
"if",
"any",
"."
] | cc309e4a22231782e8893f3c35ced0967807a33e | https://github.com/mwitkow/go-conntrack/blob/cc309e4a22231782e8893f3c35ced0967807a33e/dialer_wrapper.go#L66-L72 |
1,290 | mwitkow/go-conntrack | dialer_wrapper.go | DialNameToContext | func DialNameToContext(ctx context.Context, dialerName string) context.Context {
return context.WithValue(ctx, dialerNameKey, dialerName)
} | go | func DialNameToContext(ctx context.Context, dialerName string) context.Context {
return context.WithValue(ctx, dialerNameKey, dialerName)
} | [
"func",
"DialNameToContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"dialerName",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"dialerNameKey",
",",
"dialerName",
")",
"\n",
"}"
] | // DialNameToContext returns a context that will contain a dialer name override. | [
"DialNameToContext",
"returns",
"a",
"context",
"that",
"will",
"contain",
"a",
"dialer",
"name",
"override",
"."
] | cc309e4a22231782e8893f3c35ced0967807a33e | https://github.com/mwitkow/go-conntrack/blob/cc309e4a22231782e8893f3c35ced0967807a33e/dialer_wrapper.go#L75-L77 |
1,291 | mwitkow/go-conntrack | dialer_wrapper.go | NewDialContextFunc | func NewDialContextFunc(optFuncs ...dialerOpt) func(context.Context, string, string) (net.Conn, error) {
opts := &dialerOpts{name: defaultName, monitoring: true, parentDialContextFunc: (&net.Dialer{}).DialContext}
for _, f := range optFuncs {
f(opts)
}
if opts.monitoring {
PreRegisterDialerMetrics(opts.name)
}... | go | func NewDialContextFunc(optFuncs ...dialerOpt) func(context.Context, string, string) (net.Conn, error) {
opts := &dialerOpts{name: defaultName, monitoring: true, parentDialContextFunc: (&net.Dialer{}).DialContext}
for _, f := range optFuncs {
f(opts)
}
if opts.monitoring {
PreRegisterDialerMetrics(opts.name)
}... | [
"func",
"NewDialContextFunc",
"(",
"optFuncs",
"...",
"dialerOpt",
")",
"func",
"(",
"context",
".",
"Context",
",",
"string",
",",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"opts",
":=",
"&",
"dialerOpts",
"{",
"name",
":",
"defa... | // NewDialContextFunc returns a `DialContext` function that tracks outbound connections.
// The signature is compatible with `http.Tranport.DialContext` and is meant to be used there. | [
"NewDialContextFunc",
"returns",
"a",
"DialContext",
"function",
"that",
"tracks",
"outbound",
"connections",
".",
"The",
"signature",
"is",
"compatible",
"with",
"http",
".",
"Tranport",
".",
"DialContext",
"and",
"is",
"meant",
"to",
"be",
"used",
"there",
"."... | cc309e4a22231782e8893f3c35ced0967807a33e | https://github.com/mwitkow/go-conntrack/blob/cc309e4a22231782e8893f3c35ced0967807a33e/dialer_wrapper.go#L81-L96 |
1,292 | mwitkow/go-conntrack | dialer_wrapper.go | NewDialFunc | func NewDialFunc(optFuncs ...dialerOpt) func(string, string) (net.Conn, error) {
dialContextFunc := NewDialContextFunc(optFuncs...)
return func(network string, addr string) (net.Conn, error) {
return dialContextFunc(context.TODO(), network, addr)
}
} | go | func NewDialFunc(optFuncs ...dialerOpt) func(string, string) (net.Conn, error) {
dialContextFunc := NewDialContextFunc(optFuncs...)
return func(network string, addr string) (net.Conn, error) {
return dialContextFunc(context.TODO(), network, addr)
}
} | [
"func",
"NewDialFunc",
"(",
"optFuncs",
"...",
"dialerOpt",
")",
"func",
"(",
"string",
",",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"dialContextFunc",
":=",
"NewDialContextFunc",
"(",
"optFuncs",
"...",
")",
"\n",
"return",
"func",... | // NewDialFunc returns a `Dial` function that tracks outbound connections.
// The signature is compatible with `http.Tranport.Dial` and is meant to be used there for Go < 1.7. | [
"NewDialFunc",
"returns",
"a",
"Dial",
"function",
"that",
"tracks",
"outbound",
"connections",
".",
"The",
"signature",
"is",
"compatible",
"with",
"http",
".",
"Tranport",
".",
"Dial",
"and",
"is",
"meant",
"to",
"be",
"used",
"there",
"for",
"Go",
"<",
... | cc309e4a22231782e8893f3c35ced0967807a33e | https://github.com/mwitkow/go-conntrack/blob/cc309e4a22231782e8893f3c35ced0967807a33e/dialer_wrapper.go#L100-L105 |
1,293 | lox/httpcache | cache.go | NewVFSCache | func NewVFSCache(fs vfs.VFS) Cache {
return &cache{fs: fs, stale: map[string]time.Time{}}
} | go | func NewVFSCache(fs vfs.VFS) Cache {
return &cache{fs: fs, stale: map[string]time.Time{}}
} | [
"func",
"NewVFSCache",
"(",
"fs",
"vfs",
".",
"VFS",
")",
"Cache",
"{",
"return",
"&",
"cache",
"{",
"fs",
":",
"fs",
",",
"stale",
":",
"map",
"[",
"string",
"]",
"time",
".",
"Time",
"{",
"}",
"}",
"\n",
"}"
] | // NewCache returns a cache backend off the provided VFS | [
"NewCache",
"returns",
"a",
"cache",
"backend",
"off",
"the",
"provided",
"VFS"
] | 2de7d84cb2513697e071961c5a5a81060c4382b5 | https://github.com/lox/httpcache/blob/2de7d84cb2513697e071961c5a5a81060c4382b5/cache.go#L53-L55 |
1,294 | lox/httpcache | cache.go | NewDiskCache | func NewDiskCache(dir string) (Cache, error) {
if err := os.MkdirAll(dir, 0777); err != nil {
return nil, err
}
fs, err := vfs.FS(dir)
if err != nil {
return nil, err
}
chfs, err := vfs.Chroot("/", fs)
if err != nil {
return nil, err
}
return NewVFSCache(chfs), nil
} | go | func NewDiskCache(dir string) (Cache, error) {
if err := os.MkdirAll(dir, 0777); err != nil {
return nil, err
}
fs, err := vfs.FS(dir)
if err != nil {
return nil, err
}
chfs, err := vfs.Chroot("/", fs)
if err != nil {
return nil, err
}
return NewVFSCache(chfs), nil
} | [
"func",
"NewDiskCache",
"(",
"dir",
"string",
")",
"(",
"Cache",
",",
"error",
")",
"{",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"dir",
",",
"0777",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"fs",
"... | // NewDiskCache returns a disk-backed cache | [
"NewDiskCache",
"returns",
"a",
"disk",
"-",
"backed",
"cache"
] | 2de7d84cb2513697e071961c5a5a81060c4382b5 | https://github.com/lox/httpcache/blob/2de7d84cb2513697e071961c5a5a81060c4382b5/cache.go#L63-L76 |
1,295 | lox/httpcache | cache.go | Header | func (c *cache) Header(key string) (Header, error) {
path := headerPrefix + formatPrefix + hashKey(key)
f, err := c.fs.Open(path)
if err != nil {
if vfs.IsNotExist(err) {
return Header{}, ErrNotFoundInCache
}
return Header{}, err
}
return readHeaders(bufio.NewReader(f))
} | go | func (c *cache) Header(key string) (Header, error) {
path := headerPrefix + formatPrefix + hashKey(key)
f, err := c.fs.Open(path)
if err != nil {
if vfs.IsNotExist(err) {
return Header{}, ErrNotFoundInCache
}
return Header{}, err
}
return readHeaders(bufio.NewReader(f))
} | [
"func",
"(",
"c",
"*",
"cache",
")",
"Header",
"(",
"key",
"string",
")",
"(",
"Header",
",",
"error",
")",
"{",
"path",
":=",
"headerPrefix",
"+",
"formatPrefix",
"+",
"hashKey",
"(",
"key",
")",
"\n",
"f",
",",
"err",
":=",
"c",
".",
"fs",
".",... | // Retrieve the Status and Headers for a given key path | [
"Retrieve",
"the",
"Status",
"and",
"Headers",
"for",
"a",
"given",
"key",
"path"
] | 2de7d84cb2513697e071961c5a5a81060c4382b5 | https://github.com/lox/httpcache/blob/2de7d84cb2513697e071961c5a5a81060c4382b5/cache.go#L94-L105 |
1,296 | lox/httpcache | cache.go | Store | func (c *cache) Store(res *Resource, keys ...string) error {
var buf = &bytes.Buffer{}
if length, err := strconv.ParseInt(res.Header().Get("Content-Length"), 10, 64); err == nil {
if _, err = io.CopyN(buf, res, length); err != nil {
return err
}
} else if _, err = io.Copy(buf, res); err != nil {
return err... | go | func (c *cache) Store(res *Resource, keys ...string) error {
var buf = &bytes.Buffer{}
if length, err := strconv.ParseInt(res.Header().Get("Content-Length"), 10, 64); err == nil {
if _, err = io.CopyN(buf, res, length); err != nil {
return err
}
} else if _, err = io.Copy(buf, res); err != nil {
return err... | [
"func",
"(",
"c",
"*",
"cache",
")",
"Store",
"(",
"res",
"*",
"Resource",
",",
"keys",
"...",
"string",
")",
"error",
"{",
"var",
"buf",
"=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n\n",
"if",
"length",
",",
"err",
":=",
"strconv",
".",
"Parse... | // Store a resource against a number of keys | [
"Store",
"a",
"resource",
"against",
"a",
"number",
"of",
"keys"
] | 2de7d84cb2513697e071961c5a5a81060c4382b5 | https://github.com/lox/httpcache/blob/2de7d84cb2513697e071961c5a5a81060c4382b5/cache.go#L108-L132 |
1,297 | lox/httpcache | cache.go | Retrieve | func (c *cache) Retrieve(key string) (*Resource, error) {
f, err := c.fs.Open(bodyPrefix + formatPrefix + hashKey(key))
if err != nil {
if vfs.IsNotExist(err) {
return nil, ErrNotFoundInCache
}
return nil, err
}
h, err := c.Header(key)
if err != nil {
if vfs.IsNotExist(err) {
return nil, ErrNotFoundI... | go | func (c *cache) Retrieve(key string) (*Resource, error) {
f, err := c.fs.Open(bodyPrefix + formatPrefix + hashKey(key))
if err != nil {
if vfs.IsNotExist(err) {
return nil, ErrNotFoundInCache
}
return nil, err
}
h, err := c.Header(key)
if err != nil {
if vfs.IsNotExist(err) {
return nil, ErrNotFoundI... | [
"func",
"(",
"c",
"*",
"cache",
")",
"Retrieve",
"(",
"key",
"string",
")",
"(",
"*",
"Resource",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"c",
".",
"fs",
".",
"Open",
"(",
"bodyPrefix",
"+",
"formatPrefix",
"+",
"hashKey",
"(",
"key",
")",... | // Retrieve returns a cached Resource for the given key | [
"Retrieve",
"returns",
"a",
"cached",
"Resource",
"for",
"the",
"given",
"key"
] | 2de7d84cb2513697e071961c5a5a81060c4382b5 | https://github.com/lox/httpcache/blob/2de7d84cb2513697e071961c5a5a81060c4382b5/cache.go#L153-L176 |
1,298 | lox/httpcache | handler.go | freshness | func (h *Handler) freshness(res *Resource, r *cacheRequest) (time.Duration, error) {
maxAge, err := res.MaxAge(h.Shared)
if err != nil {
return time.Duration(0), err
}
if r.CacheControl.Has("max-age") {
reqMaxAge, err := r.CacheControl.Duration("max-age")
if err != nil {
return time.Duration(0), err
}
... | go | func (h *Handler) freshness(res *Resource, r *cacheRequest) (time.Duration, error) {
maxAge, err := res.MaxAge(h.Shared)
if err != nil {
return time.Duration(0), err
}
if r.CacheControl.Has("max-age") {
reqMaxAge, err := r.CacheControl.Duration("max-age")
if err != nil {
return time.Duration(0), err
}
... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"freshness",
"(",
"res",
"*",
"Resource",
",",
"r",
"*",
"cacheRequest",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"maxAge",
",",
"err",
":=",
"res",
".",
"MaxAge",
"(",
"h",
".",
"Shared",
... | // freshness returns the duration that a requested resource will be fresh for | [
"freshness",
"returns",
"the",
"duration",
"that",
"a",
"requested",
"resource",
"will",
"be",
"fresh",
"for"
] | 2de7d84cb2513697e071961c5a5a81060c4382b5 | https://github.com/lox/httpcache/blob/2de7d84cb2513697e071961c5a5a81060c4382b5/handler.go#L131-L164 |
1,299 | lox/httpcache | handler.go | pipeUpstream | func (h *Handler) pipeUpstream(w http.ResponseWriter, r *cacheRequest) {
rw := newResponseStreamer(w)
rdr, err := rw.Stream.NextReader()
if err != nil {
debugf("error creating next stream reader: %v", err)
w.Header().Set(CacheHeader, "SKIP")
h.upstream.ServeHTTP(w, r.Request)
return
}
defer rdr.Close()
d... | go | func (h *Handler) pipeUpstream(w http.ResponseWriter, r *cacheRequest) {
rw := newResponseStreamer(w)
rdr, err := rw.Stream.NextReader()
if err != nil {
debugf("error creating next stream reader: %v", err)
w.Header().Set(CacheHeader, "SKIP")
h.upstream.ServeHTTP(w, r.Request)
return
}
defer rdr.Close()
d... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"pipeUpstream",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"cacheRequest",
")",
"{",
"rw",
":=",
"newResponseStreamer",
"(",
"w",
")",
"\n",
"rdr",
",",
"err",
":=",
"rw",
".",
"Stream",
".",
"NextR... | // pipeUpstream makes the request via the upstream handler, the response is not stored or modified | [
"pipeUpstream",
"makes",
"the",
"request",
"via",
"the",
"upstream",
"handler",
"the",
"response",
"is",
"not",
"stored",
"or",
"modified"
] | 2de7d84cb2513697e071961c5a5a81060c4382b5 | https://github.com/lox/httpcache/blob/2de7d84cb2513697e071961c5a5a81060c4382b5/handler.go#L206-L236 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.