Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/core-concepts/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ tools:
- name: trello
instanceID: default
options:
board:
name: golang-demo-board
apikey: xxx
token: xxx
scm:
owner: IronCore864
name: golang-demo
repo: golang-demo
scmType: github
borad:
name: golang-demo-board
```
```

- `TOOL_NAME` is "trello"
- `TOOL_INSTANCE_ID` is "default"
Expand Down
11 changes: 8 additions & 3 deletions docs/core-concepts/config.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ tools:
- name: trello
instanceID: default
options:
owner: IronCore864
repo: golang-demo
kanbanBoardName: golang-demo-board
board:
name: golang-demo-board
apikey: xxx
token: xxx
scm:
owner: IronCore864
repo: golang-demo
scmType: github
```

- `TOOL_NAME` 是 "trello"
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/plugin/trello/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type options struct {
type board struct {
Name string `mapstructure:"name"`
Description string `mapstructure:"description"`
APIKey string `mapstructure:"apiKey"`
Token string `mapstructure:"token"`
}

type boardIDInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/trello/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func getState(rawOptions configmanager.RawOptions) (statemanager.ResourceStatus,
return nil, err
}

c, err := trello.NewClient()
c, err := trello.NewClient(opts.Board.APIKey, opts.Board.Token)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/plugin/trello/trello.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func createBoard(rawOptions configmanager.RawOptions) error {
if err != nil {
return err
}
c, err := trello.NewClient()
c, err := trello.NewClient(opts.Board.APIKey, opts.Board.Token)
if err != nil {
return err
}
Expand All @@ -27,7 +27,7 @@ func deleteBoard(rawOptions configmanager.RawOptions) error {
if err != nil {
return err
}
c, err := trello.NewClient()
c, err := trello.NewClient(opts.Board.APIKey, opts.Board.Token)
if err != nil {
return err
}
Expand All @@ -48,7 +48,7 @@ func addTrelloSecret(rawOptions configmanager.RawOptions) error {
}

// 2. init trello client
trelloClient, err := trello.NewClient()
trelloClient, err := trello.NewClient(opts.Board.APIKey, opts.Board.Token)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/trello/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func setDefault(rawOptions configmanager.RawOptions) (configmanager.RawOptions,
if err != nil {
return nil, err
}
// set board dedefault value
// set board default value
var boardDefaultConfig = &board{
Name: fmt.Sprintf("%s/%s", opts.Scm.GetRepoOwner(), opts.Scm.GetRepoName()),
Description: fmt.Sprintf("Description is managed by DevStream, please don't modify. %s/%s", opts.Scm.GetRepoOwner(), opts.Scm.GetRepoName()),
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/plugin/trello/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var _ = Describe("setDefault method", func() {
Expect(data["board"]).Should(Equal(map[string]any{
"name": "test_user/test",
"description": "Description is managed by DevStream, please don't modify. test_user/test",
"apiKey": "",
"token": "",
}))
Expect(data["scm"]).Should(Equal(map[string]any{
"owner": "test_user",
Expand Down
9 changes: 6 additions & 3 deletions internal/pkg/show/config/plugins/trello.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ tools:
options:
# the repo's owner
board:
# the Tello board name. If empty, use owner/name as the board's name.
# the Trello board name. If empty, use owner/name as the board's name.
name: KANBAN_BOARD_NAME
# the Tello board description. If empty, use devstream's default description
# the Trello board description. If empty, use devstream's default description
description: KANBAN_DESCRIPTION
# Trello apiKey and token, see https://docs.servicenow.com/bundle/quebec-it-asset-management/page/product/software-asset-management2/task/generate-trello-apikey-token.html for more information
apikey: [[ env TRELLO_API_KEY ]] # use environment variable "TRELLO_API_KEY" to set the value
token: [[ env TRELLO_TOKEN ]] # use environment variable "TRELLO_TOKEN" to set the value
scm:
name: YOUR_PROJECT_NAME
owner: YOUR_REPO_OWNER
Expand All @@ -21,4 +24,4 @@ tools:
# project branch
branch: YOUR_PROJECT_BRANCH
# scm repo token
token: YOUR_REPO_TOKEN
token: [[ env GITHUB_TOKEN ]] # use environment variable "GITHUB_TOKEN" to set the value
5 changes: 1 addition & 4 deletions pkg/util/trello/trello.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package trello

import (
"fmt"
"os"

"github.com/adlio/trello"
)
Expand All @@ -16,9 +15,7 @@ type client struct {
*trello.Client
}

func NewClient() (TrelloAPI, error) {
apiKey := os.Getenv("TRELLO_API_KEY")
token := os.Getenv("TRELLO_TOKEN")
func NewClient(apiKey, token string) (TrelloAPI, error) {
if apiKey == "" || token == "" {
const helpUrl = "https://docs.servicenow.com/bundle/quebec-it-asset-management/page/product/software-asset-management2/task/generate-trello-apikey-token.html"
return nil, fmt.Errorf("TRELLO_API_KEY and/or TRELLO_TOKEN are/is empty. see %s for more info", helpUrl)
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/yaml/e2e-trello-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ tools:
org: [[ githubOrganization ]]
name: [[ repoName ]]
scmType: github
token: [[ env GITHUB_TOKEN ]]
board:
name: [[ kanbanBoardName ]]
apikey: [[ env TRELLO_API_KEY ]]
token: [[ env TRELLO_TOKEN ]]