From 456d73aff8e00864cd8818b0db630a9d9d5660cd Mon Sep 17 00:00:00 2001 From: Lukas Burgey Date: Thu, 15 Nov 2018 15:53:26 +0100 Subject: [PATCH] Adapt to adjustments at the API --- scripts.go | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/scripts.go b/scripts.go index 7800121..63f751f 100644 --- a/scripts.go +++ b/scripts.go @@ -6,14 +6,9 @@ import ( ) type ( - // SSHKey of a user - SSHKey struct { - Name string `json:"name"` - Key string `json:"key"` - } - // 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"` @@ -23,6 +18,9 @@ type ( // after the script run UserCredentialStates map[string]map[string]State + // UserCredentials maps a credential type to the credentials of this type + UserCredentials map[string][]Credential + // Group a group of which User is a member of Group struct { Name string `json:"name"` @@ -33,11 +31,11 @@ type ( // User describes the user info User struct { - // TODO maybe just handover the raw userinfo - Email string `json:"email"` - // TODO maybe just handover the raw userinfo - //Groups []Group `json:"groups"` - UserInfo UserInfo `json:"userinfo"` + // Email string `json:"email"` + // Groups []Group `json:"groups"` + + UserInfo UserInfo `json:"userinfo"` + Credentials UserCredentials `json:"credentials,omitempty"` } // Input of the deployment script @@ -51,13 +49,14 @@ type ( // Credentials the credentials to deploy // maps the credential type to the according credentials - Credentials map[string][]Credential `json:"credentials"` + // TODO this should move into Input.User + 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 - Questionnaire map[string]string `json:"questionnaire"` + Questionnaire map[string]string `json:"questionnaire,omitempty"` } // Output of the deployment script @@ -74,17 +73,17 @@ type ( // Questionnaire requested by the script // Ignored when State is not Questionnaire // Maps a question name to a description of the question - Questionnaire map[string]string `json:"questionnaire"` + Questionnaire map[string]string `json:"questionnaire,omitempty"` // Credentials for the user // Ignored when State is not Deployed // Maps a credential name to a credential value - Credentials map[string]string `json:"credentials"` + Credentials map[string]string `json:"credentials,omitempty"` // UserCredentialStates states of the credentials provided by the user (not by the script!) // This field is not mandatory! The client will assume that all credentials have the State // Output.State if this is not given - UserCredentialStates UserCredentialStates `json:"user_credential_states"` + UserCredentialStates UserCredentialStates `json:"user_credential_states,omitempty"` } // State is a string enum @@ -123,10 +122,6 @@ func (u User) String() string { return "" } -func (k SSHKey) String() string { - return k.Name -} - func (i Input) String() string { iBytes, err := i.Marshal() if err != nil { -- GitLab