Skip to content

Commit 8865713

Browse files
authored
refactor: change urn format as per OIP-001-unified-urn (#78)
1 parent 588e37c commit 8865713

File tree

5 files changed

+53
-53
lines changed

5 files changed

+53
-53
lines changed

core/resource/resource.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ func (f Filter) isMatch(r Resource) bool {
119119
}
120120

121121
func generateURN(res Resource) string {
122-
parts := []string{"urn", "odpf", "entropy", res.Kind, res.Project, res.Name}
122+
parts := []string{"orn", "entropy", res.Kind, res.Project, res.Name}
123123
return strings.Join(parts, urnSeparator)
124124
}

core/write_test.go

+38-38
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func TestService_CreateResource(t *testing.T) {
133133
Enqueue(mock.Anything, mock.Anything).
134134
Run(func(ctx context.Context, jobs ...worker.Job) {
135135
assert.Len(t, jobs, 1)
136-
assert.Equal(t, "sync-urn:odpf:entropy:mock:project:child-1650536955", jobs[0].ID)
136+
assert.Equal(t, "sync-orn:entropy:mock:project:child-1650536955", jobs[0].ID)
137137
}).
138138
Return(nil)
139139

@@ -145,7 +145,7 @@ func TestService_CreateResource(t *testing.T) {
145145
Project: "project",
146146
},
147147
want: &resource.Resource{
148-
URN: "urn:odpf:entropy:mock:project:child",
148+
URN: "orn:entropy:mock:project:child",
149149
Kind: "mock",
150150
Name: "child",
151151
Project: "project",
@@ -179,7 +179,7 @@ func TestService_UpdateResource(t *testing.T) {
179179
t.Parallel()
180180
testErr := errors.New("failed")
181181
testResource := resource.Resource{
182-
URN: "urn:odpf:entropy:mock:project:child",
182+
URN: "orn:entropy:mock:project:child",
183183
Kind: "mock",
184184
Name: "child",
185185
Project: "project",
@@ -201,13 +201,13 @@ func TestService_UpdateResource(t *testing.T) {
201201
t.Helper()
202202
resourceRepo := &mocks.ResourceStore{}
203203
resourceRepo.EXPECT().
204-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:project:child").
204+
GetByURN(mock.Anything, "orn:entropy:mock:project:child").
205205
Return(nil, errors.ErrNotFound).
206206
Once()
207207

208208
return core.New(resourceRepo, nil, &mocks.AsyncWorker{}, deadClock, nil)
209209
},
210-
urn: "urn:odpf:entropy:mock:project:child",
210+
urn: "orn:entropy:mock:project:child",
211211
newSpec: resource.Spec{Configs: []byte(`{"foo": "bar"}`)},
212212
want: nil,
213213
wantErr: errors.ErrNotFound,
@@ -223,13 +223,13 @@ func TestService_UpdateResource(t *testing.T) {
223223

224224
resourceRepo := &mocks.ResourceStore{}
225225
resourceRepo.EXPECT().
226-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:project:child").
226+
GetByURN(mock.Anything, "orn:entropy:mock:project:child").
227227
Return(&testResource, nil).
228228
Once()
229229

230230
return core.New(resourceRepo, mod, &mocks.AsyncWorker{}, deadClock, nil)
231231
},
232-
urn: "urn:odpf:entropy:mock:project:child",
232+
urn: "orn:entropy:mock:project:child",
233233
newSpec: resource.Spec{Configs: []byte(`{"foo": "bar"}`)},
234234
want: nil,
235235
wantErr: errors.ErrInvalid,
@@ -245,7 +245,7 @@ func TestService_UpdateResource(t *testing.T) {
245245

246246
resourceRepo := &mocks.ResourceStore{}
247247
resourceRepo.EXPECT().
248-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:project:child").
248+
GetByURN(mock.Anything, "orn:entropy:mock:project:child").
249249
Return(&testResource, nil).
250250
Once()
251251

@@ -262,15 +262,15 @@ func TestService_UpdateResource(t *testing.T) {
262262
Enqueue(mock.Anything, mock.Anything).
263263
Run(func(ctx context.Context, jobs ...worker.Job) {
264264
assert.Len(t, jobs, 1)
265-
assert.Equal(t, jobs[0].ID, "sync-urn:odpf:entropy:mock:project:child-1650536955")
265+
assert.Equal(t, jobs[0].ID, "sync-orn:entropy:mock:project:child-1650536955")
266266
assert.Equal(t, jobs[0].Kind, "sync_resource")
267267
}).
268268
Return(nil).
269269
Once()
270270

271271
return core.New(resourceRepo, mod, mockWorker, deadClock, nil)
272272
},
273-
urn: "urn:odpf:entropy:mock:project:child",
273+
urn: "orn:entropy:mock:project:child",
274274
newSpec: resource.Spec{Configs: []byte(`{"foo": "bar"}`)},
275275
want: nil,
276276
wantErr: testErr,
@@ -283,7 +283,7 @@ func TestService_UpdateResource(t *testing.T) {
283283
mod.EXPECT().
284284
Plan(mock.Anything, mock.Anything, mock.Anything).
285285
Return(&resource.Resource{
286-
URN: "urn:odpf:entropy:mock:project:child",
286+
URN: "orn:entropy:mock:project:child",
287287
Kind: "mock",
288288
Name: "child",
289289
Project: "project",
@@ -296,7 +296,7 @@ func TestService_UpdateResource(t *testing.T) {
296296

297297
resourceRepo := &mocks.ResourceStore{}
298298
resourceRepo.EXPECT().
299-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:project:child").
299+
GetByURN(mock.Anything, "orn:entropy:mock:project:child").
300300
Return(&testResource, nil).Once()
301301

302302
resourceRepo.EXPECT().
@@ -314,17 +314,17 @@ func TestService_UpdateResource(t *testing.T) {
314314
Return(nil).
315315
Run(func(ctx context.Context, jobs ...worker.Job) {
316316
assert.Len(t, jobs, 1)
317-
assert.Equal(t, jobs[0].ID, "sync-urn:odpf:entropy:mock:project:child-1650536955")
317+
assert.Equal(t, jobs[0].ID, "sync-orn:entropy:mock:project:child-1650536955")
318318
assert.Equal(t, jobs[0].Kind, "sync_resource")
319319
}).
320320
Once()
321321

322322
return core.New(resourceRepo, mod, mockWorker, deadClock, nil)
323323
},
324-
urn: "urn:odpf:entropy:mock:project:child",
324+
urn: "orn:entropy:mock:project:child",
325325
newSpec: resource.Spec{Configs: []byte(`{"foo": "bar"}`)},
326326
want: &resource.Resource{
327-
URN: "urn:odpf:entropy:mock:project:child",
327+
URN: "orn:entropy:mock:project:child",
328328
Kind: "mock",
329329
Name: "child",
330330
Project: "project",
@@ -374,13 +374,13 @@ func TestService_DeleteResource(t *testing.T) {
374374
t.Helper()
375375
resourceRepo := &mocks.ResourceStore{}
376376
resourceRepo.EXPECT().
377-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:foo:bar").
377+
GetByURN(mock.Anything, "orn:entropy:mock:foo:bar").
378378
Return(nil, testErr).
379379
Once()
380380

381381
return core.New(resourceRepo, nil, &mocks.AsyncWorker{}, deadClock, nil)
382382
},
383-
urn: "urn:odpf:entropy:mock:foo:bar",
383+
urn: "orn:entropy:mock:foo:bar",
384384
wantErr: testErr,
385385
},
386386
{
@@ -391,7 +391,7 @@ func TestService_DeleteResource(t *testing.T) {
391391
mod.EXPECT().
392392
Plan(mock.Anything, mock.Anything, mock.Anything).
393393
Return(&resource.Resource{
394-
URN: "urn:odpf:entropy:mock:project:child",
394+
URN: "orn:entropy:mock:project:child",
395395
Kind: "mock",
396396
Name: "child",
397397
Project: "project",
@@ -402,9 +402,9 @@ func TestService_DeleteResource(t *testing.T) {
402402

403403
resourceRepo := &mocks.ResourceStore{}
404404
resourceRepo.EXPECT().
405-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:foo:bar").
405+
GetByURN(mock.Anything, "orn:entropy:mock:foo:bar").
406406
Return(&resource.Resource{
407-
URN: "urn:odpf:entropy:mock:project:child",
407+
URN: "orn:entropy:mock:project:child",
408408
Kind: "mock",
409409
Name: "child",
410410
Project: "project",
@@ -421,7 +421,7 @@ func TestService_DeleteResource(t *testing.T) {
421421

422422
return core.New(resourceRepo, mod, &mocks.AsyncWorker{}, deadClock, nil)
423423
},
424-
urn: "urn:odpf:entropy:mock:foo:bar",
424+
urn: "orn:entropy:mock:foo:bar",
425425
wantErr: errors.ErrInternal,
426426
},
427427
{
@@ -432,7 +432,7 @@ func TestService_DeleteResource(t *testing.T) {
432432
mod.EXPECT().
433433
Plan(mock.Anything, mock.Anything, mock.Anything).
434434
Return(&resource.Resource{
435-
URN: "urn:odpf:entropy:mock:project:child",
435+
URN: "orn:entropy:mock:project:child",
436436
Kind: "mock",
437437
Name: "child",
438438
Project: "project",
@@ -443,9 +443,9 @@ func TestService_DeleteResource(t *testing.T) {
443443

444444
resourceRepo := &mocks.ResourceStore{}
445445
resourceRepo.EXPECT().
446-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:foo:bar").
446+
GetByURN(mock.Anything, "orn:entropy:mock:foo:bar").
447447
Return(&resource.Resource{
448-
URN: "urn:odpf:entropy:mock:project:child",
448+
URN: "orn:entropy:mock:project:child",
449449
Kind: "mock",
450450
Name: "child",
451451
Project: "project",
@@ -462,7 +462,7 @@ func TestService_DeleteResource(t *testing.T) {
462462

463463
return core.New(resourceRepo, mod, &mocks.AsyncWorker{}, deadClock, nil)
464464
},
465-
urn: "urn:odpf:entropy:mock:foo:bar",
465+
urn: "orn:entropy:mock:foo:bar",
466466
wantErr: nil,
467467
},
468468
}
@@ -506,13 +506,13 @@ func TestService_ApplyAction(t *testing.T) {
506506
t.Helper()
507507
resourceRepo := &mocks.ResourceStore{}
508508
resourceRepo.EXPECT().
509-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:foo:bar").
509+
GetByURN(mock.Anything, "orn:entropy:mock:foo:bar").
510510
Return(nil, errors.ErrNotFound).
511511
Once()
512512

513513
return core.New(resourceRepo, nil, &mocks.AsyncWorker{}, deadClock, nil)
514514
},
515-
urn: "urn:odpf:entropy:mock:foo:bar",
515+
urn: "orn:entropy:mock:foo:bar",
516516
action: sampleAction,
517517
want: nil,
518518
wantErr: errors.ErrNotFound,
@@ -523,9 +523,9 @@ func TestService_ApplyAction(t *testing.T) {
523523
t.Helper()
524524
resourceRepo := &mocks.ResourceStore{}
525525
resourceRepo.EXPECT().
526-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:foo:bar").
526+
GetByURN(mock.Anything, "orn:entropy:mock:foo:bar").
527527
Return(&resource.Resource{
528-
URN: "urn:odpf:entropy:mock:foo:bar",
528+
URN: "orn:entropy:mock:foo:bar",
529529
Kind: "mock",
530530
Project: "foo",
531531
Name: "bar",
@@ -534,7 +534,7 @@ func TestService_ApplyAction(t *testing.T) {
534534

535535
return core.New(resourceRepo, nil, &mocks.AsyncWorker{}, deadClock, nil)
536536
},
537-
urn: "urn:odpf:entropy:mock:foo:bar",
537+
urn: "orn:entropy:mock:foo:bar",
538538
action: sampleAction,
539539
want: nil,
540540
wantErr: errors.ErrInvalid,
@@ -551,9 +551,9 @@ func TestService_ApplyAction(t *testing.T) {
551551

552552
resourceRepo := &mocks.ResourceStore{}
553553
resourceRepo.EXPECT().
554-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:foo:bar").
554+
GetByURN(mock.Anything, "orn:entropy:mock:foo:bar").
555555
Return(&resource.Resource{
556-
URN: "urn:odpf:entropy:mock:foo:bar",
556+
URN: "orn:entropy:mock:foo:bar",
557557
Kind: "mock",
558558
Project: "foo",
559559
Name: "bar",
@@ -563,7 +563,7 @@ func TestService_ApplyAction(t *testing.T) {
563563

564564
return core.New(resourceRepo, mod, &mocks.AsyncWorker{}, deadClock, nil)
565565
},
566-
urn: "urn:odpf:entropy:mock:foo:bar",
566+
urn: "orn:entropy:mock:foo:bar",
567567
action: sampleAction,
568568
want: nil,
569569
wantErr: errors.ErrInternal,
@@ -576,7 +576,7 @@ func TestService_ApplyAction(t *testing.T) {
576576
mod.EXPECT().
577577
Plan(mock.Anything, mock.Anything, sampleAction).
578578
Return(&resource.Resource{
579-
URN: "urn:odpf:entropy:mock:foo:bar",
579+
URN: "orn:entropy:mock:foo:bar",
580580
Kind: "mock",
581581
Project: "foo",
582582
Name: "bar",
@@ -586,9 +586,9 @@ func TestService_ApplyAction(t *testing.T) {
586586

587587
resourceRepo := &mocks.ResourceStore{}
588588
resourceRepo.EXPECT().
589-
GetByURN(mock.Anything, "urn:odpf:entropy:mock:foo:bar").
589+
GetByURN(mock.Anything, "orn:entropy:mock:foo:bar").
590590
Return(&resource.Resource{
591-
URN: "urn:odpf:entropy:mock:foo:bar",
591+
URN: "orn:entropy:mock:foo:bar",
592592
Kind: "mock",
593593
Project: "foo",
594594
Name: "bar",
@@ -603,10 +603,10 @@ func TestService_ApplyAction(t *testing.T) {
603603

604604
return core.New(resourceRepo, mod, &mocks.AsyncWorker{}, deadClock, nil)
605605
},
606-
urn: "urn:odpf:entropy:mock:foo:bar",
606+
urn: "orn:entropy:mock:foo:bar",
607607
action: sampleAction,
608608
want: &resource.Resource{
609-
URN: "urn:odpf:entropy:mock:foo:bar",
609+
URN: "orn:entropy:mock:foo:bar",
610610
Kind: "mock",
611611
Project: "foo",
612612
Name: "bar",

docs/concepts/resource-life-cycle.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ For instance, a [firehose](https://github.com/odpf/firehose) resource looks like
4949
"log_level": "INFO"
5050
},
5151
"dependencies": {
52-
"deployment_cluster": "urn:odpf:entropy:kubernetes:godata"
52+
"deployment_cluster": "orn:entropy:kubernetes:godata"
5353
}
5454
},
5555
"state": {
@@ -75,7 +75,7 @@ POST /api/v1beta1/resources
7575
"log_level": "INFO"
7676
},
7777
"dependencies": {
78-
"deployment_cluster": "urn:odpf:entropy:kubernetes:godata"
78+
"deployment_cluster": "orn:entropy:kubernetes:godata"
7979
}
8080
}
8181
```
@@ -88,7 +88,7 @@ Here is the resource returned
8888

8989
```
9090
{
91-
"urn": "urn:odpf:entropy:firehose:bar:foo",
91+
"urn": "orn:entropy:firehose:bar:foo",
9292
"created_at": "2022-04-28T11:00:00.000Z",
9393
"updated_at": "2022-04-28T11:00:00.000Z",
9494
"name": "foo",
@@ -98,7 +98,7 @@ Here is the resource returned
9898
"log_level": "INFO"
9999
},
100100
"dependencies": {
101-
"deployment_cluster": "urn:odpf:entropy:kubernetes:godata"
101+
"deployment_cluster": "orn:entropy:kubernetes:godata"
102102
},
103103
"state": {
104104
"status": "STATUS_PENDING",
@@ -120,7 +120,7 @@ A job-queue model is used to handle sync operations. Every mutation (create/upda
120120

121121
```
122122
{
123-
"urn": "urn:odpf:entropy:firehose:bar:foo",
123+
"urn": "orn:entropy:firehose:bar:foo",
124124
"kind": "firehose",
125125
"name": "foo",
126126
"project": "bar",
@@ -130,7 +130,7 @@ A job-queue model is used to handle sync operations. Every mutation (create/upda
130130
"log_level": "INFO"
131131
},
132132
"dependencies": {
133-
"deployment_cluster": "urn:odpf:entropy:kubernetes:godata"
133+
"deployment_cluster": "orn:entropy:kubernetes:godata"
134134
},
135135
"state": {
136136
"status": "COMPLETED",
@@ -144,7 +144,7 @@ A job-queue model is used to handle sync operations. Every mutation (create/upda
144144
### 5. Execute Action
145145

146146
```
147-
POST /api/v1beta1/resources/urn:odpf:entropy:firehose:bar:foo/execute
147+
POST /api/v1beta1/resources/orn:entropy:firehose:bar:foo/execute
148148
149149
{
150150
"action": "increase_log_level"
@@ -155,7 +155,7 @@ This will trigger Plan again, and leave the resource in `STATUS_PENDING` state.
155155

156156
```
157157
{
158-
"urn": "urn:odpf:entropy:firehose:bar:foo",
158+
"urn": "orn:entropy:firehose:bar:foo",
159159
"kind": "firehose",
160160
"name": "foo",
161161
"project": "bar",
@@ -165,7 +165,7 @@ This will trigger Plan again, and leave the resource in `STATUS_PENDING` state.
165165
"log_level": "WARN"
166166
},
167167
"dependencies": {
168-
"deployment_cluster": "urn:odpf:entropy:kubernetes:godata"
168+
"deployment_cluster": "orn:entropy:kubernetes:godata"
169169
},
170170
"state": {
171171
"status": "PENDING",

docs/reference/api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ curl --location --request POST '{{HOST}}/api/v1beta1/resources' \
6666
"dependencies": [
6767
{
6868
"key": "kube_cluster",
69-
"value": "urn:odpf:entropy:kubernetes:test:p-godata-pilot"
69+
"value": "orn:entropy:kubernetes:test:p-godata-pilot"
7070
}
7171
],
7272
"configs": {

0 commit comments

Comments
 (0)