Skip to content

Commit

Permalink
Auto-merge pull request #25 from atomist-skills/go-skill
Browse files Browse the repository at this point in the history
name: export NameFromEvent
    
Pull request auto merged:

* 1 approved review by @felipecruz91
* 1 successful check
  • Loading branch information
atomist[bot] authored Sep 7, 2023
2 parents dda55b9 + 3e97938 commit 23068b7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func createHttpHandler(handlers Handlers) func(http.ResponseWriter, *http.Reques
return
}

name := nameFromEvent(event)
name := NameFromEvent(event)
ctx := context.Background()
logger := createLogger(ctx, event)
req := RequestContext{
Expand Down
2 changes: 1 addition & 1 deletion handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestUnmarshal(t *testing.T) {
var payload = "{:execution-id\n \"698e4c21-bf56-482b-be70-54273910fc37.YgDUPm3oIpDTT0SbYH5t5\"\n :skill\n {:namespace \"atomist\"\n :name \"go-sample-skill\"\n :version \"0.1.0-42\"}\n :workspace-id \"T29E48P34\"\n :type :subscription\n :context\n {:subscription\n {:name \"on_push\"\n :configuration {:name \"go_sample_skill\"}\n :result\n ([{:schema/entity-type \":git/commit\"\n :git.commit/repo\n {:git.repo/name \"go-sample-skill\"\n :git.repo/source-id \"490643782\"\n :git.repo/default-branch \"main\"\n :git.repo/org\n {:github.org/installation-token\n \"ghs_jrb2OZetoqnpa7v27NNj2egKzOPniB1U8YTH\"\n :git.org/name \"atomist-skills\"\n :git.provider/url \"https://github.com\"}}\n :git.commit/author\n {:git.user/name \"Christian Dupuis\"\n :git.user/login \"cdupuis\"\n :git.user/emails\n [{:email.email/address \"[email protected]\"}]}\n :git.commit/sha\n \"68c3d821eddc46c4dc4b1de0ffb1a6c29a5342a9\"\n :git.commit/message \"Update README.md\"\n :git.ref/refs\n [{:git.ref/name \"main\"\n :git.ref/type\n {:db/id 83562883711320\n :db/ident \":git.ref.type/branch\"}}]}])\n :after-basis-t 4284274\n :tx 13194143817586}}\n :urls\n {:execution\n \"https://api.atomist.com/executions/698e4c21-bf56-482b-be70-54273910fc37.YgDUPm3oIpDTT0SbYH5t5\"\n :logs\n \"https://api.atomist.com/executions/698e4c21-bf56-482b-be70-54273910fc37.YgDUPm3oIpDTT0SbYH5t5/logs\"\n :transactions\n \"https://api.atomist.com/executions/698e4c21-bf56-482b-be70-54273910fc37.YgDUPm3oIpDTT0SbYH5t5/transactions\"\n :query\n \"https://api.atomist.com/datalog/team/T29E48P34/queries\"}\n :token \"[JSON_WEB_TOKEN]\"}"
var event EventIncoming
err := edn.NewDecoder(strings.NewReader(payload)).Decode(&event)
name := nameFromEvent(event)
name := NameFromEvent(event)
if name != "on_push" {
t.Errorf("Expected on_push as name")
}
Expand Down
2 changes: 1 addition & 1 deletion log.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func debugInfo(logger Logger, event EventIncoming) {
}
}
if skillDep != nil && revision != "" {
logger.Debugf("Starting %s/%s:%s '%s' (%s) %s:%s %s", event.Skill.Namespace, event.Skill.Name, event.Skill.Version, nameFromEvent(event), revision, skillDep.Path, skillDep.Version, goVersion)
logger.Debugf("Starting %s/%s:%s '%s' (%s) %s:%s %s", event.Skill.Namespace, event.Skill.Name, event.Skill.Version, NameFromEvent(event), revision, skillDep.Path, skillDep.Version, goVersion)
}
}
}
4 changes: 2 additions & 2 deletions name.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package skill

// nameFromEvent extracts the name of either a subscription or
// NameFromEvent extracts the name of either a subscription or
// webhook from the incoming payload
func nameFromEvent(event EventIncoming) string {
func NameFromEvent(event EventIncoming) string {
switch event.Type {
case "subscription":
return event.Context.Subscription.Name
Expand Down

0 comments on commit 23068b7

Please sign in to comment.