Skip to content

Commit

Permalink
WIP: We need component ID to be generated before apply
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirianni committed Feb 8, 2025
1 parent 080c9cc commit c127134
Show file tree
Hide file tree
Showing 5 changed files with 664 additions and 0 deletions.
35 changes: 35 additions & 0 deletions internal/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ type ResourceConfig struct {

// A list of processor names to attach to the resource
Processors []string

// Routes to attach to the resource
Routes *model.Routes
}

// Option is a function that configures a
Expand Down Expand Up @@ -147,6 +150,37 @@ func NewV1(options ...Option) (*model.Configuration, error) {
return c, nil
}

// NewV2Beta takes a configuration options and returns a BindPlane configuration
// with API version bindplane.observiq.com/v2beta
func NewV2Beta(options ...Option) (*model.Configuration, error) {
const (
version = "bindplane.observiq.com/v2beta"
kind = model.KindConfiguration
contentType = "text/yaml" // TODO(jsirianni): Is this required and does it make sense?
)

c := &model.Configuration{
ResourceMeta: model.ResourceMeta{
APIVersion: version,
Kind: kind,
},
Spec: model.ConfigurationSpec{
ContentType: contentType,
},
}

for _, option := range options {
if option == nil {
continue
}
if err := option(c); err != nil {
return nil, err
}
}

return c, nil
}

// WithResourcesByName takes a list of resource configurations
// and returns a list of bindplane model.ResourceConfigurations.
func withResourcesByName(r []ResourceConfig) []model.ResourceConfiguration {
Expand All @@ -169,6 +203,7 @@ func withResourcesByName(r []ResourceConfig) []model.ResourceConfiguration {
ParameterizedSpec: model.ParameterizedSpec{
Processors: processorResources,
},
Routes: r.Routes,
}
resources = append(resources, r)
}
Expand Down
1 change: 1 addition & 0 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func Configure() *schema.Provider {
ResourcesMap: map[string]*schema.Resource{
"bindplane_connector": resourceConnector(),
"bindplane_configuration": resourceConfiguration(),
"bindplane_configuration_v2": resourceConfigurationV2(),
"bindplane_destination": resourceDestination(),
"bindplane_source": resourceSource(),
"bindplane_processor": resourceProcessor(),
Expand Down
Loading

0 comments on commit c127134

Please sign in to comment.