mvp in 90 uloc
This commit is contained in:
commit
72071df374
|
@ -0,0 +1,19 @@
|
|||
|
||||
Implements naming convention based on resource properies, such as type, location, role, application code
|
||||
|
||||
Requirement : name must update in real time when properties are edited (no stale result).
|
||||
|
||||
# TODO
|
||||
|
||||
- [x] virtual machines
|
||||
- [x] code
|
||||
- [x] region
|
||||
- [x] environment
|
||||
- [x] role
|
||||
- [x] increment
|
||||
- [ ] other resource type
|
||||
- [ ] resource group
|
||||
- [ ] storage account
|
||||
- [ ] some styling
|
||||
- [ ] propose some links (azure web console, datadog, leanix)
|
||||
- [ ] lookup code from app name with fuzzy search (try native component at first)
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"type": "application",
|
||||
"source-directories": [
|
||||
"src"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
"dependencies": {
|
||||
"direct": {
|
||||
"elm/browser": "1.0.2",
|
||||
"elm/core": "1.0.5",
|
||||
"elm/html": "1.0.0"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/json": "1.1.3",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/url": "1.0.0",
|
||||
"elm/virtual-dom": "1.0.3"
|
||||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
module Main exposing (..)
|
||||
|
||||
import Browser
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (..)
|
||||
|
||||
|
||||
main =
|
||||
Browser.sandbox
|
||||
{ init = init
|
||||
, view = view
|
||||
, update = update
|
||||
}
|
||||
|
||||
|
||||
init =
|
||||
{ reg = "EW", code = "zz", env = "P", role = "APP", incr = 1 }
|
||||
|
||||
|
||||
regions =
|
||||
[ ( "EW", "West Europe, Amsterdam" )
|
||||
, ( "EN", "North Europe, Dublin" )
|
||||
]
|
||||
|
||||
|
||||
roles =
|
||||
[ ( "APP", "Application Server" )
|
||||
, ( "WEB", "Web Server" )
|
||||
, ( "DBA", "Database" )
|
||||
, ( "RDS", "Remote Desktop Server" )
|
||||
]
|
||||
|
||||
|
||||
envs =
|
||||
[ ( "P", "Production" )
|
||||
, ( "E", "Préproduction" )
|
||||
, ( "U", "UAT" )
|
||||
, ( "T", "Test" )
|
||||
, ( "I", "Integration" )
|
||||
]
|
||||
|
||||
|
||||
type Msg
|
||||
= InputCode String
|
||||
| InputReg String
|
||||
| InputRole String
|
||||
| InputEnv String
|
||||
| InputIncr String
|
||||
|
||||
|
||||
update msg model =
|
||||
case msg of
|
||||
InputCode s ->
|
||||
{ model | code = s }
|
||||
|
||||
InputReg s ->
|
||||
{ model | reg = s }
|
||||
|
||||
InputRole s ->
|
||||
{ model | role = s }
|
||||
|
||||
InputEnv s ->
|
||||
{ model | env = s }
|
||||
|
||||
InputIncr s ->
|
||||
{ model | incr = String.toInt s |> Maybe.withDefault 1 }
|
||||
|
||||
|
||||
formatName r =
|
||||
"AL"
|
||||
++ r.reg
|
||||
++ "1"
|
||||
-- AZ is hard coded :(
|
||||
++ r.code
|
||||
++ r.env
|
||||
++ r.role
|
||||
++ (if r.incr < 10 then
|
||||
"0"
|
||||
|
||||
else
|
||||
""
|
||||
)
|
||||
++ String.fromInt r.incr
|
||||
|
||||
|
||||
br_ =
|
||||
br [] []
|
||||
|
||||
|
||||
renderSelect : (String -> Msg) -> List ( String, String ) -> Html Msg
|
||||
renderSelect msg options =
|
||||
select [ onInput msg ] (options |> List.map renderOption)
|
||||
|
||||
|
||||
renderOption : ( String, String ) -> Html Msg
|
||||
renderOption opt =
|
||||
option [ opt |> Tuple.first |> value ] [ opt |> Tuple.second |> text ]
|
||||
|
||||
|
||||
view model =
|
||||
div []
|
||||
[ h1 [] [ text "Name Generator 😎" ]
|
||||
, br_
|
||||
, text (formatName model)
|
||||
, br_
|
||||
, br_
|
||||
, br_
|
||||
, text "code"
|
||||
, input [ onInput InputCode, value model.code ] []
|
||||
, br_
|
||||
, br_
|
||||
, text "region"
|
||||
, renderSelect InputReg regions
|
||||
, br_
|
||||
, br_
|
||||
, text "environment"
|
||||
, renderSelect InputEnv envs
|
||||
, br_
|
||||
, br_
|
||||
, text "role"
|
||||
, renderSelect InputRole roles
|
||||
, br_
|
||||
, br_
|
||||
, text "increment"
|
||||
, select [ onInput InputIncr ] (List.range 1 20 |> List.map (String.fromInt >> (\s -> ( s, s )) >> renderOption))
|
||||
]
|
Loading…
Reference in New Issue