Skip to content

Commit

Permalink
changes for injection cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed Oct 13, 2023
1 parent d93ca48 commit 6964c29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
4 changes: 3 additions & 1 deletion pkg/cloudprovider/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import (

corev1beta1 "github.com/aws/karpenter-core/pkg/apis/v1beta1"
"github.com/aws/karpenter-core/pkg/events"
coreoptions "github.com/aws/karpenter-core/pkg/operator/options"
"github.com/aws/karpenter-core/pkg/utils/functional"
machineutil "github.com/aws/karpenter-core/pkg/utils/machine"
nodepoolutil "github.com/aws/karpenter-core/pkg/utils/nodepool"
"github.com/aws/karpenter/pkg/apis"

Check failure on line 34 in pkg/cloudprovider/cloudprovider.go

View workflow job for this annotation

GitHub Actions / ci

could not import github.com/aws/karpenter/pkg/apis (-: # github.com/aws/karpenter/pkg/apis
"github.com/aws/karpenter/pkg/apis/v1alpha1"
"github.com/aws/karpenter/pkg/apis/v1beta1"
"github.com/aws/karpenter/pkg/operator/options"
"github.com/aws/karpenter/pkg/utils"
nodeclassutil "github.com/aws/karpenter/pkg/utils/nodeclass"

Expand Down Expand Up @@ -63,7 +65,7 @@ func init() {
v1alpha5.NormalizedLabels = lo.Assign(v1alpha5.NormalizedLabels, map[string]string{"topology.ebs.csi.aws.com/zone": v1.LabelTopologyZone})
corev1beta1.NormalizedLabels = lo.Assign(corev1beta1.NormalizedLabels, map[string]string{"topology.ebs.csi.aws.com/zone": v1.LabelTopologyZone})
coreapis.Settings = append(coreapis.Settings, apis.Settings...)
coreapis.Options = append(coreapis.Options, apis.Options...)
coreoptions.Injectables = append(coreoptions.Injectables, &options.Options{})

Check failure on line 68 in pkg/cloudprovider/cloudprovider.go

View workflow job for this annotation

GitHub Actions / ci

undefined: coreoptions.Injectables (typecheck)
}

var _ cloudprovider.CloudProvider = (*CloudProvider)(nil)
Expand Down
36 changes: 15 additions & 21 deletions pkg/operator/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"k8s.io/apimachinery/pkg/util/sets"

coresettings "github.com/aws/karpenter-core/pkg/apis/settings"
"github.com/aws/karpenter-core/pkg/utils/env"
"github.com/aws/karpenter/pkg/apis/settings"
)
Expand Down Expand Up @@ -117,29 +116,24 @@ func (*Options) Inject(ctx context.Context, args ...string) (context.Context, er
}
}

ctx = ToContext(ctx, o)
return ctx, nil
return ToContext(ctx, o), nil
}

func (*Options) MergeSettings(ctx context.Context, injectables ...coresettings.Injectable) context.Context {
for _, in := range injectables {
_, ok := in.(*settings.Settings)
if !ok {
continue
}
s := in.FromContext(ctx).(*settings.Settings)
o := FromContext(ctx)
mergeField(&o.AssumeRoleARN, s.AssumeRoleARN, o.AssumeRoleARNSet)
mergeField(&o.AssumeRoleDuration, s.AssumeRoleDuration, o.AssumeRoleDurationSet)
mergeField(&o.ClusterCABundle, s.ClusterCABundle, o.ClusterCABundleSet)
mergeField(&o.ClusterName, s.ClusterName, o.ClusterNameSet)
mergeField(&o.ClusterEndpoint, s.ClusterEndpoint, o.ClusterEndpointSet)
mergeField(&o.IsolatedVPC, s.IsolatedVPC, o.IsolatedVPCSet)
mergeField(&o.VMMemoryOverheadPercent, s.VMMemoryOverheadPercent, o.VMMemoryOverheadPercentSet)
mergeField(&o.InterruptionQueueName, s.InterruptionQueueName, o.InterruptionQueueNameSet)
ctx = ToContext(ctx, o)
func (*Options) MergeSettings(ctx context.Context) context.Context {
s := settings.FromContext(ctx)
if s == nil {
return ctx
}
return ctx
o := FromContext(ctx)
mergeField(&o.AssumeRoleARN, s.AssumeRoleARN, o.AssumeRoleARNSet)
mergeField(&o.AssumeRoleDuration, s.AssumeRoleDuration, o.AssumeRoleDurationSet)
mergeField(&o.ClusterCABundle, s.ClusterCABundle, o.ClusterCABundleSet)
mergeField(&o.ClusterName, s.ClusterName, o.ClusterNameSet)
mergeField(&o.ClusterEndpoint, s.ClusterEndpoint, o.ClusterEndpointSet)
mergeField(&o.IsolatedVPC, s.IsolatedVPC, o.IsolatedVPCSet)
mergeField(&o.VMMemoryOverheadPercent, s.VMMemoryOverheadPercent, o.VMMemoryOverheadPercentSet)
mergeField(&o.InterruptionQueueName, s.InterruptionQueueName, o.InterruptionQueueNameSet)
return ToContext(ctx, o)
}

func ToContext(ctx context.Context, opts *Options) context.Context {
Expand Down

0 comments on commit 6964c29

Please sign in to comment.