FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
stackmate/lib/stackmate/resolver.rb at master · stackmate/stackmate · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Oct 6, 2020. It is now read-only.
stackmate
/
stackmate
Public archive
Notifications
You must be signed in to change notification settings
Fork
12
Star
21
Code
Issues
2
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
stackmate
/
lib
/
stackmate
/
resolver.rb
Copy path
More file actions
More file actions
Latest commit
History
History
History
149 lines (143 loc) · 3.61 KB
Breadcrumbs
stackmate
/
lib
/
stackmate
/
resolver.rb
Copy path
File metadata and controls
149 lines (143 loc) · 3.61 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#require 'stackmate/logging'
require
'stackmate/intrinsic_functions'
module
StackMate
module
Resolver
@devicename_map
=
{
'/dev/sdb'
=>
'1'
,
'/dev/sdc'
=>
'2'
,
'/dev/sdd'
=>
'3'
,
'/dev/sde'
=>
'4'
,
'/dev/sdf'
=>
'5'
,
'/dev/sdg'
=>
'6'
,
'/dev/sdh'
=>
'7'
,
'/dev/sdi'
=>
'8'
,
'/dev/sdj'
=>
'9'
,
'/dev/xvdb'
=>
'1'
,
'/dev/xvdc'
=>
'2'
,
'/dev/xvdd'
=>
'3'
,
'/dev/xvde'
=>
'4'
,
'/dev/xvdf'
=>
'5'
,
'/dev/xvdg'
=>
'6'
,
'/dev/xvdh'
=>
'7'
,
'/dev/xvdi'
=>
'8'
,
'/dev/xvdj'
=>
'9'
,
'xvdb'
=>
'1'
,
'xvdc'
=>
'2'
,
'xvdd'
=>
'3'
,
'xvde'
=>
'4'
,
'xvdf'
=>
'5'
,
'xvdg'
=>
'6'
,
'xvdh'
=>
'7'
,
'xvdi'
=>
'8'
,
'xvdj'
=>
'9'
,
}
#comes from awsapi reference
STRINGEXP
=
/.+/
INTEXP
=
/[0-9]+/
UUIDEXP
=
/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
@@intrinsics
=
[
"Ref"
,
"Fn::Join"
,
"Fn::GetAtt"
,
"Fn::Select"
,
"Fn::FindInMap"
,
"Fn::Base64"
]
def
get_resolved
(
lookup_data
,
workitem
)
case
lookup_data
when
String
lookup_data
when
Hash
intrinsic
(
lookup_data
,
workitem
)
end
end
def
validate_param
(
value
,
type
)
return
true
begin
case
type
when
"boolean"
[
"true"
,
"false"
]
.
include?
(
value
)
when
"date"
true
when
"imageformat"
[
"vhd"
,
"qcow"
]
.
include?
(
value
)
when
"int"
!
INTEXP
.
match
(
value
)
.
nil?
when
"integer"
!
INTEXP
.
match
(
value
)
.
nil?
when
"list"
#eval(value).kind_of?(Array)
true
when
"long"
!
INTEXP
.
match
(
value
)
.
nil?
when
"map"
#eval(value).kind_of?(Hash)
true
when
"set"
#eval(value).kind_of?(Array) and eval(value).uniq == eval(value)
true
when
"short"
!
INTEXP
.
match
(
value
)
.
nil?
when
"state"
true
when
"string"
value
.
kind_of?
(
String
)
when
"tzdate"
true
when
"uuid"
!
UUIDEXP
.
match
(
value
)
.
nil?
else
true
end
rescue
Exception
=>
e
false
end
end
def
get_named_tag
(
tag_name
,
properties
,
workitem
,
default
)
result
=
default
unless
properties
[
'Tags'
]
.
nil?
properties
[
'Tags'
]
.
each
do
|
tag
|
k
=
tag
[
'Key'
]
v
=
tag
[
'Value'
]
if
k
.
eql?
(
tag_name
)
result
=
get_resolved
(
v
,
workitem
)
end
end
end
result
end
def
resolve_tags
(
tags_array
,
workitem
)
result
=
{
}
tags_array
.
each
do
|
tag
|
k
=
tag
[
'key'
]
v
=
tag
[
'value'
]
resolved_v
=
get_resolved
(
v
,
workitem
)
result
[
k
]
=
resolved_v
end
result
end
def
resolve_to_deviceid
(
devicename
)
@devicename_map
[
devicename
.
downcase
]
end
def
recursive_resolve
(
lookup_data
,
workitem
)
case
lookup_data
when
String
lookup_data
when
Array
return_array
=
[
]
lookup_data
.
each
do
|
data
|
return_array
.
push
(
recursive_resolve
(
data
,
workitem
)
)
end
return_array
when
Hash
return_hash
=
{
}
#key = lookup_data.keys[0]
#p lookup_data.keys
lookup_data
.
keys
.
each
do
|
key
|
val
=
lookup_data
[
key
]
if
(
@@intrinsics
.
include?
(
key
)
)
#Intrinsic functions work without nesting and so return
return
intrinsic
(
lookup_data
,
workitem
)
else
return_hash
[
key
]
=
recursive_resolve
(
val
,
workitem
)
end
end
return
return_hash
end
end
end
end
Back
|
FazBrowse Home
|
New Git URL