Add a Docker Artifact Source Using API
This topic describes how to create, read, update, and delete Docker Artifact Source using Harness GraphQL APIs.
Before You Begin
- Read the Create an Application topic to get an overview of how Harness organizes Services.
- Read the Add a Service topic to understand the process to add a Service to an Application.
- Read Configuration as Code to see how you can quickly configure your Harness Service using your existing YAML in Git.
- Add Artifact Servers
- Add a Docker Artifact Source
Step: Create a Docker Artifact Source
Use this sample query to create a Docker Artifact Source.
Request
You create a Docker Artifact Source using the mutation createConnector
.
mutation CreateConnector($connector: CreateConnectorInput!) {
createConnector(input: $connector) {
clientMutationId
connector {
...on DockerConnector{
name
id
}
}
}
}
Query Variables
The Query Variables follow this syntax, with connectorType
identifying the Docker Artifact Source to create.
To fetch the passwordSecretId
use:
{
"connector": {
"connectorType": "DOCKER",
"dockerConnector": {
"name":"DockerConnector",
"URL":"https://registry.hub.docker.com/v2/",
"passwordSecretId": "xxxyyy1aa_zzzaa1aa",
"userName": "wingsplugins"
}
}
}
Step: Update a Docker Artifact Source
Use this sample query to update a Docker Artifact Source.
Request
You update a Docker Artifact Source using the mutation updateConnector
.
mutation UpdateConnector($connector: UpdateConnectorInput!) {
updateConnector(input: $connector) {
clientMutationId
connector {
name
id
}
}
}
Query Variables
The Query Variables follow this syntax, with connectorType
identifying the Docker Artifact Source to update. See Fetch the Connector ID to get the connector ID details.
{
"connector": {
"connectorType": "DOCKER",
"connectorId": "xxxxxx",
"dockerConnector": {
"name":"Updated name docker",
"URL":"https://registry.hub.docker.com/v2/",
"passwordSecretId": "xxxxxx",
"userName": "wingsplugins2"
}
}
}
Fetch the Connector ID
Use the following query to fetch the ID
of a connector. A list of connectors is returned based on the set filters. You can select the ID
of the connector that you want to update.
query
{
connectors(filters: [{connectorType: {operator: EQUALS, values: DOCKER}}], limit: 20) {
nodes {
name
id
}
}
}
Step: Delete a Docker Artifact Source
You delete a Docker Artifact Source using the mutation deleteConnector
. Deleting a Docker Artifact Source requires its ID
only.
mutation DeleteConnectorMutation($connector: DeleteConnectorInput!) {
deleteConnector(input: $connector) {
clientMutationId
}
}
Query Variables
Query Variables, with connectorId
identifies the Docker Artifact Source to delete.
{
"connector": {
"connectorId": "xxxxxx"
}
}