-
Notifications
You must be signed in to change notification settings - Fork 9
Refactor to remove legacyconfig object #163
Changes from 2 commits
f708a33
7d1bbdf
3e64e43
c613565
e51288a
3329943
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ import ( | |
orchInf "github.com/atlassian/voyager/pkg/orchestration/informer" | ||
orchUpdater "github.com/atlassian/voyager/pkg/orchestration/updater" | ||
"github.com/atlassian/voyager/pkg/orchestration/wiring" | ||
"github.com/atlassian/voyager/pkg/orchestration/wiring/legacy" | ||
"github.com/atlassian/voyager/pkg/orchestration/wiring/wiringplugin" | ||
prom_util "github.com/atlassian/voyager/pkg/util/prometheus" | ||
"github.com/pkg/errors" | ||
|
@@ -30,9 +29,9 @@ import ( | |
) | ||
|
||
type ControllerConstructor struct { | ||
FlagConfigFile string | ||
GetLegacyConfigFunc func(voyager.Location) *legacy.Config | ||
Plugins map[voyager.ResourceType]wiringplugin.WiringPlugin | ||
FlagConfigFile string | ||
Plugins map[voyager.ResourceType]wiringplugin.WiringPlugin | ||
Tags wiring.TagGenerator | ||
} | ||
|
||
func (cc *ControllerConstructor) AddFlags(flagset ctrl.FlagSet) { | ||
|
@@ -88,14 +87,7 @@ func (cc *ControllerConstructor) New(config *ctrl.Config, cctx *ctrl.Context) (* | |
Plugins: cc.Plugins, | ||
ClusterLocation: opts.Location.ClusterLocation(), | ||
ClusterConfig: toClusterConfig(opts.Cluster), | ||
TagNames: wiring.TagNames{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? Seems unrelated to LegacyConfig. Could you split into multiple PRs please? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the comment about introducing the tag generator. If the tags come from a function there's no need to make their keys come in via config. |
||
ServiceNameTag: opts.TagNames.ServiceName, | ||
BusinessUnitTag: opts.TagNames.BusinessUnit, | ||
ResourceOwnerTag: opts.TagNames.ResourceOwner, | ||
PlatformTag: opts.TagNames.Platform, | ||
EnvironmentTypeTag: opts.TagNames.EnvironmentType, | ||
}, | ||
GetLegacyConfigFunc: cc.GetLegacyConfigFunc, | ||
Tags: cc.Tags, | ||
} | ||
|
||
// Spec check | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ import ( | |
creator_v1 "github.com/atlassian/voyager/pkg/apis/creator/v1" | ||
"github.com/atlassian/voyager/pkg/creator/luigi" | ||
"github.com/atlassian/voyager/pkg/creator/ssam" | ||
ec2compute_common "github.com/atlassian/voyager/pkg/orchestration/wiring/ec2compute/common" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also unrelated to LegacyConfig? separate PR please. |
||
ec2compute_v2 "github.com/atlassian/voyager/pkg/orchestration/wiring/ec2compute/v2" | ||
"github.com/atlassian/voyager/pkg/pagerduty" | ||
"github.com/atlassian/voyager/pkg/servicecentral" | ||
"github.com/atlassian/voyager/pkg/util" | ||
|
@@ -33,7 +33,7 @@ const ( | |
ServiceNameMinimumLength = 1 | ||
ServiceNameMaximumLength = 24 | ||
ServiceNameExpr = schema.ResourceNameSchemaPattern | ||
EC2ComputeNameMaximumLength = ec2compute_common.MaximumServiceNameLength | ||
EC2ComputeNameMaximumLength = ec2compute_v2.MaximumServiceNameLength | ||
) | ||
|
||
var ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,11 +34,16 @@ const ( | |
|
||
// All osb-aws-provider resources are 'almost' the same, differing only in the service/plan names, | ||
// what they need passed in the ServiceEnvironment. | ||
var ResourceTypes = map[voyager.ResourceType]wiringplugin.WiringPlugin{ | ||
DynamoDB: wiringutil.StatusAdapter(Resource(DynamoDB, DynamoDBName, DynamoDBClass, DynamoDBPlan, dynamoDbServiceEnvironment, dynamoDbShapes).WireUp), | ||
S3: wiringutil.StatusAdapter(Resource(S3, S3Name, S3Class, S3Plan, s3ServiceEnvironment, s3Shapes).WireUp), | ||
Cfn: wiringutil.StatusAdapter(Resource(Cfn, CfnName, CfnClass, CfnPlan, CfnServiceEnvironment, cfnShapes).WireUp), | ||
} | ||
var ( | ||
emptyVPC = func(location voyager.Location) *oap.VPCEnvironment { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you construct non-empty VPC and make it environment-specific without LegacyConfig? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're passing a function type based on public types. I won't be using know authowire plugins in the close repo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry, I don't understand this English :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not. Follow the code in the orchestration main in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused. If you want to construct plugins dynamically, these static plugin variables simply should not exist, at least in the non-test package. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with Nail's point. Would be better to move the not-really-ready-to-use instances of plugins (and other "stubby" stuff) into some testing package There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think these comments are now outdated. |
||
return oap.ExampleVPC(location.Label, location.Region) | ||
} | ||
DynamoDBPlugin = wiringutil.StatusAdapter(Resource(DynamoDB, DynamoDBName, DynamoDBClass, DynamoDBPlan, dynamoDbServiceEnvironment, dynamoDbShapes, emptyVPC).WireUp) | ||
|
||
S3Plugin = wiringutil.StatusAdapter(Resource(S3, S3Name, S3Class, S3Plan, s3ServiceEnvironment, s3Shapes, emptyVPC).WireUp) | ||
|
||
CfnPlugin = wiringutil.StatusAdapter(Resource(Cfn, CfnName, CfnClass, CfnPlan, CfnServiceEnvironment, cfnShapes, emptyVPC).WireUp) | ||
) | ||
|
||
func cfnShapes(resource *orch_v1.StateResource, smithResource *smith_v1.Resource, _ *wiringplugin.WiringContext) ([]wiringplugin.Shape, bool /* externalErr */, bool /* retriableErr */, error) { | ||
templateName, external, retriable, err := oap.TemplateName(resource.Spec) | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The real problem, I think, is that autowiring functions at the moment are not configurable (they are all hardcoded), and the only way to pass configuration is via context and orchestration controller constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about moving the plugins out of wiring/registry? We can pass them as parameters into the constructor for orchestration controller.
This matches up with what @amckague has done for the example tag generator, and it's what we sort of do for smith too. We're going to want to split the wiring out of this repo anyway.