2018-10-13 15:53:52 +02:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold
- **Resumable Send & Recv Support**
No knobs required, automatically used where supported.
- **Hold-Protected Send & Recv**
Automatic ZFS holds to ensure that we can always resume a replication step.
- **Encrypted Send & Recv Support** for OpenZFS native encryption.
Configurable at the job level, i.e., for all filesystems a job is responsible for.
- **Receive-side hold on last received dataset**
The counterpart to the replication cursor bookmark on the send-side.
Ensures that incremental replication will always be possible between a sender and receiver.
Design Doc
----------
`replication/design.md` doc describes how we use ZFS holds and bookmarks to ensure that a single replication step is always resumable.
The replication algorithm described in the design doc introduces the notion of job IDs (please read the details on this design doc).
We reuse the job names for job IDs and use `JobID` type to ensure that a job name can be embedded into hold tags, bookmark names, etc.
This might BREAK CONFIG on upgrade.
Protocol Version Bump
---------------------
This commit makes backwards-incompatible changes to the replication/pdu protobufs.
Thus, bump the version number used in the protocol handshake.
Replication Cursor Format Change
--------------------------------
The new replication cursor bookmark format is: `#zrepl_CURSOR_G_${this.GUID}_J_${jobid}`
Including the GUID enables transaction-safe moving-forward of the cursor.
Including the job id enables that multiple sending jobs can send the same filesystem without interfering.
The `zrepl migrate replication-cursor:v1-v2` subcommand can be used to safely destroy old-format cursors once zrepl has created new-format cursors.
Changes in This Commit
----------------------
- package zfs
- infrastructure for holds
- infrastructure for resume token decoding
- implement a variant of OpenZFS's `entity_namecheck` and use it for validation in new code
- ZFSSendArgs to specify a ZFS send operation
- validation code protects against malicious resume tokens by checking that the token encodes the same send parameters that the send-side would use if no resume token were available (i.e. same filesystem, `fromguid`, `toguid`)
- RecvOptions support for `recv -s` flag
- convert a bunch of ZFS operations to be idempotent
- achieved through more differentiated error message scraping / additional pre-/post-checks
- package replication/pdu
- add field for encryption to send request messages
- add fields for resume handling to send & recv request messages
- receive requests now contain `FilesystemVersion To` in addition to the filesystem into which the stream should be `recv`d into
- can use `zfs recv $root_fs/$client_id/path/to/dataset@${To.Name}`, which enables additional validation after recv (i.e. whether `To.Guid` matched what we received in the stream)
- used to set `last-received-hold`
- package replication/logic
- introduce `PlannerPolicy` struct, currently only used to configure whether encrypted sends should be requested from the sender
- integrate encryption and resume token support into `Step` struct
- package endpoint
- move the concepts that endpoint builds on top of ZFS to a single file `endpoint/endpoint_zfs.go`
- step-holds + step-bookmarks
- last-received-hold
- new replication cursor + old replication cursor compat code
- adjust `endpoint/endpoint.go` handlers for
- encryption
- resumability
- new replication cursor
- last-received-hold
- client subcommand `zrepl holds list`: list all holds and hold-like bookmarks that zrepl thinks belong to it
- client subcommand `zrepl migrate replication-cursor:v1-v2`
2019-09-11 17:19:17 +02:00
|
|
|
"context"
|
|
|
|
"encoding/json"
|
2018-10-13 15:53:52 +02:00
|
|
|
"fmt"
|
new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold
- **Resumable Send & Recv Support**
No knobs required, automatically used where supported.
- **Hold-Protected Send & Recv**
Automatic ZFS holds to ensure that we can always resume a replication step.
- **Encrypted Send & Recv Support** for OpenZFS native encryption.
Configurable at the job level, i.e., for all filesystems a job is responsible for.
- **Receive-side hold on last received dataset**
The counterpart to the replication cursor bookmark on the send-side.
Ensures that incremental replication will always be possible between a sender and receiver.
Design Doc
----------
`replication/design.md` doc describes how we use ZFS holds and bookmarks to ensure that a single replication step is always resumable.
The replication algorithm described in the design doc introduces the notion of job IDs (please read the details on this design doc).
We reuse the job names for job IDs and use `JobID` type to ensure that a job name can be embedded into hold tags, bookmark names, etc.
This might BREAK CONFIG on upgrade.
Protocol Version Bump
---------------------
This commit makes backwards-incompatible changes to the replication/pdu protobufs.
Thus, bump the version number used in the protocol handshake.
Replication Cursor Format Change
--------------------------------
The new replication cursor bookmark format is: `#zrepl_CURSOR_G_${this.GUID}_J_${jobid}`
Including the GUID enables transaction-safe moving-forward of the cursor.
Including the job id enables that multiple sending jobs can send the same filesystem without interfering.
The `zrepl migrate replication-cursor:v1-v2` subcommand can be used to safely destroy old-format cursors once zrepl has created new-format cursors.
Changes in This Commit
----------------------
- package zfs
- infrastructure for holds
- infrastructure for resume token decoding
- implement a variant of OpenZFS's `entity_namecheck` and use it for validation in new code
- ZFSSendArgs to specify a ZFS send operation
- validation code protects against malicious resume tokens by checking that the token encodes the same send parameters that the send-side would use if no resume token were available (i.e. same filesystem, `fromguid`, `toguid`)
- RecvOptions support for `recv -s` flag
- convert a bunch of ZFS operations to be idempotent
- achieved through more differentiated error message scraping / additional pre-/post-checks
- package replication/pdu
- add field for encryption to send request messages
- add fields for resume handling to send & recv request messages
- receive requests now contain `FilesystemVersion To` in addition to the filesystem into which the stream should be `recv`d into
- can use `zfs recv $root_fs/$client_id/path/to/dataset@${To.Name}`, which enables additional validation after recv (i.e. whether `To.Guid` matched what we received in the stream)
- used to set `last-received-hold`
- package replication/logic
- introduce `PlannerPolicy` struct, currently only used to configure whether encrypted sends should be requested from the sender
- integrate encryption and resume token support into `Step` struct
- package endpoint
- move the concepts that endpoint builds on top of ZFS to a single file `endpoint/endpoint_zfs.go`
- step-holds + step-bookmarks
- last-received-hold
- new replication cursor + old replication cursor compat code
- adjust `endpoint/endpoint.go` handlers for
- encryption
- resumability
- new replication cursor
- last-received-hold
- client subcommand `zrepl holds list`: list all holds and hold-like bookmarks that zrepl thinks belong to it
- client subcommand `zrepl migrate replication-cursor:v1-v2`
2019-09-11 17:19:17 +02:00
|
|
|
"os"
|
2019-03-22 19:41:12 +01:00
|
|
|
|
2018-11-16 11:25:48 +01:00
|
|
|
"github.com/pkg/errors"
|
2018-10-13 15:53:52 +02:00
|
|
|
"github.com/spf13/pflag"
|
2019-03-22 19:41:12 +01:00
|
|
|
|
2018-10-13 15:53:52 +02:00
|
|
|
"github.com/zrepl/zrepl/cli"
|
|
|
|
"github.com/zrepl/zrepl/config"
|
|
|
|
"github.com/zrepl/zrepl/daemon/filters"
|
|
|
|
"github.com/zrepl/zrepl/zfs"
|
|
|
|
)
|
|
|
|
|
2019-03-22 19:41:12 +01:00
|
|
|
var TestCmd = &cli.Subcommand{
|
2018-10-13 15:53:52 +02:00
|
|
|
Use: "test",
|
|
|
|
SetupSubcommands: func() []*cli.Subcommand {
|
new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold
- **Resumable Send & Recv Support**
No knobs required, automatically used where supported.
- **Hold-Protected Send & Recv**
Automatic ZFS holds to ensure that we can always resume a replication step.
- **Encrypted Send & Recv Support** for OpenZFS native encryption.
Configurable at the job level, i.e., for all filesystems a job is responsible for.
- **Receive-side hold on last received dataset**
The counterpart to the replication cursor bookmark on the send-side.
Ensures that incremental replication will always be possible between a sender and receiver.
Design Doc
----------
`replication/design.md` doc describes how we use ZFS holds and bookmarks to ensure that a single replication step is always resumable.
The replication algorithm described in the design doc introduces the notion of job IDs (please read the details on this design doc).
We reuse the job names for job IDs and use `JobID` type to ensure that a job name can be embedded into hold tags, bookmark names, etc.
This might BREAK CONFIG on upgrade.
Protocol Version Bump
---------------------
This commit makes backwards-incompatible changes to the replication/pdu protobufs.
Thus, bump the version number used in the protocol handshake.
Replication Cursor Format Change
--------------------------------
The new replication cursor bookmark format is: `#zrepl_CURSOR_G_${this.GUID}_J_${jobid}`
Including the GUID enables transaction-safe moving-forward of the cursor.
Including the job id enables that multiple sending jobs can send the same filesystem without interfering.
The `zrepl migrate replication-cursor:v1-v2` subcommand can be used to safely destroy old-format cursors once zrepl has created new-format cursors.
Changes in This Commit
----------------------
- package zfs
- infrastructure for holds
- infrastructure for resume token decoding
- implement a variant of OpenZFS's `entity_namecheck` and use it for validation in new code
- ZFSSendArgs to specify a ZFS send operation
- validation code protects against malicious resume tokens by checking that the token encodes the same send parameters that the send-side would use if no resume token were available (i.e. same filesystem, `fromguid`, `toguid`)
- RecvOptions support for `recv -s` flag
- convert a bunch of ZFS operations to be idempotent
- achieved through more differentiated error message scraping / additional pre-/post-checks
- package replication/pdu
- add field for encryption to send request messages
- add fields for resume handling to send & recv request messages
- receive requests now contain `FilesystemVersion To` in addition to the filesystem into which the stream should be `recv`d into
- can use `zfs recv $root_fs/$client_id/path/to/dataset@${To.Name}`, which enables additional validation after recv (i.e. whether `To.Guid` matched what we received in the stream)
- used to set `last-received-hold`
- package replication/logic
- introduce `PlannerPolicy` struct, currently only used to configure whether encrypted sends should be requested from the sender
- integrate encryption and resume token support into `Step` struct
- package endpoint
- move the concepts that endpoint builds on top of ZFS to a single file `endpoint/endpoint_zfs.go`
- step-holds + step-bookmarks
- last-received-hold
- new replication cursor + old replication cursor compat code
- adjust `endpoint/endpoint.go` handlers for
- encryption
- resumability
- new replication cursor
- last-received-hold
- client subcommand `zrepl holds list`: list all holds and hold-like bookmarks that zrepl thinks belong to it
- client subcommand `zrepl migrate replication-cursor:v1-v2`
2019-09-11 17:19:17 +02:00
|
|
|
return []*cli.Subcommand{testFilter, testPlaceholder, testDecodeResumeToken}
|
2018-10-13 15:53:52 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var testFilterArgs struct {
|
2019-03-22 19:41:12 +01:00
|
|
|
job string
|
|
|
|
all bool
|
2018-10-13 15:53:52 +02:00
|
|
|
input string
|
|
|
|
}
|
|
|
|
|
|
|
|
var testFilter = &cli.Subcommand{
|
2019-03-22 19:41:12 +01:00
|
|
|
Use: "filesystems --job JOB [--all | --input INPUT]",
|
2018-10-13 15:53:52 +02:00
|
|
|
Short: "test filesystems filter specified in push or source job",
|
|
|
|
SetupFlags: func(f *pflag.FlagSet) {
|
|
|
|
f.StringVar(&testFilterArgs.job, "job", "", "the name of the push or source job")
|
|
|
|
f.StringVar(&testFilterArgs.input, "input", "", "a filesystem name to test against the job's filters")
|
|
|
|
f.BoolVar(&testFilterArgs.all, "all", false, "test all local filesystems")
|
|
|
|
},
|
|
|
|
Run: runTestFilterCmd,
|
|
|
|
}
|
|
|
|
|
|
|
|
func runTestFilterCmd(subcommand *cli.Subcommand, args []string) error {
|
|
|
|
|
|
|
|
if testFilterArgs.job == "" {
|
|
|
|
return fmt.Errorf("must specify --job flag")
|
|
|
|
}
|
|
|
|
if !(testFilterArgs.all != (testFilterArgs.input != "")) { // xor
|
|
|
|
return fmt.Errorf("must set one: --all or --input")
|
|
|
|
}
|
|
|
|
|
|
|
|
conf := subcommand.Config()
|
2020-03-27 00:57:33 +01:00
|
|
|
ctx := context.Background()
|
2018-10-13 15:53:52 +02:00
|
|
|
|
|
|
|
var confFilter config.FilesystemsFilter
|
|
|
|
job, err := conf.Job(testFilterArgs.job)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
switch j := job.Ret.(type) {
|
2019-03-22 19:41:12 +01:00
|
|
|
case *config.SourceJob:
|
|
|
|
confFilter = j.Filesystems
|
|
|
|
case *config.PushJob:
|
|
|
|
confFilter = j.Filesystems
|
2020-02-17 17:56:48 +01:00
|
|
|
case *config.SnapJob:
|
|
|
|
confFilter = j.Filesystems
|
2018-10-13 15:53:52 +02:00
|
|
|
default:
|
|
|
|
return fmt.Errorf("job type %T does not have filesystems filter", j)
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err := filters.DatasetMapFilterFromConfig(confFilter)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("filter invalid: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var fsnames []string
|
|
|
|
if testFilterArgs.input != "" {
|
|
|
|
fsnames = []string{testFilterArgs.input}
|
|
|
|
} else {
|
2020-03-27 00:57:33 +01:00
|
|
|
out, err := zfs.ZFSList(ctx, []string{"name"})
|
2018-10-13 15:53:52 +02:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("could not list ZFS filesystems: %s", err)
|
|
|
|
}
|
|
|
|
for _, row := range out {
|
|
|
|
|
|
|
|
fsnames = append(fsnames, row[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fspaths := make([]*zfs.DatasetPath, len(fsnames))
|
|
|
|
for i, fsname := range fsnames {
|
|
|
|
path, err := zfs.NewDatasetPath(fsname)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
fspaths[i] = path
|
|
|
|
}
|
|
|
|
|
|
|
|
hadFilterErr := false
|
|
|
|
for _, in := range fspaths {
|
|
|
|
var res string
|
|
|
|
var errStr string
|
|
|
|
pass, err := f.Filter(in)
|
|
|
|
if err != nil {
|
|
|
|
res = "ERROR"
|
|
|
|
errStr = err.Error()
|
|
|
|
hadFilterErr = true
|
|
|
|
} else if pass {
|
|
|
|
res = "ACCEPT"
|
|
|
|
} else {
|
|
|
|
res = "REJECT"
|
|
|
|
}
|
|
|
|
fmt.Printf("%s\t%s\t%s\n", res, in.ToString(), errStr)
|
|
|
|
}
|
|
|
|
|
|
|
|
if hadFilterErr {
|
|
|
|
return fmt.Errorf("filter errors occurred")
|
|
|
|
}
|
|
|
|
return nil
|
2018-11-16 11:25:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var testPlaceholderArgs struct {
|
2019-03-22 20:45:27 +01:00
|
|
|
ds string
|
|
|
|
all bool
|
2018-11-16 11:25:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var testPlaceholder = &cli.Subcommand{
|
2019-03-19 17:43:28 +01:00
|
|
|
Use: "placeholder [--all | --dataset DATASET]",
|
|
|
|
Short: fmt.Sprintf("list received placeholder filesystems (zfs property %q)", zfs.PlaceholderPropertyName),
|
2018-11-16 11:25:48 +01:00
|
|
|
Example: `
|
|
|
|
placeholder --all
|
2019-03-19 17:43:28 +01:00
|
|
|
placeholder --dataset path/to/sink/clientident/fs`,
|
2018-11-16 11:25:48 +01:00
|
|
|
NoRequireConfig: true,
|
|
|
|
SetupFlags: func(f *pflag.FlagSet) {
|
|
|
|
f.StringVar(&testPlaceholderArgs.ds, "dataset", "", "dataset path (not required to exist)")
|
|
|
|
f.BoolVar(&testPlaceholderArgs.all, "all", false, "list tab-separated placeholder status of all filesystems")
|
|
|
|
},
|
|
|
|
Run: runTestPlaceholder,
|
|
|
|
}
|
|
|
|
|
|
|
|
func runTestPlaceholder(subcommand *cli.Subcommand, args []string) error {
|
|
|
|
|
2019-03-19 17:43:28 +01:00
|
|
|
var checkDPs []*zfs.DatasetPath
|
2020-03-27 00:57:33 +01:00
|
|
|
ctx := context.Background()
|
2019-03-19 17:43:28 +01:00
|
|
|
|
2018-11-16 11:25:48 +01:00
|
|
|
// all actions first
|
|
|
|
if testPlaceholderArgs.all {
|
2020-03-27 00:57:33 +01:00
|
|
|
out, err := zfs.ZFSList(ctx, []string{"name"})
|
2018-11-16 11:25:48 +01:00
|
|
|
if err != nil {
|
|
|
|
return errors.Wrap(err, "could not list ZFS filesystems")
|
|
|
|
}
|
|
|
|
for _, row := range out {
|
|
|
|
dp, err := zfs.NewDatasetPath(row[0])
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-03-19 17:43:28 +01:00
|
|
|
checkDPs = append(checkDPs, dp)
|
2018-11-16 11:25:48 +01:00
|
|
|
}
|
2019-03-19 17:43:28 +01:00
|
|
|
} else {
|
|
|
|
dp, err := zfs.NewDatasetPath(testPlaceholderArgs.ds)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if dp.Empty() {
|
|
|
|
return fmt.Errorf("must specify --dataset DATASET or --all")
|
|
|
|
}
|
|
|
|
checkDPs = append(checkDPs, dp)
|
2018-11-16 11:25:48 +01:00
|
|
|
}
|
|
|
|
|
2019-03-19 17:43:28 +01:00
|
|
|
fmt.Printf("IS_PLACEHOLDER\tDATASET\tzrepl:placeholder\n")
|
|
|
|
for _, dp := range checkDPs {
|
2020-03-27 00:57:33 +01:00
|
|
|
ph, err := zfs.ZFSGetFilesystemPlaceholderState(ctx, dp)
|
2019-03-19 17:43:28 +01:00
|
|
|
if err != nil {
|
|
|
|
return errors.Wrap(err, "cannot get placeholder state")
|
2018-11-16 11:25:48 +01:00
|
|
|
}
|
2019-03-19 17:43:28 +01:00
|
|
|
if !ph.FSExists {
|
|
|
|
panic("placeholder state inconsistent: filesystem " + ph.FS + " must exist in this context")
|
|
|
|
}
|
|
|
|
is := "yes"
|
|
|
|
if !ph.IsPlaceholder {
|
|
|
|
is = "no"
|
2018-11-16 11:25:48 +01:00
|
|
|
}
|
2019-03-19 17:43:28 +01:00
|
|
|
fmt.Printf("%s\t%s\t%s\n", is, dp.ToString(), ph.RawLocalPropertyValue)
|
2018-11-16 11:25:48 +01:00
|
|
|
}
|
2019-03-19 17:43:28 +01:00
|
|
|
return nil
|
2018-11-16 11:25:48 +01:00
|
|
|
}
|
new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold
- **Resumable Send & Recv Support**
No knobs required, automatically used where supported.
- **Hold-Protected Send & Recv**
Automatic ZFS holds to ensure that we can always resume a replication step.
- **Encrypted Send & Recv Support** for OpenZFS native encryption.
Configurable at the job level, i.e., for all filesystems a job is responsible for.
- **Receive-side hold on last received dataset**
The counterpart to the replication cursor bookmark on the send-side.
Ensures that incremental replication will always be possible between a sender and receiver.
Design Doc
----------
`replication/design.md` doc describes how we use ZFS holds and bookmarks to ensure that a single replication step is always resumable.
The replication algorithm described in the design doc introduces the notion of job IDs (please read the details on this design doc).
We reuse the job names for job IDs and use `JobID` type to ensure that a job name can be embedded into hold tags, bookmark names, etc.
This might BREAK CONFIG on upgrade.
Protocol Version Bump
---------------------
This commit makes backwards-incompatible changes to the replication/pdu protobufs.
Thus, bump the version number used in the protocol handshake.
Replication Cursor Format Change
--------------------------------
The new replication cursor bookmark format is: `#zrepl_CURSOR_G_${this.GUID}_J_${jobid}`
Including the GUID enables transaction-safe moving-forward of the cursor.
Including the job id enables that multiple sending jobs can send the same filesystem without interfering.
The `zrepl migrate replication-cursor:v1-v2` subcommand can be used to safely destroy old-format cursors once zrepl has created new-format cursors.
Changes in This Commit
----------------------
- package zfs
- infrastructure for holds
- infrastructure for resume token decoding
- implement a variant of OpenZFS's `entity_namecheck` and use it for validation in new code
- ZFSSendArgs to specify a ZFS send operation
- validation code protects against malicious resume tokens by checking that the token encodes the same send parameters that the send-side would use if no resume token were available (i.e. same filesystem, `fromguid`, `toguid`)
- RecvOptions support for `recv -s` flag
- convert a bunch of ZFS operations to be idempotent
- achieved through more differentiated error message scraping / additional pre-/post-checks
- package replication/pdu
- add field for encryption to send request messages
- add fields for resume handling to send & recv request messages
- receive requests now contain `FilesystemVersion To` in addition to the filesystem into which the stream should be `recv`d into
- can use `zfs recv $root_fs/$client_id/path/to/dataset@${To.Name}`, which enables additional validation after recv (i.e. whether `To.Guid` matched what we received in the stream)
- used to set `last-received-hold`
- package replication/logic
- introduce `PlannerPolicy` struct, currently only used to configure whether encrypted sends should be requested from the sender
- integrate encryption and resume token support into `Step` struct
- package endpoint
- move the concepts that endpoint builds on top of ZFS to a single file `endpoint/endpoint_zfs.go`
- step-holds + step-bookmarks
- last-received-hold
- new replication cursor + old replication cursor compat code
- adjust `endpoint/endpoint.go` handlers for
- encryption
- resumability
- new replication cursor
- last-received-hold
- client subcommand `zrepl holds list`: list all holds and hold-like bookmarks that zrepl thinks belong to it
- client subcommand `zrepl migrate replication-cursor:v1-v2`
2019-09-11 17:19:17 +02:00
|
|
|
|
|
|
|
var testDecodeResumeTokenArgs struct {
|
|
|
|
token string
|
|
|
|
}
|
|
|
|
|
|
|
|
var testDecodeResumeToken = &cli.Subcommand{
|
|
|
|
Use: "decoderesumetoken --token TOKEN",
|
|
|
|
Short: "decode resume token",
|
|
|
|
SetupFlags: func(f *pflag.FlagSet) {
|
|
|
|
f.StringVar(&testDecodeResumeTokenArgs.token, "token", "", "the resume token obtained from the receive_resume_token property")
|
|
|
|
},
|
|
|
|
Run: runTestDecodeResumeTokenCmd,
|
|
|
|
}
|
|
|
|
|
|
|
|
func runTestDecodeResumeTokenCmd(subcommand *cli.Subcommand, args []string) error {
|
|
|
|
if testDecodeResumeTokenArgs.token == "" {
|
|
|
|
return fmt.Errorf("token argument must be specified")
|
|
|
|
}
|
|
|
|
token, err := zfs.ParseResumeToken(context.Background(), testDecodeResumeTokenArgs.token)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
enc := json.NewEncoder(os.Stdout)
|
|
|
|
enc.SetIndent("", " ")
|
|
|
|
if err := enc.Encode(&token); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|