package arn
import (
)
var supportedServiceARN = []string{
"s3",
"s3-outposts",
"s3-object-lambda",
}
func ( string) bool {
for , := range supportedServiceARN {
if == {
return true
}
}
return false
}
type Resource interface {
GetARN() arn.ARN
String() string
}
type ResourceParser func(arn.ARN) (Resource, error)
func ( arn.ARN, ResourceParser) ( Resource, error) {
if len(.Partition) == 0 {
return nil, InvalidARNError{ARN: , Reason: "partition not set"}
}
if !isSupportedServiceARN(.Service) {
return nil, InvalidARNError{ARN: , Reason: "service is not supported"}
}
if len(.Resource) == 0 {
return nil, InvalidARNError{ARN: , Reason: "resource not set"}
}
return ()
}
func ( string) []string {
var []string
var int
for <= len() {
:= strings.IndexAny([:], "/:")
if < 0 {
= append(, [:])
break
}
= append(, [:+])
+= + 1
}
return
}
func ( string) bool {
return arn.IsARN()
}
type InvalidARNError struct {
ARN arn.ARN
Reason string
}
func ( InvalidARNError) () string {
return fmt.Sprintf("invalid Amazon %s ARN, %s, %s", .ARN.Service, .Reason, .ARN.String())
}