@@ -20,6 +20,7 @@ provider "codefresh" {
2020
2121resource "codefresh_registry" "acr" {
2222 name = " acr"
23+ default = true
2324 spec {
2425 acr {
2526 domain = " acr.io"
@@ -32,6 +33,8 @@ resource "codefresh_registry" "acr" {
3233
3334resource "codefresh_registry" "gcr" {
3435 name = " gcr"
36+ # all registries SHOULD be dependent on each other to be created/updated sequentially
37+ depends_on = [codefresh_registry . acr ]
3538 spec {
3639 gcr {
3740 domain = " gcr.io"
@@ -43,6 +46,7 @@ resource "codefresh_registry" "gcr" {
4346
4447resource "codefresh_registry" "gar" {
4548 name = " gar"
49+ depends_on = [codefresh_registry . gcr ]
4650 spec {
4751 gar {
4852 domain = " asia"
@@ -52,19 +56,27 @@ resource "codefresh_registry" "gar" {
5256 }
5357}
5458
55- resource "codefresh_registry" "dockerhub" {
59+ data "codefresh_registry" "dockerhub" {
60+ name = " dockerhub"
61+ }
62+
63+ # example with using data reference to existing registry, not managed by terraform
64+ resource "codefresh_registry" "dockerhub1" {
5665 name = " dockerhub1"
57- primary = false
66+ primary = ! data. codefresh_registry . dockerhub . primary
67+ depends_on = [codefresh_registry . gar ]
5868 spec {
5969 dockerhub {
6070 username = " test"
6171 password = " test"
6272 }
6373 }
74+ fallback_registry = data. codefresh_registry . dockerhub . id
6475}
6576
6677resource "codefresh_registry" "bintray" {
6778 name = " bintray"
79+ depends_on = [codefresh_registry . dockerhub1 ]
6880 spec {
6981 bintray {
7082 domain = " bintray.io"
@@ -76,7 +88,8 @@ resource "codefresh_registry" "bintray" {
7688
7789resource "codefresh_registry" "other" {
7890 name = " other"
79- primary = true
91+ depends_on = [codefresh_registry . bintray ]
92+ primary = false
8093 spec {
8194 other {
8295 domain = " other.io"
@@ -86,9 +99,14 @@ resource "codefresh_registry" "other" {
8699 }
87100}
88101
102+ # when you have multiple registries under the same domain
103+ # they MUST be dependant on each other and `primary`
104+ # MUST be specified at least and only for one registry
105+ # as `true`
89106resource "codefresh_registry" "other1" {
90107 name = " other1"
91- primary = false
108+ primary = true
109+ depends_on = [codefresh_registry . other ]
92110 spec {
93111 other {
94112 domain = " other.io"
@@ -101,11 +119,13 @@ resource "codefresh_registry" "other1" {
101119resource "codefresh_registry" "other2" {
102120 name = " other2"
103121 primary = false
122+ depends_on = [codefresh_registry . other1 , codefresh_registry . bintray ]
104123 spec {
105124 other {
106125 domain = " other.io"
107126 username = " test"
108127 password = " test"
109128 }
110129 }
130+ fallback_registry = codefresh_registry. bintray . id
111131}
0 commit comments