harborapi.auth
harborapi.auth
defines utility functions for use with harborapi
.
HarborAuthFile
Bases: Robot
Represents a Harbor robot account auth file.
Supports arbitrary extra fields to allow for future compatibility.
Source code in harborapi/auth.py
load_harbor_auth_file(path)
Load a HarborAuthFile from a file path. Ensure that the file contains a name and secret.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[str, Path]
|
The path to the file to load. |
required |
Returns:
Type | Description |
---|---|
HarborAuthFile
|
The HarborAuthFile loaded from the file. |
Raises:
Type | Description |
---|---|
ValueError
|
The auth file does not contain a username and/or secret. |
Source code in harborapi/auth.py
save_authfile(path, authfile, overwrite)
Save the authfile to the given path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[str, Path]
|
Path to save the file to. |
required |
authfile |
HarborAuthFile
|
Auth file definition to save. |
required |
overwrite |
bool
|
Overwrite file if it exists. |
required |
Raises:
Type | Description |
---|---|
FileExistsError
|
A file with the given path already exists, and |
Source code in harborapi/auth.py
new_authfile_from_robotcreate(path, robotcreate, robotcreated, overwrite=False)
Create a new authfile from the result of a create robot call.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[str, Path]
|
Path to save the file to. |
required |
robotcreate |
RobotCreate
|
The arguments used to create the robot. |
required |
robotcreated |
RobotCreated
|
The result of the create robot call. |
required |
overwrite |
bool
|
Overwrite file if it exists. |
False
|
See Also
Source code in harborapi/auth.py
new_authfile_from_robot(path, robot, secret, overwrite=False)
Create a new authfile from a Robot definition and a secret.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[str, Path]
|
Path to save the file to. |
required |
robot |
Robot
|
Robot definition. |
required |
secret |
str
|
Secret to use for the robot. |
required |
overwrite |
bool
|
Overwrite file if it exists. |
False
|