@@ -20,6 +20,7 @@ provider "codefresh" {
20
20
21
21
resource "codefresh_registry" "acr" {
22
22
name = " acr"
23
+ default = true
23
24
spec {
24
25
acr {
25
26
domain = " acr.io"
@@ -32,6 +33,8 @@ resource "codefresh_registry" "acr" {
32
33
33
34
resource "codefresh_registry" "gcr" {
34
35
name = " gcr"
36
+ # all registries SHOULD be dependent on each other to be created/updated sequentially
37
+ depends_on = [codefresh_registry . acr ]
35
38
spec {
36
39
gcr {
37
40
domain = " gcr.io"
@@ -43,6 +46,7 @@ resource "codefresh_registry" "gcr" {
43
46
44
47
resource "codefresh_registry" "gar" {
45
48
name = " gar"
49
+ depends_on = [codefresh_registry . gcr ]
46
50
spec {
47
51
gar {
48
52
domain = " asia"
@@ -52,19 +56,27 @@ resource "codefresh_registry" "gar" {
52
56
}
53
57
}
54
58
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" {
56
65
name = " dockerhub1"
57
- primary = false
66
+ primary = ! data. codefresh_registry . dockerhub . primary
67
+ depends_on = [codefresh_registry . gar ]
58
68
spec {
59
69
dockerhub {
60
70
username = " test"
61
71
password = " test"
62
72
}
63
73
}
74
+ fallback_registry = data. codefresh_registry . dockerhub . id
64
75
}
65
76
66
77
resource "codefresh_registry" "bintray" {
67
78
name = " bintray"
79
+ depends_on = [codefresh_registry . dockerhub1 ]
68
80
spec {
69
81
bintray {
70
82
domain = " bintray.io"
@@ -76,7 +88,8 @@ resource "codefresh_registry" "bintray" {
76
88
77
89
resource "codefresh_registry" "other" {
78
90
name = " other"
79
- primary = true
91
+ depends_on = [codefresh_registry . bintray ]
92
+ primary = false
80
93
spec {
81
94
other {
82
95
domain = " other.io"
@@ -86,9 +99,14 @@ resource "codefresh_registry" "other" {
86
99
}
87
100
}
88
101
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`
89
106
resource "codefresh_registry" "other1" {
90
107
name = " other1"
91
- primary = false
108
+ primary = true
109
+ depends_on = [codefresh_registry . other ]
92
110
spec {
93
111
other {
94
112
domain = " other.io"
@@ -101,11 +119,13 @@ resource "codefresh_registry" "other1" {
101
119
resource "codefresh_registry" "other2" {
102
120
name = " other2"
103
121
primary = false
122
+ depends_on = [codefresh_registry . other1 , codefresh_registry . bintray ]
104
123
spec {
105
124
other {
106
125
domain = " other.io"
107
126
username = " test"
108
127
password = " test"
109
128
}
110
129
}
130
+ fallback_registry = codefresh_registry. bintray . id
111
131
}
0 commit comments