Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix eks bugs #838

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/engine2/testdata/k8s_api.expect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ resources:
Region: aws:region:region-0
aws:eks_cluster:eks_cluster-0:
ClusterRole: aws:iam_role:ClusterRole-eks_cluster-0
KubeConfig: kubernetes:kube_config:eks_cluster-0-kube_config
SecurityGroups:
- aws:security_group:vpc-0:eks_cluster-0-security_group
Subnets:
Expand Down
2 changes: 1 addition & 1 deletion pkg/infra/iac3/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (p Plugin) Translate(ctx solution_context.SolutionContext) ([]kio.File, err
func (p *Plugin) sanitizeConfig() error {
reg, err := regexp.Compile("[^a-zA-Z0-9-_]+")
if err != nil {
return fmt.Errorf("Error compiling regex: %v", err)
return fmt.Errorf("error compiling regex: %v", err)
}
p.Config.AppName = reg.ReplaceAllString(p.Config.AppName, "")
return nil
Expand Down
19 changes: 9 additions & 10 deletions pkg/knowledge_base2/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,32 +90,31 @@ func ConsumeFromResource(consumer, emitter *construct.Resource, ctx DynamicConte
addErr(consume, emit, err)
continue
}
val, err = sanitizeForConsumption(ctx, resource, consumeTmpl.GetProperty(consume.PropertyPath), val)
pval, err := resource.GetProperty(consume.PropertyPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why did this move up? pval isn't used until after converting & sanitizing so it can be done later

if err != nil {
addErr(consume, emit, err)
continue
}
pval, err := resource.GetProperty(consume.PropertyPath)
if consume.Converter != "" {
val, err = consume.Convert(val, id, ctx)
if err != nil {
addErr(consume, emit, err)
continue
}
}
val, err = sanitizeForConsumption(ctx, resource, consumeTmpl.GetProperty(consume.PropertyPath), val)
if err != nil {
addErr(consume, emit, err)
continue
}
if pval == nil {
if consume.Converter != "" {
val, err = consume.Convert(val, id, ctx)
if err != nil {
addErr(consume, emit, err)
continue
}
}
delays = append(delays, DelayedConsumption{
Value: val,
Resource: id,
PropertyPath: consume.PropertyPath,
})
continue
}

err = consume.Consume(val, ctx, resource)
if err != nil {
addErr(consume, emit, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/knowledge_base2/properties/list_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (l *ListProperty) Validate(resource *construct.Resource, value any, ctx kno

listVal, ok := value.([]any)
if !ok {
return fmt.Errorf("invalid map value %v", value)
return fmt.Errorf("invalid list value %v", value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
if l.MinLength != nil {
if len(listVal) < *l.MinLength {
Expand Down
7 changes: 6 additions & 1 deletion pkg/templates/aws/edges/eks_cluster-vpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ operational_rules:
- selector: aws:security_group_rule
properties:
SecurityGroupId: '{{ fieldRef "ClusterSecurityGroup" .Source }}'
Type: ingress
Type: ingress
- resource: '{{ .Source }}' # Temporarily generate the kube_config for the cluster
direction: upstream
resources:
- kubernetes:kube_config
unique: true
10 changes: 0 additions & 10 deletions pkg/templates/aws/resources/eks_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ properties:
- aws:security_group
unique: true
description: Lists the security groups associated with the EKS cluster nodes
KubeConfig:
type: resource(kubernetes:kube_config)
operational_rule:
step:
direction: upstream
resources:
- kubernetes:kube_config
unique: true
description: Points to a Kubernetes kubeconfig file containing cluster access
information
Name:
type: string
configuration_disabled: true
Expand Down
Loading