mirror of https://github.com/databricks/cli.git
merge
This commit is contained in:
commit
88590a9db0
12
README.md
12
README.md
|
@ -15,6 +15,18 @@ See https://github.com/databricks/cli/releases for releases and
|
|||
[the docs pages](https://docs.databricks.com/dev-tools/cli/databricks-cli.html) for
|
||||
installation instructions.
|
||||
|
||||
------
|
||||
You can use the CLI via a Docker image by pulling the image from `ghcr.io`. You can find all available versions
|
||||
at: https://github.com/databricks/cli/pkgs/container/cli.
|
||||
```
|
||||
docker pull ghcr.io/databricks/cli:latest
|
||||
```
|
||||
|
||||
Example of how to run the CLI using the Docker image. More documentation is available at https://docs.databricks.com/dev-tools/bundles/airgapped-environment.html.
|
||||
```
|
||||
docker run -e DATABRICKS_HOST=$YOUR_HOST_URL -e DATABRICKS_TOKEN=$YOUR_TOKEN ghcr.io/databricks/cli:latest current-user me
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
This CLI follows the Databricks Unified Authentication principles.
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// This test ensures that all resources have a custom marshaller and unmarshaller.
|
||||
// This is required because DABs resources map to Databricks APIs, and they do so
|
||||
// by embedding the corresponding Go SDK structs.
|
||||
//
|
||||
// Go SDK structs often implement custom marshalling and unmarshalling methods (based on the API specifics).
|
||||
// If the Go SDK struct implements custom marshalling and unmarshalling and we do not
|
||||
// for the resources at the top level, marshalling and unmarshalling operations will panic.
|
||||
// Thus we will be overly cautious and ensure that all resources need a custom marshaller and unmarshaller.
|
||||
//
|
||||
// Why do we not assert this using an interface to assert MarshalJSON and UnmarshalJSON
|
||||
// are implemented at the top level?
|
||||
// If a method is implemented for an embedded struct, the top level struct will
|
||||
// also have that method and satisfy the interface. This is why we cannot assert
|
||||
// that the methods are implemented at the top level using an interface.
|
||||
//
|
||||
// Why don't we use reflection to assert that the methods are implemented at the
|
||||
// top level?
|
||||
// Same problem as above, the golang reflection package does not seem to provide
|
||||
// a way to directly assert that MarshalJSON and UnmarshalJSON are implemented
|
||||
// at the top level.
|
||||
func TestCustomMarshallerIsImplemented(t *testing.T) {
|
||||
r := Resources{}
|
||||
rt := reflect.TypeOf(r)
|
||||
|
||||
for i := 0; i < rt.NumField(); i++ {
|
||||
field := rt.Field(i)
|
||||
|
||||
// Fields in Resources are expected be of the form map[string]*resourceStruct
|
||||
assert.Equal(t, field.Type.Kind(), reflect.Map, "Resource %s is not a map", field.Name)
|
||||
kt := field.Type.Key()
|
||||
assert.Equal(t, kt.Kind(), reflect.String, "Resource %s is not a map with string keys", field.Name)
|
||||
vt := field.Type.Elem()
|
||||
assert.Equal(t, vt.Kind(), reflect.Ptr, "Resource %s is not a map with pointer values", field.Name)
|
||||
|
||||
// Marshalling a resourceStruct will panic if resourceStruct does not have a custom marshaller
|
||||
// This is because resourceStruct embeds a Go SDK struct that implements
|
||||
// a custom marshaller.
|
||||
// Eg: resource.Job implements MarshalJSON
|
||||
v := reflect.Zero(vt.Elem()).Interface()
|
||||
assert.NotPanics(t, func() {
|
||||
json.Marshal(v)
|
||||
}, "Resource %s does not have a custom marshaller", field.Name)
|
||||
|
||||
// Unmarshalling a *resourceStruct will panic if the resource does not have a custom unmarshaller
|
||||
// This is because resourceStruct embeds a Go SDK struct that implements
|
||||
// a custom unmarshaller.
|
||||
// Eg: *resource.Job implements UnmarshalJSON
|
||||
v = reflect.New(vt.Elem()).Interface()
|
||||
assert.NotPanics(t, func() {
|
||||
json.Unmarshal([]byte("{}"), v)
|
||||
}, "Resource %s does not have a custom unmarshaller", field.Name)
|
||||
}
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
package schema
|
||||
|
||||
const ProviderVersion = "1.40.0"
|
||||
const ProviderVersion = "1.43.0"
|
||||
|
|
|
@ -243,12 +243,13 @@ type DataSourceJobJobSettingsSettingsLibraryPypi struct {
|
|||
}
|
||||
|
||||
type DataSourceJobJobSettingsSettingsLibrary struct {
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *DataSourceJobJobSettingsSettingsLibraryCran `json:"cran,omitempty"`
|
||||
Maven *DataSourceJobJobSettingsSettingsLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *DataSourceJobJobSettingsSettingsLibraryPypi `json:"pypi,omitempty"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Requirements string `json:"requirements,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *DataSourceJobJobSettingsSettingsLibraryCran `json:"cran,omitempty"`
|
||||
Maven *DataSourceJobJobSettingsSettingsLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *DataSourceJobJobSettingsSettingsLibraryPypi `json:"pypi,omitempty"`
|
||||
}
|
||||
|
||||
type DataSourceJobJobSettingsSettingsNewClusterAutoscale struct {
|
||||
|
@ -558,12 +559,13 @@ type DataSourceJobJobSettingsSettingsTaskForEachTaskTaskLibraryPypi struct {
|
|||
}
|
||||
|
||||
type DataSourceJobJobSettingsSettingsTaskForEachTaskTaskLibrary struct {
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *DataSourceJobJobSettingsSettingsTaskForEachTaskTaskLibraryCran `json:"cran,omitempty"`
|
||||
Maven *DataSourceJobJobSettingsSettingsTaskForEachTaskTaskLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *DataSourceJobJobSettingsSettingsTaskForEachTaskTaskLibraryPypi `json:"pypi,omitempty"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Requirements string `json:"requirements,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *DataSourceJobJobSettingsSettingsTaskForEachTaskTaskLibraryCran `json:"cran,omitempty"`
|
||||
Maven *DataSourceJobJobSettingsSettingsTaskForEachTaskTaskLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *DataSourceJobJobSettingsSettingsTaskForEachTaskTaskLibraryPypi `json:"pypi,omitempty"`
|
||||
}
|
||||
|
||||
type DataSourceJobJobSettingsSettingsTaskForEachTaskTaskNewClusterAutoscale struct {
|
||||
|
@ -896,12 +898,13 @@ type DataSourceJobJobSettingsSettingsTaskLibraryPypi struct {
|
|||
}
|
||||
|
||||
type DataSourceJobJobSettingsSettingsTaskLibrary struct {
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *DataSourceJobJobSettingsSettingsTaskLibraryCran `json:"cran,omitempty"`
|
||||
Maven *DataSourceJobJobSettingsSettingsTaskLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *DataSourceJobJobSettingsSettingsTaskLibraryPypi `json:"pypi,omitempty"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Requirements string `json:"requirements,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *DataSourceJobJobSettingsSettingsTaskLibraryCran `json:"cran,omitempty"`
|
||||
Maven *DataSourceJobJobSettingsSettingsTaskLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *DataSourceJobJobSettingsSettingsTaskLibraryPypi `json:"pypi,omitempty"`
|
||||
}
|
||||
|
||||
type DataSourceJobJobSettingsSettingsTaskNewClusterAutoscale struct {
|
||||
|
|
|
@ -146,12 +146,13 @@ type ResourceClusterLibraryPypi struct {
|
|||
}
|
||||
|
||||
type ResourceClusterLibrary struct {
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceClusterLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceClusterLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceClusterLibraryPypi `json:"pypi,omitempty"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Requirements string `json:"requirements,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceClusterLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceClusterLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceClusterLibraryPypi `json:"pypi,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceClusterWorkloadTypeClients struct {
|
||||
|
|
|
@ -19,12 +19,13 @@ type ResourceClusterPolicyLibrariesPypi struct {
|
|||
}
|
||||
|
||||
type ResourceClusterPolicyLibraries struct {
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceClusterPolicyLibrariesCran `json:"cran,omitempty"`
|
||||
Maven *ResourceClusterPolicyLibrariesMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceClusterPolicyLibrariesPypi `json:"pypi,omitempty"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Requirements string `json:"requirements,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceClusterPolicyLibrariesCran `json:"cran,omitempty"`
|
||||
Maven *ResourceClusterPolicyLibrariesMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceClusterPolicyLibrariesPypi `json:"pypi,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceClusterPolicy struct {
|
||||
|
|
|
@ -243,12 +243,13 @@ type ResourceJobLibraryPypi struct {
|
|||
}
|
||||
|
||||
type ResourceJobLibrary struct {
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceJobLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceJobLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceJobLibraryPypi `json:"pypi,omitempty"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Requirements string `json:"requirements,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceJobLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceJobLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceJobLibraryPypi `json:"pypi,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceJobNewClusterAutoscale struct {
|
||||
|
@ -558,12 +559,13 @@ type ResourceJobTaskForEachTaskTaskLibraryPypi struct {
|
|||
}
|
||||
|
||||
type ResourceJobTaskForEachTaskTaskLibrary struct {
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceJobTaskForEachTaskTaskLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceJobTaskForEachTaskTaskLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceJobTaskForEachTaskTaskLibraryPypi `json:"pypi,omitempty"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Requirements string `json:"requirements,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceJobTaskForEachTaskTaskLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceJobTaskForEachTaskTaskLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceJobTaskForEachTaskTaskLibraryPypi `json:"pypi,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceJobTaskForEachTaskTaskNewClusterAutoscale struct {
|
||||
|
@ -896,12 +898,13 @@ type ResourceJobTaskLibraryPypi struct {
|
|||
}
|
||||
|
||||
type ResourceJobTaskLibrary struct {
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceJobTaskLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceJobTaskLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceJobTaskLibraryPypi `json:"pypi,omitempty"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Requirements string `json:"requirements,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceJobTaskLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceJobTaskLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceJobTaskLibraryPypi `json:"pypi,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceJobTaskNewClusterAutoscale struct {
|
||||
|
|
|
@ -19,12 +19,13 @@ type ResourceLibraryPypi struct {
|
|||
}
|
||||
|
||||
type ResourceLibrary struct {
|
||||
ClusterId string `json:"cluster_id"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Id string `json:"id,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceLibraryPypi `json:"pypi,omitempty"`
|
||||
ClusterId string `json:"cluster_id"`
|
||||
Egg string `json:"egg,omitempty"`
|
||||
Id string `json:"id,omitempty"`
|
||||
Jar string `json:"jar,omitempty"`
|
||||
Requirements string `json:"requirements,omitempty"`
|
||||
Whl string `json:"whl,omitempty"`
|
||||
Cran *ResourceLibraryCran `json:"cran,omitempty"`
|
||||
Maven *ResourceLibraryMaven `json:"maven,omitempty"`
|
||||
Pypi *ResourceLibraryPypi `json:"pypi,omitempty"`
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// Generated from Databricks Terraform provider schema. DO NOT EDIT.
|
||||
|
||||
package schema
|
||||
|
||||
type ResourceMwsNccBinding struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
NetworkConnectivityConfigId string `json:"network_connectivity_config_id"`
|
||||
WorkspaceId int `json:"workspace_id"`
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
// Generated from Databricks Terraform provider schema. DO NOT EDIT.
|
||||
|
||||
package schema
|
||||
|
||||
type ResourceMwsNccPrivateEndpointRule struct {
|
||||
ConnectionState string `json:"connection_state,omitempty"`
|
||||
CreationTime int `json:"creation_time,omitempty"`
|
||||
Deactivated bool `json:"deactivated,omitempty"`
|
||||
DeactivatedAt int `json:"deactivated_at,omitempty"`
|
||||
EndpointName string `json:"endpoint_name,omitempty"`
|
||||
GroupId string `json:"group_id"`
|
||||
Id string `json:"id,omitempty"`
|
||||
NetworkConnectivityConfigId string `json:"network_connectivity_config_id"`
|
||||
ResourceId string `json:"resource_id"`
|
||||
RuleId string `json:"rule_id,omitempty"`
|
||||
UpdatedTime int `json:"updated_time,omitempty"`
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
// Generated from Databricks Terraform provider schema. DO NOT EDIT.
|
||||
|
||||
package schema
|
||||
|
||||
type ResourceMwsNetworkConnectivityConfigEgressConfigDefaultRulesAwsStableIpRule struct {
|
||||
CidrBlocks []string `json:"cidr_blocks,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceMwsNetworkConnectivityConfigEgressConfigDefaultRulesAzureServiceEndpointRule struct {
|
||||
Subnets []string `json:"subnets,omitempty"`
|
||||
TargetRegion string `json:"target_region,omitempty"`
|
||||
TargetServices []string `json:"target_services,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceMwsNetworkConnectivityConfigEgressConfigDefaultRules struct {
|
||||
AwsStableIpRule *ResourceMwsNetworkConnectivityConfigEgressConfigDefaultRulesAwsStableIpRule `json:"aws_stable_ip_rule,omitempty"`
|
||||
AzureServiceEndpointRule *ResourceMwsNetworkConnectivityConfigEgressConfigDefaultRulesAzureServiceEndpointRule `json:"azure_service_endpoint_rule,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceMwsNetworkConnectivityConfigEgressConfigTargetRulesAzurePrivateEndpointRules struct {
|
||||
ConnectionState string `json:"connection_state,omitempty"`
|
||||
CreationTime int `json:"creation_time,omitempty"`
|
||||
Deactivated bool `json:"deactivated,omitempty"`
|
||||
DeactivatedAt int `json:"deactivated_at,omitempty"`
|
||||
EndpointName string `json:"endpoint_name,omitempty"`
|
||||
GroupId string `json:"group_id,omitempty"`
|
||||
NetworkConnectivityConfigId string `json:"network_connectivity_config_id,omitempty"`
|
||||
ResourceId string `json:"resource_id,omitempty"`
|
||||
RuleId string `json:"rule_id,omitempty"`
|
||||
UpdatedTime int `json:"updated_time,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceMwsNetworkConnectivityConfigEgressConfigTargetRules struct {
|
||||
AzurePrivateEndpointRules []ResourceMwsNetworkConnectivityConfigEgressConfigTargetRulesAzurePrivateEndpointRules `json:"azure_private_endpoint_rules,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceMwsNetworkConnectivityConfigEgressConfig struct {
|
||||
DefaultRules *ResourceMwsNetworkConnectivityConfigEgressConfigDefaultRules `json:"default_rules,omitempty"`
|
||||
TargetRules *ResourceMwsNetworkConnectivityConfigEgressConfigTargetRules `json:"target_rules,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceMwsNetworkConnectivityConfig struct {
|
||||
AccountId string `json:"account_id,omitempty"`
|
||||
CreationTime int `json:"creation_time,omitempty"`
|
||||
Id string `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
NetworkConnectivityConfigId string `json:"network_connectivity_config_id,omitempty"`
|
||||
Region string `json:"region"`
|
||||
UpdatedTime int `json:"updated_time,omitempty"`
|
||||
EgressConfig *ResourceMwsNetworkConnectivityConfigEgressConfig `json:"egress_config,omitempty"`
|
||||
}
|
|
@ -45,6 +45,9 @@ type Resources struct {
|
|||
MwsCredentials map[string]any `json:"databricks_mws_credentials,omitempty"`
|
||||
MwsCustomerManagedKeys map[string]any `json:"databricks_mws_customer_managed_keys,omitempty"`
|
||||
MwsLogDelivery map[string]any `json:"databricks_mws_log_delivery,omitempty"`
|
||||
MwsNccBinding map[string]any `json:"databricks_mws_ncc_binding,omitempty"`
|
||||
MwsNccPrivateEndpointRule map[string]any `json:"databricks_mws_ncc_private_endpoint_rule,omitempty"`
|
||||
MwsNetworkConnectivityConfig map[string]any `json:"databricks_mws_network_connectivity_config,omitempty"`
|
||||
MwsNetworks map[string]any `json:"databricks_mws_networks,omitempty"`
|
||||
MwsPermissionAssignment map[string]any `json:"databricks_mws_permission_assignment,omitempty"`
|
||||
MwsPrivateAccessSettings map[string]any `json:"databricks_mws_private_access_settings,omitempty"`
|
||||
|
@ -137,6 +140,9 @@ func NewResources() *Resources {
|
|||
MwsCredentials: make(map[string]any),
|
||||
MwsCustomerManagedKeys: make(map[string]any),
|
||||
MwsLogDelivery: make(map[string]any),
|
||||
MwsNccBinding: make(map[string]any),
|
||||
MwsNccPrivateEndpointRule: make(map[string]any),
|
||||
MwsNetworkConnectivityConfig: make(map[string]any),
|
||||
MwsNetworks: make(map[string]any),
|
||||
MwsPermissionAssignment: make(map[string]any),
|
||||
MwsPrivateAccessSettings: make(map[string]any),
|
||||
|
|
|
@ -21,7 +21,7 @@ type Root struct {
|
|||
|
||||
const ProviderHost = "registry.terraform.io"
|
||||
const ProviderSource = "databricks/databricks"
|
||||
const ProviderVersion = "1.40.0"
|
||||
const ProviderVersion = "1.43.0"
|
||||
|
||||
func NewRoot() *Root {
|
||||
return &Root{
|
||||
|
|
|
@ -2,6 +2,7 @@ package bundle
|
|||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/databricks/cli/bundle/config"
|
||||
|
@ -10,9 +11,14 @@ import (
|
|||
)
|
||||
|
||||
type addToContainer struct {
|
||||
t *testing.T
|
||||
container *[]int
|
||||
value int
|
||||
err bool
|
||||
|
||||
// mu is a mutex that protects container. It is used to ensure that the
|
||||
// container slice is only modified by one goroutine at a time.
|
||||
mu *sync.Mutex
|
||||
}
|
||||
|
||||
func (m *addToContainer) Apply(ctx context.Context, b ReadOnlyBundle) diag.Diagnostics {
|
||||
|
@ -20,9 +26,10 @@ func (m *addToContainer) Apply(ctx context.Context, b ReadOnlyBundle) diag.Diagn
|
|||
return diag.Errorf("error")
|
||||
}
|
||||
|
||||
c := *m.container
|
||||
c = append(c, m.value)
|
||||
*m.container = c
|
||||
m.mu.Lock()
|
||||
*m.container = append(*m.container, m.value)
|
||||
m.mu.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -36,9 +43,10 @@ func TestParallelMutatorWork(t *testing.T) {
|
|||
}
|
||||
|
||||
container := []int{}
|
||||
m1 := &addToContainer{container: &container, value: 1}
|
||||
m2 := &addToContainer{container: &container, value: 2}
|
||||
m3 := &addToContainer{container: &container, value: 3}
|
||||
var mu sync.Mutex
|
||||
m1 := &addToContainer{t: t, container: &container, value: 1, mu: &mu}
|
||||
m2 := &addToContainer{t: t, container: &container, value: 2, mu: &mu}
|
||||
m3 := &addToContainer{t: t, container: &container, value: 3, mu: &mu}
|
||||
|
||||
m := Parallel(m1, m2, m3)
|
||||
|
||||
|
@ -57,9 +65,10 @@ func TestParallelMutatorWorkWithErrors(t *testing.T) {
|
|||
}
|
||||
|
||||
container := []int{}
|
||||
m1 := &addToContainer{container: &container, value: 1}
|
||||
m2 := &addToContainer{container: &container, err: true, value: 2}
|
||||
m3 := &addToContainer{container: &container, value: 3}
|
||||
var mu sync.Mutex
|
||||
m1 := &addToContainer{container: &container, value: 1, mu: &mu}
|
||||
m2 := &addToContainer{container: &container, err: true, value: 2, mu: &mu}
|
||||
m3 := &addToContainer{container: &container, value: 3, mu: &mu}
|
||||
|
||||
m := Parallel(m1, m2, m3)
|
||||
|
||||
|
|
11
go.mod
11
go.mod
|
@ -23,17 +23,16 @@ require (
|
|||
github.com/stretchr/testify v1.9.0 // MIT
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
|
||||
golang.org/x/mod v0.17.0
|
||||
golang.org/x/oauth2 v0.19.0
|
||||
golang.org/x/oauth2 v0.20.0
|
||||
golang.org/x/sync v0.7.0
|
||||
golang.org/x/term v0.19.0
|
||||
golang.org/x/text v0.14.0
|
||||
golang.org/x/term v0.20.0
|
||||
golang.org/x/text v0.15.0
|
||||
gopkg.in/ini.v1 v1.67.0 // Apache 2.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.google.com/go/compute v1.23.4 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.3.0 // indirect
|
||||
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
|
||||
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
|
||||
|
@ -60,7 +59,7 @@ require (
|
|||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.21.0 // indirect
|
||||
golang.org/x/net v0.23.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
google.golang.org/api v0.169.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304161311-37d4d3c04a78 // indirect
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go/compute v1.23.4 h1:EBT9Nw4q3zyE7G45Wvv3MzolIrCJEuHys5muLY0wvAw=
|
||||
cloud.google.com/go/compute v1.23.4/go.mod h1:/EJMj55asU6kAFnuZET8zqgwgJ9FvXWXOkkfQZa4ioI=
|
||||
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
|
||||
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
|
||||
cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc=
|
||||
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
|
||||
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
|
||||
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
|
@ -191,8 +189,8 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY
|
|||
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
|
||||
golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
|
||||
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
|
||||
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -208,14 +206,14 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
|
||||
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
|
|
Loading…
Reference in New Issue