Ejemplo n.º 1
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)
	}
}
Ejemplo n.º 2
0
func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()

	password := randPass()

	var details artifactory.UserDetails = artifactory.UserDetails{
		Email:    *email,
		Password: password,
	}
	if group != nil {
		details.Groups = *group
	}

	if updatable != nil {
		details.ProfileUpdatable = *updatable
	}
	err := client.CreateUser(*username, details)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		if *showpass {
			fmt.Printf("User created. Random password is: %s\n", password)
		}
		os.Exit(0)
	}
}
Ejemplo n.º 3
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)
	}
}
Ejemplo n.º 4
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)
	}
}
Ejemplo n.º 5
0
func main() {
	client := artifactory.NewClientFromEnv()
	p, err := client.GetGeneralConfiguration()
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("%s\n", p)
		os.Exit(0)
	}
}
Ejemplo n.º 6
0
func main() {
	client := artifactory.NewClientFromEnv()
	p, err := client.GetUserEncryptedPassword()
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("%s\n", p)
		os.Exit(0)
	}
}
Ejemplo n.º 7
0
func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	err := client.DeleteUser(*username)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("User %s deleted\n", *username)
		os.Exit(0)
	}
}
Ejemplo n.º 8
0
func main() {
	client := artifactory.NewClientFromEnv()
	data, err := client.GetLicenseInformation()
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"Type", "Expires", "Owner"})
		table.SetAutoWrapText(false)
		table.Append([]string{data.LicenseType, data.ValidThrough, data.LicensedTo})
		table.Render()
		os.Exit(0)
	}
}
Ejemplo n.º 9
0
func main() {
	client := artifactory.NewClientFromEnv()
	data, err := client.GetPermissionTargets()
	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)
	}
}
Ejemplo n.º 10
0
func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()

	i, err := client.DeployArtifact(*repo, *file, *path, *property)
	if err != nil {
		if *silent != true {
			fmt.Printf("%s\n", err)
		}
		os.Exit(1)
	} else {
		if *silent != true {
			fmt.Printf("%s\n", i.URI)
		}
		os.Exit(0)
	}
}
Ejemplo n.º 11
0
func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	u, err := client.GetGroupDetails(*group)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"Name", "Description", "AutoJoin?", "Realm", "Realm Attributes"})
		table.SetAutoWrapText(false)
		table.Append([]string{
			u.Name,
			u.Description,
			strconv.FormatBool(u.AutoJoin),
			u.Realm,
			u.RealmAttributes,
		})
		table.Render()
		os.Exit(0)
	}
}
Ejemplo n.º 12
0
func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	var coords artifactory.Gavc
	if groupid != nil {
		coords.GroupID = *groupid
	}
	if artifactid != nil {
		coords.ArtifactID = *artifactid
	}
	if version != nil {
		coords.Version = *version
	}
	if classifier != nil {
		coords.Classifier = *classifier
	}
	if repo != nil {
		coords.Repos = *repo
	}
	data, err := client.GAVCSearch(&coords)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetAutoWrapText(false)
		table.SetBorder(false)
		table.SetAlignment(tablewriter.ALIGN_LEFT)

		for _, r := range data {
			var innerBuf bytes.Buffer
			innerTable := tablewriter.NewWriter(&innerBuf)
			innerTable.SetHeader([]string{
				"File",
				"Repo",
				"RemoteUrl",
				"Created",
				"Last Modified",
				"Created By",
				"Modified By",
				"SHA1",
				"MD5",
				"Size",
				"MimeType",
			})
			elems := strings.Split(r.Path, "/")
			fileName := elems[len(elems)-1]
			innerTable.Append([]string{
				fileName,
				r.Repo,
				r.RemoteUrl,
				r.Created,
				r.LastModified,
				r.CreatedBy,
				r.ModifiedBy,
				r.Checksums.SHA1,
				r.Checksums.MD5,
				r.Size,
				r.MimeType,
			})
			innerTable.Render()
			table.Append([]string{
				innerBuf.String(),
			})
			table.Append([]string{
				fmt.Sprintf("Download: %s\n", r.Uri),
			})

		}
		table.Render()
		os.Exit(0)
	}
}