generated from kyma-project/template-repository
/
state.go
49 lines (37 loc) · 973 Bytes
/
state.go
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package focal
import (
cloudresourcesv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
"github.com/kyma-project/cloud-manager/pkg/composed"
)
type State interface {
composed.State
Scope() *cloudresourcesv1beta1.Scope
SetScope(*cloudresourcesv1beta1.Scope)
ObjAsCommonObj() CommonObject
}
type StateFactory interface {
NewState(base composed.State) State
}
func NewStateFactory() StateFactory {
return &stateFactory{}
}
type stateFactory struct{}
func (f *stateFactory) NewState(base composed.State) State {
return &state{
State: base,
}
}
// ========================================================================
type state struct {
composed.State
scope *cloudresourcesv1beta1.Scope
}
func (s *state) Scope() *cloudresourcesv1beta1.Scope {
return s.scope
}
func (s *state) SetScope(scope *cloudresourcesv1beta1.Scope) {
s.scope = scope
}
func (s *state) ObjAsCommonObj() CommonObject {
return s.Obj().(CommonObject)
}