mirror of https://github.com/hashicorp/boundary
parent
444af9151c
commit
47477e8fd6
@ -0,0 +1,20 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package convert
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/bsr"
|
||||
"github.com/hashicorp/boundary/internal/storage"
|
||||
)
|
||||
|
||||
// ToAsciinema accepts a bsr.Session and will convert the underlying BSR connection or channel file to an asciinema file.
|
||||
// The tempFs will be used to write the asciinema file to disk
|
||||
// It returns an io.Reader to the converted asciinema file
|
||||
// Supports WithChannelId() to indicate this conversion should occur on a chanel on a multiplexed session
|
||||
func ToAsciinema(ctx context.Context, session bsr.Session, tempFs storage.FS, connectionId string, options ...Option) (io.Reader, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package convert
|
||||
|
||||
// getOpts - iterate the inbound Options and return a struct
|
||||
func getOpts(opt ...Option) options {
|
||||
opts := getDefaultOptions()
|
||||
for _, o := range opt {
|
||||
o(&opts)
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
// Option - how Options are passed as arguments
|
||||
type Option func(*options)
|
||||
|
||||
// options = how options are represented
|
||||
type options struct {
|
||||
withChannelId string
|
||||
}
|
||||
|
||||
func getDefaultOptions() options {
|
||||
return options{}
|
||||
}
|
||||
|
||||
// WithChannelId provides and option to specify the channelId
|
||||
func WithChannelId(id string) Option {
|
||||
return func(o *options) {
|
||||
o.withChannelId = id
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package convert
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Test_GetOpts provides unit tests for GetOpts and all the options
|
||||
func Test_GetOpts(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("WithChannelId", func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
channelId := "channel-id"
|
||||
opts := getOpts(WithChannelId(channelId))
|
||||
testOpts := getDefaultOptions()
|
||||
testOpts.withChannelId = channelId
|
||||
assert.Equal(opts, testOpts)
|
||||
})
|
||||
}
|
||||
Loading…
Reference in new issue