mirror of https://github.com/databricks/cli.git
Compare commits
6 Commits
a571492724
...
9c7d2a238f
Author | SHA1 | Date |
---|---|---|
Andrew Nester | 9c7d2a238f | |
Andrew Nester | 0753dfe2f4 | |
Andrew Nester | 68e27f2eed | |
Andrew Nester | d58624b644 | |
Andrew Nester | 555f635058 | |
Andrew Nester | 7cf99715c0 |
|
@ -0,0 +1,34 @@
|
|||
name: "Close Stale Issues"
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 */4 * * *"
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
permissions:
|
||||
issues: write
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
name: Stale issue job
|
||||
steps:
|
||||
- uses: actions/stale@v8
|
||||
with:
|
||||
issue-types: issues
|
||||
stale-issue-message: This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
|
||||
|
||||
# These labels are required
|
||||
stale-issue-label: Stale
|
||||
exempt-issue-labels: No Autoclose
|
||||
|
||||
# Issue timing
|
||||
days-before-stale: 30
|
||||
days-before-close: 7
|
||||
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
loglevel: DEBUG
|
||||
# Set dry-run to true to not perform label or close actions.
|
||||
dry-run: false
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
|
||||
"github.com/databricks/cli/libs/diag"
|
||||
"github.com/databricks/cli/libs/dyn/convert"
|
||||
|
@ -63,11 +64,24 @@ func (j *JsonFlag) Unmarshal(v any) diag.Diagnostics {
|
|||
return diags.Extend(diag.FromErr(err))
|
||||
}
|
||||
|
||||
// Finally unmarshal the normalized data to the output.
|
||||
// It will fill in the ForceSendFields field if the struct contains it.
|
||||
err = marshal.Unmarshal(data, v)
|
||||
if err != nil {
|
||||
return diags.Extend(diag.FromErr(err))
|
||||
kind := reflect.ValueOf(v).Kind()
|
||||
if kind == reflect.Ptr {
|
||||
kind = reflect.ValueOf(v).Elem().Kind()
|
||||
}
|
||||
|
||||
if kind == reflect.Struct {
|
||||
// Finally unmarshal the normalized data to the output.
|
||||
// It will fill in the ForceSendFields field if the struct contains it.
|
||||
err = marshal.Unmarshal(data, v)
|
||||
if err != nil {
|
||||
return diags.Extend(diag.FromErr(err))
|
||||
}
|
||||
} else {
|
||||
// If the output is not a struct, just unmarshal the data to the output.
|
||||
err = json.Unmarshal(data, v)
|
||||
if err != nil {
|
||||
return diags.Extend(diag.FromErr(err))
|
||||
}
|
||||
}
|
||||
|
||||
return diags
|
||||
|
|
|
@ -13,10 +13,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type requestType struct {
|
||||
Foo string `json:"foo"`
|
||||
}
|
||||
|
||||
func TestJsonFlagEmpty(t *testing.T) {
|
||||
var body JsonFlag
|
||||
|
||||
|
@ -35,13 +31,13 @@ func TestJsonFlagInline(t *testing.T) {
|
|||
err := body.Set(`{"foo": "bar"}`)
|
||||
assert.NoError(t, err)
|
||||
|
||||
var request requestType
|
||||
var request any
|
||||
diags := body.Unmarshal(&request)
|
||||
assert.NoError(t, diags.Error())
|
||||
assert.Empty(t, diags)
|
||||
|
||||
assert.Equal(t, "JSON (14 bytes)", body.String())
|
||||
assert.Equal(t, requestType{"bar"}, request)
|
||||
assert.Equal(t, map[string]any{"foo": "bar"}, request)
|
||||
}
|
||||
|
||||
func TestJsonFlagError(t *testing.T) {
|
||||
|
@ -50,7 +46,7 @@ func TestJsonFlagError(t *testing.T) {
|
|||
err := body.Set(`{"foo":`)
|
||||
assert.NoError(t, err)
|
||||
|
||||
var request requestType
|
||||
var request any
|
||||
diags := body.Unmarshal(&request)
|
||||
assert.EqualError(t, diags.Error(), "error decoding JSON at (inline):1:8: unexpected end of JSON input")
|
||||
assert.Equal(t, "JSON (7 bytes)", body.String())
|
||||
|
@ -58,7 +54,7 @@ func TestJsonFlagError(t *testing.T) {
|
|||
|
||||
func TestJsonFlagFile(t *testing.T) {
|
||||
var body JsonFlag
|
||||
var request requestType
|
||||
var request any
|
||||
|
||||
var fpath string
|
||||
var payload = []byte(`{"foo": "bar"}`)
|
||||
|
@ -78,7 +74,7 @@ func TestJsonFlagFile(t *testing.T) {
|
|||
assert.NoError(t, diags.Error())
|
||||
assert.Empty(t, diags)
|
||||
|
||||
assert.Equal(t, requestType{"bar"}, request)
|
||||
assert.Equal(t, map[string]any{"foo": "bar"}, request)
|
||||
}
|
||||
|
||||
const jsonData = `
|
||||
|
|
Loading…
Reference in New Issue