@@ -11,8 +11,8 @@ import (
1111// It adds the project ID and zone to the base struct
1212// and makes them available to concrete wrapper implementations.
1313type ZoneBase struct {
14- projectID string
15- zone string
14+ GCPBase
15+ zone string
1616
1717 * shared.Base
1818}
@@ -25,8 +25,10 @@ func NewZoneBase(
2525 item shared.ItemType ,
2626) * ZoneBase {
2727 return & ZoneBase {
28- projectID : projectID ,
29- zone : zone ,
28+ GCPBase : GCPBase {
29+ projectID : projectID ,
30+ },
31+ zone : zone ,
3032 Base : shared .NewBase (
3133 category ,
3234 item ,
@@ -35,11 +37,6 @@ func NewZoneBase(
3537 }
3638}
3739
38- // ProjectID returns the project ID
39- func (m * ZoneBase ) ProjectID () string {
40- return m .projectID
41- }
42-
4340// Zone returns the zone
4441func (m * ZoneBase ) Zone () string {
4542 return m .zone
@@ -55,8 +52,8 @@ func (m *ZoneBase) DefaultScope() string {
5552// It adds the project ID and region to the base struct
5653// and makes them available to concrete wrapper implementations.
5754type RegionBase struct {
58- projectID string
59- region string
55+ GCPBase
56+ region string
6057
6158 * shared.Base
6259}
@@ -69,8 +66,10 @@ func NewRegionBase(
6966 item shared.ItemType ,
7067) * RegionBase {
7168 return & RegionBase {
72- projectID : projectID ,
73- region : region ,
69+ GCPBase : GCPBase {
70+ projectID : projectID ,
71+ },
72+ region : region ,
7473 Base : shared .NewBase (
7574 category ,
7675 item ,
@@ -79,11 +78,6 @@ func NewRegionBase(
7978 }
8079}
8180
82- // ProjectID returns the project ID
83- func (m * RegionBase ) ProjectID () string {
84- return m .projectID
85- }
86-
8781// Region returns the region
8882func (m * RegionBase ) Region () string {
8983 return m .region
@@ -99,7 +93,7 @@ func (m *RegionBase) DefaultScope() string {
9993// It adds the project ID to the base struct
10094// and makes them available to concrete wrapper implementations.
10195type ProjectBase struct {
102- projectID string
96+ GCPBase
10397
10498 * shared.Base
10599}
@@ -111,7 +105,9 @@ func NewProjectBase(
111105 item shared.ItemType ,
112106) * ProjectBase {
113107 return & ProjectBase {
114- projectID : projectID ,
108+ GCPBase : GCPBase {
109+ projectID : projectID ,
110+ },
115111 Base : shared .NewBase (
116112 category ,
117113 item ,
@@ -120,13 +116,20 @@ func NewProjectBase(
120116 }
121117}
122118
123- // ProjectID returns the project ID
124- func (m * ProjectBase ) ProjectID () string {
125- return m .projectID
126- }
127-
128119// DefaultScope returns the default scope
129120// Project ID is used to create the default scope.
130121func (m * ProjectBase ) DefaultScope () string {
131122 return m .Scopes ()[0 ]
132123}
124+
125+ type GCPBase struct {
126+ projectID string
127+ }
128+
129+ func (g * GCPBase ) PredefinedRole () string {
130+ panic ("Predefined role not implemented" )
131+ }
132+
133+ func (g * GCPBase ) ProjectID () string {
134+ return g .projectID
135+ }
0 commit comments