Documentation
¶
Overview ¶
Package utils contains helpers shared by the ec2 controllers.
Index ¶
- Constants
- func DiffTags(desired map[string]string, current []*svcapitypes.Tag) (add []svcsdktypes.Tag, remove []svcsdktypes.Tag)
- func ErrorCode(err error) string
- func FindRule(ctx context.Context, c RuleClient, r Rule, egress bool) (*svcsdktypes.SecurityGroupRule, error)
- func FromSDK(tags []svcsdktypes.Tag) []*svcapitypes.Tag
- func IsGroupNotFound(err error) bool
- func NormalizeProtocol(p string) string
- func SpecTags(spec []*svcapitypes.Tag) map[string]string
- func TagSpecifications(rt svcsdktypes.ResourceType, tags map[string]string) []svcsdktypes.TagSpecification
- func UpdateTags(ctx context.Context, c TagClient, id string, desired map[string]string, ...) error
- type Rule
- func (r Rule) Diff(observed svcsdktypes.SecurityGroupRule, egress bool) ([]string, error)
- func (r Rule) IPPermission() svcsdktypes.IpPermission
- func (r Rule) Matches(observed svcsdktypes.SecurityGroupRule, egress bool) bool
- func (r Rule) RuleUpdate(id string) svcsdktypes.SecurityGroupRuleUpdate
- func (r Rule) Validate() error
- type RuleClient
- type TagClient
Constants ¶
const ( CodeGroupNotFound = "InvalidGroup.NotFound" CodeDependency = "DependencyViolation" CodePermissionNotFound = "InvalidPermission.NotFound" )
AWS error codes the ec2 controllers handle.
Variables ¶
This section is empty.
Functions ¶
func DiffTags ¶
func DiffTags(desired map[string]string, current []*svcapitypes.Tag) (add []svcsdktypes.Tag, remove []svcsdktypes.Tag)
DiffTags returns the tags to create (new or changed values) and to delete so that current equals desired. Tags reserved by AWS are left alone.
func FindRule ¶
func FindRule(ctx context.Context, c RuleClient, r Rule, egress bool) (*svcsdktypes.SecurityGroupRule, error)
FindRule returns the rule of r's group that Matches r, or nil if there is none. r must be valid.
func FromSDK ¶
func FromSDK(tags []svcsdktypes.Tag) []*svcapitypes.Tag
FromSDK converts SDK tags to API tags.
func IsGroupNotFound ¶
IsGroupNotFound reports whether err means that the security group does not exist.
func NormalizeProtocol ¶
NormalizeProtocol returns the form AWS reports a protocol in: lower case, with the numbers of tcp, udp, icmp and icmpv6 replaced by their names.
func SpecTags ¶ added in v0.2.0
func SpecTags(spec []*svcapitypes.Tag) map[string]string
SpecTags returns the spec tags as a map: the tags the resource should have, besides those AWS sets.
func TagSpecifications ¶
func TagSpecifications(rt svcsdktypes.ResourceType, tags map[string]string) []svcsdktypes.TagSpecification
TagSpecifications returns the tag specification of a create call.
Types ¶
type Rule ¶
type Rule struct {
GroupID *string
IPProtocol *string
FromPort *int64
ToPort *int64
CIDRIPv4 *string
CIDRIPv6 *string
PrefixListID *string
ReferencedSecurityGroupID *string
Description *string
}
Rule is a single security group rule, as specified by the SecurityGroupIngressRule and SecurityGroupEgressRule kinds.
func (Rule) Diff ¶
func (r Rule) Diff(observed svcsdktypes.SecurityGroupRule, egress bool) ([]string, error)
Diff returns the JSON names of the spec fields whose desired value differs from the observed rule. It returns an error if the observed rule can't be changed into the desired one: it belongs to another group, has the other direction (egress is true for SecurityGroupEgressRule), or has another source type (e.g. a prefix list instead of an IPv4 CIDR).
func (Rule) IPPermission ¶
func (r Rule) IPPermission() svcsdktypes.IpPermission
IPPermission returns the rule in the form Authorize* calls take.
func (Rule) Matches ¶
func (r Rule) Matches(observed svcsdktypes.SecurityGroupRule, egress bool) bool
Matches reports whether observed is the rule r. Within a group, AWS allows only one rule with the same direction, protocol, ports and source; the description and tags can differ.
func (Rule) RuleUpdate ¶
func (r Rule) RuleUpdate(id string) svcsdktypes.SecurityGroupRuleUpdate
RuleUpdate returns the ModifySecurityGroupRules entry that makes the rule with the given ID equal r. AWS can't change the group or the source type in place; Diff reports those as errors.
type RuleClient ¶
type RuleClient interface {
DescribeSecurityGroupRules(context.Context, *svcsdk.DescribeSecurityGroupRulesInput, ...func(*svcsdk.Options)) (*svcsdk.DescribeSecurityGroupRulesOutput, error)
}
RuleClient is the part of the EC2 API used to look up rules.
type TagClient ¶
type TagClient interface {
CreateTags(context.Context, *svcsdk.CreateTagsInput, ...func(*svcsdk.Options)) (*svcsdk.CreateTagsOutput, error)
DeleteTags(context.Context, *svcsdk.DeleteTagsInput, ...func(*svcsdk.Options)) (*svcsdk.DeleteTagsOutput, error)
}
TagClient is the part of the EC2 API used to manage tags.