mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-28 05:00:08 +00:00
ipn/store, feature/condregister: permit callers to empty import optonal ipn stores
This permits other programs (in other repos) to conditionally import ipn/store/awsstore and/or ipn/store/kubestore and have them register themselves, rather than feature/condregister doing it. Updates tailscale/corp#32922 Change-Id: I2936229ce37fd2acf9be5bf5254d4a262d090ec1 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
ebc370e517
commit
91fa51ca15
@@ -5,19 +5,4 @@
|
|||||||
|
|
||||||
package condregister
|
package condregister
|
||||||
|
|
||||||
import (
|
import _ "tailscale.com/ipn/store/awsstore"
|
||||||
"tailscale.com/ipn"
|
|
||||||
"tailscale.com/ipn/store"
|
|
||||||
"tailscale.com/ipn/store/awsstore"
|
|
||||||
"tailscale.com/types/logger"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
store.Register("arn:", func(logf logger.Logf, arg string) (ipn.StateStore, error) {
|
|
||||||
ssmARN, opts, err := awsstore.ParseARNAndOpts(arg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return awsstore.New(logf, ssmARN, opts...)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,18 +5,4 @@
|
|||||||
|
|
||||||
package condregister
|
package condregister
|
||||||
|
|
||||||
import (
|
import _ "tailscale.com/ipn/store/kubestore"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"tailscale.com/ipn"
|
|
||||||
"tailscale.com/ipn/store"
|
|
||||||
"tailscale.com/ipn/store/kubestore"
|
|
||||||
"tailscale.com/types/logger"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
store.Register("kube:", func(logf logger.Logf, path string) (ipn.StateStore, error) {
|
|
||||||
secretName := strings.TrimPrefix(path, "kube:")
|
|
||||||
return kubestore.New(logf, secretName)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) Tailscale Inc & AUTHORS
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
//go:build linux && !ts_omit_aws
|
//go:build !ts_omit_aws
|
||||||
|
|
||||||
// Package awsstore contains an ipn.StateStore implementation using AWS SSM.
|
// Package awsstore contains an ipn.StateStore implementation using AWS SSM.
|
||||||
package awsstore
|
package awsstore
|
||||||
@@ -20,10 +20,21 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go-v2/service/ssm"
|
"github.com/aws/aws-sdk-go-v2/service/ssm"
|
||||||
ssmTypes "github.com/aws/aws-sdk-go-v2/service/ssm/types"
|
ssmTypes "github.com/aws/aws-sdk-go-v2/service/ssm/types"
|
||||||
"tailscale.com/ipn"
|
"tailscale.com/ipn"
|
||||||
|
"tailscale.com/ipn/store"
|
||||||
"tailscale.com/ipn/store/mem"
|
"tailscale.com/ipn/store/mem"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
store.Register("arn:", func(logf logger.Logf, arg string) (ipn.StateStore, error) {
|
||||||
|
ssmARN, opts, err := ParseARNAndOpts(arg)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return New(logf, ssmARN, opts...)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
parameterNameRxStr = `^parameter(/.*)`
|
parameterNameRxStr = `^parameter(/.*)`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) Tailscale Inc & AUTHORS
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
//go:build linux && !ts_omit_aws
|
//go:build !ts_omit_aws
|
||||||
|
|
||||||
package awsstore
|
package awsstore
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
|
|
||||||
"tailscale.com/envknob"
|
"tailscale.com/envknob"
|
||||||
"tailscale.com/ipn"
|
"tailscale.com/ipn"
|
||||||
|
"tailscale.com/ipn/store"
|
||||||
"tailscale.com/ipn/store/mem"
|
"tailscale.com/ipn/store/mem"
|
||||||
"tailscale.com/kube/kubeapi"
|
"tailscale.com/kube/kubeapi"
|
||||||
"tailscale.com/kube/kubeclient"
|
"tailscale.com/kube/kubeclient"
|
||||||
@@ -25,6 +26,13 @@ import (
|
|||||||
"tailscale.com/util/mak"
|
"tailscale.com/util/mak"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
store.Register("kube:", func(logf logger.Logf, path string) (ipn.StateStore, error) {
|
||||||
|
secretName := strings.TrimPrefix(path, "kube:")
|
||||||
|
return New(logf, secretName)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// timeout is the timeout for a single state update that includes calls to the API server to write or read a
|
// timeout is the timeout for a single state update that includes calls to the API server to write or read a
|
||||||
// state Secret and emit an Event.
|
// state Secret and emit an Event.
|
||||||
|
|||||||
Reference in New Issue
Block a user