Add a Docker Artifact Source Using API

Updated 1 month ago by Archana Singh

This topic describes how to create, read, update, and delete Docker Artifact Source using Harness GraphQL APIs.

In this topic:

Before You Begin

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"
}
}


How did we do?