package deps import ( "fmt" "log" "git.scc.kit.edu/feudal/feudalClient/config" "git.scc.kit.edu/feudal/feudalScripts/v2" ) type ( // VO virtual organisation VO struct { ID int `json:"id"` Name string `json:"name"` ResourceType string `json:"resourcetype"` } // Dep now relates to a DeploymentState at the backend Dep struct { // ID is the db primary key of th DeploymentState instance at the backend. ID int `json:"id"` // The StateTarget of the DeploymentState parent Deployment. StateTarget scripts.State `json:"state_target"` // The user for which we are supposed to deploy access. User scripts.User `json:"user"` // The Service which this Dep is related to. Service config.Service `json:"service"` // Optional Answers by the users. Must have the same keys as the related Questionnaire Answers map[string]string `json:"answers,omitempty"` } // Reply is used to patch the fields of the DeploymentState Reply struct { // ID is the db primary key of the DeploymentState instance at the backend. ID int `json:"id"` // 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 scripts.State `json:"state"` // Message for the user Msg string `json:"message"` // 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,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,omitempty"` // UserCredentialStates are the State s of the credentials found in Input.User.Credentials. UserCredentialStates scripts.UserCredentialStates `json:"credential_states,omitempty"` } ) func (dep Dep) String() string { if dep.Service != (config.Service{}) { return fmt.Sprintf("Dep[%v]#%v", dep.Service.Name, dep.ID) } return fmt.Sprintf("Dep#%v", dep.ID) } // Log logs a message for a Dep func (dep Dep) Log(formatString string, params ...interface{}) { log.Printf("%s "+formatString, append([]interface{}{dep}, params...)...) } func (rep Reply) String() string { return fmt.Sprintf("Rep[%s]#%v]", rep.State, rep.ID) } // Log logs a message for a Reply func (rep Reply) Log(formatString string, params ...interface{}) { log.Printf("%s "+formatString, append([]interface{}{rep}, params...)...) }