aws_ecr
- Components
- Code examples
Managing private repositories
--- adds a new repository
INSERT INTO repository (repository_name, scan_on_push, image_tag_mutability)
VALUES ('<repositoryName>', false, 'MUTABLE');
--- check that new images has been created under a private repo
SELECT *
FROM repository_image
WHERE private_repository_id = (select id from repository where repository_name = '<repositoryName>');
--- deletes image with a tag from a private repo
DELETE FROM repository_image WHERE private_repository_id = (select id from repository where repository_name = '<repositoryName>') AND image_tag='<repositoryTag>';
--- tries to update a repository field
UPDATE repository SET scan_on_push = true WHERE repository_name = '<repositoryName>';
--- check adds a new repository
SELECT *
FROM repository
WHERE repository_name = '<repositoryName>';
--- adds a new repository policy
INSERT INTO repository_policy (repository_id, policy)
VALUES ((select id from repository where repository_name = '<repositoryName>'), '<policyMock>');
--- deletes the repository policy
DELETE FROM repository_policy
WHERE repository_id = (select id from repository where repository_name = '<repositoryName>');
--- deletes the repository images
DELETE FROM repository_image WHERE private_repository_id = (select id from repository where repository_name = '<repositoryName>');
--- deletes the repository
DELETE FROM repository
WHERE repository_name = '<repositoryName>';
Managing public repositories
--- adds a new public repository
INSERT INTO public_repository (repository_name)
VALUES ('<pubRepositoryName>');
--- check that new images has been created under a public repo
SELECT *
FROM repository_image
WHERE public_repository = '<pubRepositoryName>';
--- deletes the repository images
DELETE FROM repository_image WHERE public_repository= '<pubRepositoryName>';
--- deletes the public repository
DELETE FROM public_repository
WHERE repository_name = '<pubRepositoryName>';
Build images
--- installs the ecr module
SELECT * FROM iasql_install('<modules>');
--- creates a new ecr repository
INSERT INTO repository (repository_name, scan_on_push, image_tag_mutability)
VALUES ('<repositoryName>', false, 'MUTABLE');
--- builds hello world image and pushes to the new ecr repo
SELECT ecr_build(
'https://github.com/iasql/docker-helloworld',
(SELECT id FROM repository WHERE repository_name = '<repositoryName>')::varchar(255),
'.',
'main',
'<GH_PAT>'
);
--- checks if the image is created in the database
SELECT image_tag
FROM repository_image
WHERE private_repository_id = (SELECT id FROM repository WHERE repository_name = '<repositoryName>');
--- deletes the image
DELETE
FROM repository_image
WHERE private_repository_id = (SELECT id FROM repository WHERE repository_name = '<repositoryName>');
--- builds hello world image and pushes to the new ecr repo without Github personal access token
SELECT ecr_build(
'https://github.com/iasql/docker-helloworld',
(SELECT id FROM repository WHERE repository_name = '<repositoryName>')::varchar(255),
'.',
'main',
''
);
--- checks if the image is created in the database
SELECT image_tag
FROM repository_image
WHERE private_repository_id = (SELECT id FROM repository WHERE repository_name = '<repositoryName>');
--- deletes the image
DELETE
FROM repository_image
WHERE private_repository_id = (SELECT id FROM repository WHERE repository_name = '<repositoryName>');
--- deletes the repository
DELETE
FROM repository
WHERE repository_name = '<repositoryName>';