Skip to content

Commit

Permalink
refactor: add secrets engine support via route and api, even tho it m…
Browse files Browse the repository at this point in the history
…ight not work serverside
  • Loading branch information
plyr4 committed Feb 1, 2024
1 parent c682a4b commit d6533ae
Show file tree
Hide file tree
Showing 13 changed files with 263 additions and 211 deletions.
208 changes: 110 additions & 98 deletions src/elm/Api/Operations.elm
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ getOrgSecrets :
-> Session
->
{ a
| org : String
| engine : String
, org : String
, pageNumber : Maybe Int
, perPage : Maybe Int
}
Expand All @@ -240,7 +241,7 @@ getOrgSecrets baseUrl session options =
(Api.Endpoint.Secrets
options.pageNumber
options.perPage
"native"
options.engine
"org"
options.org
"*"
Expand All @@ -256,14 +257,15 @@ getOrgSecret :
-> Session
->
{ a
| org : String
| engine : String
, org : String
, name : String
}
-> Request Vela.Secret
getOrgSecret baseUrl session options =
get baseUrl
(Api.Endpoint.Secret
"native"
options.engine
"org"
options.org
"*"
Expand All @@ -280,15 +282,16 @@ updateOrgSecret :
-> Session
->
{ a
| org : String
| engine : String
, org : String
, name : String
, body : Http.Body
}
-> Request Vela.Secret
updateOrgSecret baseUrl session options =
put baseUrl
(Api.Endpoint.Secret
"native"
options.engine
"org"
options.org
"*"
Expand All @@ -299,21 +302,49 @@ updateOrgSecret baseUrl session options =
|> withAuth session


{-| addOrgSecret : adds an org secret
-}
addOrgSecret :
String
-> Session
->
{ a
| engine : String
, org : String
, body : Http.Body
}
-> Request Vela.Secret
addOrgSecret baseUrl session options =
post baseUrl
(Api.Endpoint.Secrets
Nothing
Nothing
options.engine
"org"
options.org
"*"
)
options.body
Vela.decodeSecret
|> withAuth session


{-| deleteOrgSecret : deletes a secret for an org
-}
deleteOrgSecret :
String
-> Session
->
{ a
| org : String
| engine : String
, org : String
, name : String
}
-> Request String
deleteOrgSecret baseUrl session options =
delete baseUrl
(Api.Endpoint.Secret
"native"
options.engine
"org"
options.org
"*"
Expand All @@ -330,7 +361,8 @@ getRepoSecrets :
-> Session
->
{ a
| org : String
| engine : String
, org : String
, repo : String
, pageNumber : Maybe Int
, perPage : Maybe Int
Expand All @@ -341,7 +373,7 @@ getRepoSecrets baseUrl session options =
(Api.Endpoint.Secrets
options.pageNumber
options.perPage
"native"
options.engine
"repo"
options.org
options.repo
Expand All @@ -357,15 +389,16 @@ getRepoSecret :
-> Session
->
{ a
| org : String
| engine : String
, org : String
, repo : String
, name : String
}
-> Request Vela.Secret
getRepoSecret baseUrl session options =
get baseUrl
(Api.Endpoint.Secret
"native"
options.engine
"repo"
options.org
options.repo
Expand All @@ -382,7 +415,8 @@ updateRepoSecret :
-> Session
->
{ a
| org : String
| engine : String
, org : String
, repo : String
, name : String
, body : Http.Body
Expand All @@ -391,7 +425,7 @@ updateRepoSecret :
updateRepoSecret baseUrl session options =
put baseUrl
(Api.Endpoint.Secret
"native"
options.engine
"repo"
options.org
options.repo
Expand All @@ -402,22 +436,51 @@ updateRepoSecret baseUrl session options =
|> withAuth session


{-| addRepoSecret : adds a repo secret
-}
addRepoSecret :
String
-> Session
->
{ a
| engine : String
, org : String
, repo : String
, body : Http.Body
}
-> Request Vela.Secret
addRepoSecret baseUrl session options =
post baseUrl
(Api.Endpoint.Secrets
Nothing
Nothing
options.engine
"repo"
options.org
options.repo
)
options.body
Vela.decodeSecret
|> withAuth session


{-| deleteRepoSecret : deletes a secret for an repo
-}
deleteRepoSecret :
String
-> Session
->
{ a
| org : String
| engine : String
, org : String
, repo : String
, name : String
}
-> Request String
deleteRepoSecret baseUrl session options =
delete baseUrl
(Api.Endpoint.Secret
"native"
options.engine
"repo"
options.org
options.repo
Expand All @@ -434,7 +497,8 @@ getSharedSecrets :
-> Session
->
{ a
| org : String
| engine : String
, org : String
, team : String
, pageNumber : Maybe Int
, perPage : Maybe Int
Expand All @@ -445,7 +509,7 @@ getSharedSecrets baseUrl session options =
(Api.Endpoint.Secrets
options.pageNumber
options.perPage
"native"
options.engine
"shared"
options.org
options.team
Expand All @@ -454,6 +518,34 @@ getSharedSecrets baseUrl session options =
|> withAuth session


{-| addSharedSecret : adds a shared secret
-}
addSharedSecret :
String
-> Session
->
{ a
| engine : String
, org : String
, team : String
, body : Http.Body
}
-> Request Vela.Secret
addSharedSecret baseUrl session options =
post baseUrl
(Api.Endpoint.Secrets
Nothing
Nothing
options.engine
"shared"
options.org
options.team
)
options.body
Vela.decodeSecret
|> withAuth session


{-| getRepoBuilds : retrieves builds for a repo
-}
getRepoBuilds :
Expand Down Expand Up @@ -918,83 +1010,3 @@ getBuildGraph baseUrl session options =
)
Vela.decodeBuildGraph
|> withAuth session


{-| addOrgSecret : adds an org secret
-}
addOrgSecret :
String
-> Session
->
{ a
| org : String
, body : Http.Body
}
-> Request Vela.Secret
addOrgSecret baseUrl session options =
post baseUrl
(Api.Endpoint.Secrets
Nothing
Nothing
"native"
"org"
options.org
"*"
)
options.body
Vela.decodeSecret
|> withAuth session


{-| addRepoSecret : adds a repo secret
-}
addRepoSecret :
String
-> Session
->
{ a
| org : String
, repo : String
, body : Http.Body
}
-> Request Vela.Secret
addRepoSecret baseUrl session options =
post baseUrl
(Api.Endpoint.Secrets
Nothing
Nothing
"native"
"repo"
options.org
options.repo
)
options.body
Vela.decodeSecret
|> withAuth session


{-| addSharedSecret : adds a shared secret
-}
addSharedSecret :
String
-> Session
->
{ a
| org : String
, team : String
, body : Http.Body
}
-> Request Vela.Secret
addSharedSecret baseUrl session options =
post baseUrl
(Api.Endpoint.Secrets
Nothing
Nothing
"native"
"shared"
options.org
options.team
)
options.body
Vela.decodeSecret
|> withAuth session
2 changes: 1 addition & 1 deletion src/elm/Components/Repo.elm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ view shared { toggleFavoriteMsg, org, repo, favorites, filtered } =
[ class "button"
, class "-outline"
, Util.testAttribute "repo-secrets"
, Route.Path.href <| Route.Path.Org_Repo_Secrets { org = org, repo = repo }
, Route.Path.href <| Route.Path.Org_Repo_Secrets { org = org, repo = repo, engine = "native" }
]
[ text "Secrets" ]
, a
Expand Down
Loading

0 comments on commit d6533ae

Please sign in to comment.