Skip to content

Instantly share code, notes, and snippets.

@shiywang
Created December 27, 2016 17:08
Show Gist options
  • Save shiywang/5ce96b34c9060cc21a8a8dd5bc7361ed to your computer and use it in GitHub Desktop.
Save shiywang/5ce96b34c9060cc21a8a8dd5bc7361ed to your computer and use it in GitHub Desktop.
if err := printPolicyRoleMultilineWithIndent(w, name, rolesString, policy); err != nil {
return err
}
func printPolicyRoleMultilineWithIndent(w io.Writer, name string, rolesString string, policy *authorizationapi.Policy) error{
if len(rolesString) > 50 {
if _, err := fmt.Fprintf(w, "%s\t%s\t%v", name, rolesString, policy.LastModified); err != nil {
return err
}
} else {
beginIndent, endIndent := "",""
for i, key := range rolesString {
if i == 0 {
if _, err := fmt.Fprintf(w, "%s\t%s\t%v", name, rolesString, policy.LastModified); err != nil {
return err
}
}
if _, err := fmt.Fprintf(w, "%s\t%s\t%v", beginIndent, rolesString, endIndent); err != nil {
return err
}
i++
}
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment