summaryrefslogtreecommitdiff
path: root/internal/resource/resource.go
blob: b0f60575a6f0bf6d1377427cd6b0ae972f4b9260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package resource

import (
	"fmt"
)

type Resource struct {
	Type      string
	Name      string
	dependsOn map[string]struct{}
}

func Register(type_, name string) Resource {
	r := Resource{
		Type:      type_,
		Name:      name,
		dependsOn: make(map[string]struct{}),
	}

	if err := getRepository().register(r); err != nil {
		panic(err)
	}

	return r
}

func (r Resource) String() string {
	return r.ID()
}

func (r Resource) ID() string {
	return fmt.Sprintf("%s[%s]", r.Type, r.Name)
}