Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
feudalScripts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
feudal
feudalScripts
Commits
bbc1bf09
Commit
bbc1bf09
authored
Dec 18, 2018
by
Lukas Burgey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add v2
parent
45f57072
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
172 additions
and
14 deletions
+172
-14
scripts.go
scripts.go
+19
-14
v2/go.mod
v2/go.mod
+1
-0
v2/go.sum
v2/go.sum
+0
-0
v2/scripts.go
v2/scripts.go
+152
-0
No files found.
scripts.go
View file @
bbc1bf09
...
...
@@ -16,8 +16,6 @@ type (
// UserCredentialStates serves to inform the backend about the per credential states
// after the script run
// This maps a credential type like "ssh_key" to a map of the states of credentials of this
// type.
UserCredentialStates
map
[
string
]
map
[
string
]
State
// UserCredentials maps a credential type to the credentials of this type
...
...
@@ -41,35 +39,42 @@ type (
// User describes the user of this deployment task
User
User
`json:"user"`
// Answers is an answered questionnaire
// Credentials the credentials to deploy
// maps the credential type to the according credentials
//
// This is now located in Input.User.Credentials
// This field will therefore be removed in the future!
Credentials
UserCredentials
`json:"credentials,omitempty"`
// Questionnaire is an answered questionnaire
// Maps a question name to the answer of the user
// The keys (question names) *must* be identical to those of the Output.Questionnaire
// containing the questions
Answers
map
[
string
]
string
`json:"answers
,omitempty"`
Questionnaire
map
[
string
]
string
`json:"questionnaire
,omitempty"`
}
// Output of the deployment script
Output
struct
{
// State
describes the state of the deployment, after the script execution.
//
When State == Questionnaire then Output.Questionnaire *must* be set.
//
When State == Deployed then Output.Credentials *can* be set.
// State
of the deployment, after the script execution
//
when State == Questionnaire then Output.Questionnaire *must* be set
//
when State == Deployed then Output.Credentials *can* be set
State
State
`json:"state"`
// M
sg is a message for the user.
// M
essage for the user
Msg
string
`json:"message"`
// Questionnaire requested by the script
//
This field is Ignored when Output.State is not Questionnaire.
//
Questionnaire maps a question name to a question.
//
Ignored when State is not Questionnaire
//
Maps a question name to a description of the question
Questionnaire
map
[
string
]
string
`json:"questionnaire,omitempty"`
// Credentials are additionnal credentials for the user.
// Examples are additional passwords.
// This field is ignored by the client when Output.State is not Deployed.
// Credentials maps a credential name to a credential value.
// Credentials for the user
// Ignored when State is not Deployed
// Maps a credential name to a credential value
Credentials
map
[
string
]
string
`json:"credentials,omitempty"`
// UserCredentialStates are the State s of the credentials found in Input.User.Credentials.
//
// This field is not mandatory. The client will assume that all credentials have the State
// Output.State if this field is not given.
UserCredentialStates
UserCredentialStates
`json:"user_credential_states,omitempty"`
...
...
v2/go.mod
0 → 100644
View file @
bbc1bf09
module git.scc.kit.edu/feudal/feudalScripts/v2
v2/go.sum
0 → 100644
View file @
bbc1bf09
v2/scripts.go
0 → 100644
View file @
bbc1bf09
package
scripts
import
(
"encoding/json"
"log"
)
type
(
// Credential is currently a ssh key, but may be a password hash in the future
Credential
struct
{
ID
int
`json:"id,omitempty"`
Type
string
`json:"type,omitempty"`
Name
string
`json:"name"`
Value
string
`json:"value"`
}
// UserCredentialStates serves to inform the backend about the per credential states
// after the script run
// This maps a credential type like "ssh_key" to a map of the states of credentials of this
// type.
UserCredentialStates
map
[
string
]
map
[
string
]
State
// UserCredentials maps a credential type to the credentials of this type
UserCredentials
map
[
string
][]
Credential
// UserInfo info about the user
UserInfo
map
[
string
]
interface
{}
// User contains information concerning the user of a deployment
User
struct
{
UserInfo
UserInfo
`json:"userinfo"`
Credentials
UserCredentials
`json:"credentials"`
}
// Input of the deployment script
Input
struct
{
// StateTarget is the state which is to be reached by this deployment task
// StateTarget is either Deployed or NotDeployed
StateTarget
State
`json:"state_target"`
// User describes the user of this deployment task
User
User
`json:"user"`
// Answers is an answered questionnaire
// Maps a question name to the answer of the user
// The keys (question names) *must* be identical to those of the Output.Questionnaire
// containing the questions
Answers
map
[
string
]
string
`json:"answers,omitempty"`
}
// Output of the deployment script
Output
struct
{
// State describes the state of the deployment, after the script execution.
// When State == Questionnaire then Output.Questionnaire *must* be set.
// When State == Deployed then Output.Credentials *can* be set.
State
State
`json:"state"`
// Msg is a message for the user.
Msg
string
`json:"message"`
// Questionnaire requested by the script
// This field is Ignored when Output.State is not Questionnaire.
// Questionnaire maps a question name to a question.
Questionnaire
map
[
string
]
string
`json:"questionnaire,omitempty"`
// Credentials are additionnal credentials for the user.
// Examples are additional passwords.
// This field is ignored by the client when Output.State is not Deployed.
// Credentials maps a credential name to a credential value.
Credentials
map
[
string
]
string
`json:"credentials,omitempty"`
// UserCredentialStates are the State s of the credentials found in Input.User.Credentials.
// This field is not mandatory. The client will assume that all credentials have the State
// Output.State if this field is not given.
UserCredentialStates
UserCredentialStates
`json:"user_credential_states,omitempty"`
}
// State is a string enum
// The enum values for State are listed below
State
string
)
const
(
// Deployed value for State
Deployed
State
=
"deployed"
// NotDeployed value for State
NotDeployed
State
=
"not_deployed"
// Rejected value for State
// the user can never be deployed
Rejected
State
=
"rejected"
// Failed value for State
// the deployment can be retried
Failed
State
=
"failed"
// Questionnaire value for State
// the user has to fill the questionnaire
// with the questionnaire data the deployment can be retried
Questionnaire
State
=
"questionnaire"
)
func
(
u
User
)
String
()
string
{
if
email
,
ok
:=
u
.
UserInfo
[
"email"
];
ok
{
return
email
.
(
string
)
}
if
name
,
ok
:=
u
.
UserInfo
[
"name"
];
ok
{
return
name
.
(
string
)
}
return
""
}
func
(
i
Input
)
String
()
string
{
iBytes
,
err
:=
i
.
Marshal
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
return
string
(
iBytes
)
}
func
(
o
Output
)
String
()
string
{
oBytes
,
err
:=
o
.
Marshal
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
return
string
(
oBytes
)
}
// Marshal encodes an Input as json
func
(
i
Input
)
Marshal
()
(
iBytes
[]
byte
,
err
error
)
{
iBytes
,
err
=
json
.
MarshalIndent
(
i
,
""
,
" "
)
return
}
// Marshal encodes an Output as json
func
(
o
Output
)
Marshal
()
(
oBytes
[]
byte
,
err
error
)
{
oBytes
,
err
=
json
.
MarshalIndent
(
o
,
""
,
" "
)
return
}
// UnmarshalInput decodes a json encoded input
func
UnmarshalInput
(
inputBytes
[]
byte
)
(
i
Input
,
err
error
)
{
err
=
json
.
Unmarshal
(
inputBytes
,
&
i
)
return
}
// UnmarshalOutput decodes a json encoded output
func
UnmarshalOutput
(
inputBytes
[]
byte
)
(
i
Output
,
err
error
)
{
err
=
json
.
Unmarshal
(
inputBytes
,
&
i
)
return
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment