Adding frameworks column to control command

This commit is contained in:
JusteenR
2022-11-20 15:42:13 -08:00
parent af8e786ab5
commit 81771b7bd7
2 changed files with 17 additions and 9 deletions
+13 -5
View File
@@ -65,12 +65,20 @@ func (drp *DownloadReleasedPolicy) ListControls() ([]string, error) {
if err != nil {
return []string{}, err
}
controlsNamesWithIDsList := make([]string, len(controlsIDsList))
// by design both slices have the same length
for i := range controlsIDsList {
controlsNamesWithIDsList[i] = fmt.Sprintf("%v|%v", controlsIDsList[i], controlsNamesList[i])
controls, err := drp.gs.GetOPAControls()
if err != nil {
return []string{}, err
}
return controlsNamesWithIDsList, nil
var controlsFrameworksList [][]string
for _, control := range controls {
controlsFrameworksList = append(controlsFrameworksList, control.FrameworkNames)
}
controlsNamesWithIDsandFrameworksList := make([]string, len(controlsIDsList))
// by design all slices have the same lengt
for i := range controlsIDsList {
controlsNamesWithIDsandFrameworksList[i] = fmt.Sprintf("%v|%v|%v", controlsIDsList[i], controlsNamesList[i], strings.Join(controlsFrameworksList[i], ","))
}
return controlsNamesWithIDsandFrameworksList, nil
}
func (drp *DownloadReleasedPolicy) GetControlsInputs(clusterName string) (map[string][]string, error) {
+4 -4
View File
@@ -112,7 +112,7 @@ func jsonListFormat(targetPolicy string, policies []string) {
func prettyPrintControls(policies []string) {
controlsTable := tablewriter.NewWriter(printer.GetWriter(""))
controlsTable.SetAutoWrapText(true)
controlsTable.SetHeader([]string{"Control ID", "Control Name", "Docs"})
controlsTable.SetHeader([]string{"Control ID", "Control Name", "Docs", "Frameworks"})
controlsTable.SetHeaderLine(true)
controlsTable.SetRowLine(true)
data := v2.Matrix{}
@@ -128,12 +128,12 @@ func generateControlRows(policies []string) [][]string {
rows := [][]string{}
for _, control := range policies {
idAndControl := strings.Split(control, "|")
id, control := idAndControl[0], idAndControl[1]
idAndControlAndFrameworks := strings.Split(control, "|")
id, control, framework := idAndControlAndFrameworks[0], idAndControlAndFrameworks[1], idAndControlAndFrameworks[2]
docs := cautils.GetControlLink(id)
currentRow := []string{id, control, docs}
currentRow := []string{id, control, docs, framework}
rows = append(rows, currentRow)
}