jenkinsrole

package module
v0.0.0-...-d53c459 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 8 Imported by: 0

README

jenkinsrole

Build Status Go Report Card GoDoc

jenkinsrole is a Go package that wraps the API of the Role Strategy plugin for Jenkins. For additional info regarding the plugin itself, see the plugin page.

Using the package

Installation / import

In order to use the package, run go get github.com/calmandniceperson/jenkinsrole and import the package with import github.com/calmandniceperson/jenkinsrole.

Creating a token

In order to use this package, you need to provide a user token to the Client struct. This token can be acquired by entering the respective user's settings in the top right of the Jenkins UI, selecting Configure in the menu on the left side and generating a token in the API Token section.

Creating a client
c := &Client {
    HostName: "http://localhost:8080",
    User: "admin",
    Token: "token123",
}

License

This package is shared under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// The Jenkins hostname
	HostName string
	// The user used to manipulate roles
	User string
	// The token for the given user
	Token string
}

Client implements functionality for manipulating roles in Jenkins.

func NewClient

func NewClient(hostname, user, token string) (*Client, error)

NewClient creates a new instance of Client and does additional checks to ensure that all attributes are valid.

func (*Client) GetAllRoles

func (c *Client) GetAllRoles(roleType string) (RolesWithUsers, error)

GetAllRoles gets a list of all roles with all users they're assigned to.

func (*Client) UnassignRole

func (c *Client) UnassignRole(roleType, roleName, sid string) error

UnassignRole unassigns the role with the given name from the user with the given SID. https://github.com/runzexia/role-strategy-plugin/blob/5fdea531bc5aff5865a64cead6abcf9461720b1b/src/main/java/com/michelin/cio/hudson/plugins/rolestrategy/RoleBasedAuthorizationStrategy.java#L453

type Permission

type Permission int

Permission repesents a permission that can be assigned to a role.

const (
	// ViewDeletePermission = hudson.model.View.Delete
	ViewDeletePermission Permission = iota
	// ComputerConnectPermission = hudson.model.Computer.Connect
	ComputerConnectPermission
	// RunDeletePermission = hudson.model.Run.Delete
	RunDeletePermission
	// CredentialsProviderManageDomainsPermission = com.cloudbees.plugins.credentials.CredentialsProvider.ManageDomains
	CredentialsProviderManageDomainsPermission
	// ComputerCreatePermission = hudson.model.Computer.Create
	ComputerCreatePermission
	// ViewConfigurePermission = hudson.model.View.Configure
	ViewConfigurePermission
	// ComputerBuildPermission = hudson.model.Computer.Build
	ComputerBuildPermission
	// ItemConfigurePermission = hudson.model.Item.Configure
	ItemConfigurePermission
	// HudsonAdministerPermission = hudson.model.Hudson.Administer
	HudsonAdministerPermission
	// ItemCancelPermission = hudson.model.Item.Cancel
	ItemCancelPermission
	// ItemReadPermission = hudson.model.Item.Read
	ItemReadPermission
	// CredentialsProviderViewPermission = com.cloudbees.plugins.credentials.CredentialsProvider.View
	CredentialsProviderViewPermission
	// ComputerDeletePermission = hudson.model.Computer.Delete
	ComputerDeletePermission
	// ItemBuildPermission = hudson.model.Item.Build
	ItemBuildPermission
	// LockableResourcesManagerUnlockPermission = org.jenkins.plugins.lockableresources.LockableResourcesManager.Unlock
	LockableResourcesManagerUnlockPermission
	// SCMTagPermission = hudson.scm.SCM.Tag
	SCMTagPermission
	// ItemMovePermission = hudson.model.Item.Move
	ItemMovePermission
	// ItemDiscoverPermission = hudson.model.Item.Discover
	ItemDiscoverPermission
	// HudsonReadPermission = hudson.model.Hudson.Read
	HudsonReadPermission
	// CredentialsProviderUpdatePermission = com.cloudbees.plugins.credentials.CredentialsProvider.Update
	CredentialsProviderUpdatePermission
	// ItemCreatePermission = hudson.model.Item.Create
	ItemCreatePermission
	// ItemWorkspacePermission = hudson.model.Item.Workspace
	ItemWorkspacePermission
	// CredentialsProviderDeletePermission = com.cloudbees.plugins.credentials.CredentialsProvider.Delete
	CredentialsProviderDeletePermission
	// ComputerProvisionPermission = hudson.model.Computer.Provision
	ComputerProvisionPermission
	// RunReplayPermission = hudson.model.Run.Replay
	RunReplayPermission
	// ViewReadPermission = hudson.model.View.Read
	ViewReadPermission
	// LockableResourcesManagerViewPermission = org.jenkins.plugins.lockableresources.LockableResourcesManager.View
	LockableResourcesManagerViewPermission
	// ViewCreatePermission = hudson.model.View.Create
	ViewCreatePermission
	// ItemDeletePermission = hudson.model.Item.Delete
	ItemDeletePermission
	// ComputerConfigurePermission = hudson.model.Computer.Configure
	ComputerConfigurePermission
	// CredentialsProviderCreatePermission = com.cloudbees.plugins.credentials.CredentialsProvider.Create
	CredentialsProviderCreatePermission
	// ComputerDisconnectPermission = hudson.model.Computer.Disconnect
	ComputerDisconnectPermission
	// LockableResourcesManagerReservePermission = org.jenkins.plugins.lockableresources.LockableResourcesManager.Reserve
	LockableResourcesManagerReservePermission
	// RunUpdatePermission = hudson.model.Run.Update
	RunUpdatePermission

	// All activates all permissions for a role.
	All
)

type Role

type Role struct {
	PermissionIDs map[string]bool `json:"permissionIds"`
	Pattern       string          `json:"pattern"`
	SIDs          []string        `json:"sids"`
}

Role represents a role as it is implemented in the Role Strategy plugin. https://github.com/runzexia/role-strategy-plugin/blob/master/src/main/java/com/michelin/cio/hudson/plugins/rolestrategy/Role.java

type RolesWithUsers

type RolesWithUsers map[string][]string

RolesWithUsers represents the response of the getAllRoles route.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL