Пример #1
0
func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	u, err := client.GetUserDetails(*user)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"Name", "Email", "Password", "Admin?", "Updatable?", "Last Logged In", "Internal Password Disabled?", "Realm", "Groups"})
		table.SetAutoWrapText(false)
		table.Append([]string{
			u.Name,
			u.Email,
			"<hidden>",
			strconv.FormatBool(u.Admin),
			strconv.FormatBool(u.ProfileUpdatable),
			u.LastLoggedIn,
			strconv.FormatBool(u.InternalPasswordDisabled),
			u.Realm,
			strings.Join(u.Groups, "\n"),
		})
		table.Render()
		os.Exit(0)
	}
}
Пример #2
0
func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	u, err := client.GetPermissionTargetDetails(*target)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"Name", "Includes", "Excludes", "Repositories", "Users", "Groups"})
		row := []string{
			u.Name,
			u.IncludesPattern,
			u.ExcludesPattern,
			strings.Join(u.Repositories, "\n"),
		}
		var users []string
		var groups []string
		for k, v := range u.Principals.Users {
			line := fmt.Sprintf("%s (%s)", k, strings.Join(v, ","))
			users = append(users, line)
		}
		for k, v := range u.Principals.Groups {
			line := fmt.Sprintf("%s (%s)", k, strings.Join(v, ","))
			groups = append(groups, line)
		}
		row = append(row, strings.Join(users, "\n"))
		row = append(row, strings.Join(groups, "\n"))
		table.Append(row)
		table.Render()
		fmt.Println("Legend: m=admin; d=delete; w=deploy; n=annotate; r=read")
		os.Exit(0)
	}
}
Пример #3
0
func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	data, err := client.GetRepos(*kind)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{
			"Key",
			"Type",
			"Description",
			"Url",
		})
		for _, r := range data {
			table.Append([]string{
				r.Key,
				r.Rtype,
				r.Description,
				r.Url,
			})
		}
		table.Render()
		os.Exit(0)
	}
}
Пример #4
0
func main() {
	client := artifactory.NewClientFromEnv()
	p, err := client.GetSystemSecurityConfiguration()
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("%s\n", p)
		os.Exit(0)
	}
}
Пример #5
0
func main() {
	client := artifactory.NewClientFromEnv()
	data, err := client.GetUsers()
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"Name", "Uri"})
		table.SetAutoWrapText(false)
		for _, u := range data {
			table.Append([]string{u.Name, u.Uri})
		}
		table.Render()
		os.Exit(0)
	}
}