Skip to content

Commit

Permalink
Renames in the resource package
Browse files Browse the repository at this point in the history
* ExposedStatus => Status
* GetExposedStatus => GetStatus
* exposedStatusInfo => getStatusInfo
* exposedStatusInfoSched => getStatusInfoSched
  • Loading branch information
cvaroqui committed Sep 7, 2023
1 parent c37e351 commit e1f4610
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion core/instance/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Test_Status_Unmarshal(t *testing.T) {
Overall: status.Down,
Provisioned: provisioned.Mixed,
UpdatedAt: time.Date(2022, time.December, 28, 11, 21, 45, 800780633, time.UTC),
Resources: []resource.ExposedStatus{
Resources: []resource.Status{

Check failure on line 32 in core/instance/instance_test.go

View workflow job for this annotation

GitHub Actions / Go build and test

cannot use []resource.Status{…} (value of type []resource.Status) as ResourceStatuses value in struct literal
{
ResourceID: (*resourceid.T)(nil),
Rid: "volume#1",

Check failure on line 35 in core/instance/instance_test.go

View workflow job for this annotation

GitHub Actions / Go build and test

unknown field Rid in struct literal of type struct{ResourceID *resourceid.T "json:\"-\" yaml:\"-\""; Label string "json:\"label\" yaml:\"label\""; Log []*resource.StatusLogEntry "json:\"log,omitempty\" yaml:\"log,omitempty\""; Status status.T "json:\"status\" yaml:\"status\""; Type string "json:\"type\" yaml:\"type\""; Provisioned resource.ProvisionStatus "json:\"provisioned,omitempty\" yaml:\"provisioned,omitempty\""; Monitor resource.MonitorFlag "json:\"monitor,omitempty\" yaml:\"monitor,omitempty\""; Disable resource.DisableFlag "json:\"disable,omitempty\" yaml:\"disable,omitempty\""; Optional resource.OptionalFlag "json:\"optional,omitempty\" yaml:\"optional,omitempty\""; Encap resource.EncapFlag "json:\"encap,omitempty\" yaml:\"encap,omitempty\""; Standby resource.StandbyFlag "json:\"standby,omitempty\" yaml:\"standby,omitempty\""; Subset string "json:\"subset,omitempty\" yaml:\"subset,omitempty\""; Info map[string]any "json:\"info,omitempty\" yaml:\"info,omitempty\""; Restart resource.RestartFlag "json:\"restart,omitempty\" yaml:\"restart,omitempty\""; Tags resource.TagSet "json:\"tags,omitempty\" yaml:\"tags,omitempty\""}
Expand Down
2 changes: 1 addition & 1 deletion core/instance/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (m ResourceMonitors) DeepCopy() ResourceMonitors {
return xmap.Copy(m)
}

func (mon Monitor) ResourceFlagRestartString(rid resourceid.T, r resource.ExposedStatus) string {
func (mon Monitor) ResourceFlagRestartString(rid resourceid.T, r resource.Status) string {
// Restart and retries
retries := 0
if rmon := mon.Resources.Get(rid.Name); rmon != nil {
Expand Down
10 changes: 5 additions & 5 deletions core/instance/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ type (
UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`
}

ResourceStatuses map[string]resource.ExposedStatus
ResourceStatuses map[string]resource.Status

// ResourceRunningSet is the list of resource currently running (sync and task).
ResourceRunningSet []string

// ResourceOrder is a sortable list representation of the
// instance status resources map.
ResourceOrder []resource.ExposedStatus
ResourceOrder []resource.Status
)

func (m ResourceStatuses) DeepCopy() ResourceStatuses {
Expand All @@ -59,8 +59,8 @@ func (t ResourceRunningSet) Has(rid string) bool {
// 1/ driver group
// 2/ subset
// 3/ resource name
func (t *Status) SortedResources() []resource.ExposedStatus {
l := make([]resource.ExposedStatus, 0)
func (t *Status) SortedResources() []resource.Status {
l := make([]resource.Status, 0)
for rid, rstat := range t.Resources {
id, err := resourceid.Parse(rid)
if err != nil {
Expand Down Expand Up @@ -116,7 +116,7 @@ func (a ResourceOrder) Less(i, j int) bool {
// E Encap
// P Provisioned
// S Standby
func (t Status) ResourceFlagsString(rid resourceid.T, r resource.ExposedStatus) string {
func (t Status) ResourceFlagsString(rid resourceid.T, r resource.Status) string {
flags := ""

// Running task or sync
Expand Down
2 changes: 1 addition & 1 deletion core/object/actor_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (t *actor) resourceStatusEval(ctx context.Context, data *instance.Status) e
data.Resources = make(instance.ResourceStatuses)
var mu sync.Mutex
err := t.ResourceSets().Do(ctx, t, "", "status", func(ctx context.Context, r resource.Driver) error {
xd := resource.GetExposedStatus(ctx, r)
xd := resource.GetStatus(ctx, r)

// If the resource is up but the provisioned flag is unset, set
// the provisioned flag.
Expand Down
42 changes: 21 additions & 21 deletions core/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ type (
// TagSet is the list of unique tag names found in the resource definition.
TagSet []string

// ExposedStatus is the structure representing the resource status,
// Status is the structure representing the resource status,
// which is embedded in the instance status.
ExposedStatus struct {
Status struct {
ResourceID *resourceid.T `json:"-" yaml:"-"`
Label string `json:"label" yaml:"label"`
Log []*StatusLogEntry `json:"log,omitempty" yaml:"log,omitempty"`
Expand Down Expand Up @@ -234,7 +234,7 @@ type (

Hook int

ExposedStatusInfoSchedAction struct {
StatusInfoSchedAction struct {
Last time.Time `json:"last" yaml:"last"`
}

Expand Down Expand Up @@ -866,7 +866,7 @@ func Start(ctx context.Context, r Driver) error {
return nil
}

// Resync execute the resource Resync function, if exposed.
// Resync execute the resource Resync function, if implemented by the driver.
func Resync(ctx context.Context, r Driver) error {
var i any = r
s, ok := i.(resyncer)
Expand All @@ -885,7 +885,7 @@ func Resync(ctx context.Context, r Driver) error {
return nil
}

// Full execute the resource Update function, if exposed.
// Full execute the resource Update function, if implemented by the driver.
func Full(ctx context.Context, r Driver) error {
var i any = r
s, ok := i.(fuller)
Expand All @@ -904,7 +904,7 @@ func Full(ctx context.Context, r Driver) error {
return nil
}

// Update execute the resource Update function, if exposed.
// Update execute the resource Update function, if implemented by the driver.
func Update(ctx context.Context, r Driver) error {
var i any = r
s, ok := i.(updater)
Expand Down Expand Up @@ -1134,17 +1134,17 @@ func SCSIPersistentReservationStatus(r Driver) status.T {
}
}

// GetExposedStatus returns the resource exposed status data for embedding into the instance status data.
func GetExposedStatus(ctx context.Context, r Driver) ExposedStatus {
return ExposedStatus{
// GetStatus returns the resource Status for embedding into the instance.Status.
func GetStatus(ctx context.Context, r Driver) Status {
return Status{
Label: formatResourceLabel(r),
Type: r.Manifest().DriverID.String(),
Status: EvalStatus(ctx, r),
Subset: r.RSubset(),
Tags: r.TagSet(),
Log: r.StatusLog().Entries(),
Provisioned: getProvisionStatus(r),
Info: exposedStatusInfo(r),
Info: getStatusInfo(r),
Restart: RestartFlag(r.RestartCount()),
Optional: OptionalFlag(r.IsOptional()),
Standby: StandbyFlag(r.IsStandby()),
Expand All @@ -1154,7 +1154,7 @@ func GetExposedStatus(ctx context.Context, r Driver) ExposedStatus {
}

func printStatus(ctx context.Context, r Driver) error {
data := GetExposedStatus(ctx, r)
data := GetStatus(ctx, r)
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
return enc.Encode(data)
Expand Down Expand Up @@ -1214,37 +1214,37 @@ func (t *T) DoWithLock(disable bool, timeout time.Duration, intent string, f fun
return f()
}

func exposedStatusInfo(t Driver) (data map[string]any) {
func getStatusInfo(t Driver) (data map[string]any) {
if i, ok := t.(StatusInfoer); ok {
data = i.StatusInfo()
} else {
data = make(map[string]any)
}
if i, ok := t.(Scheduler); ok {
data["sched"] = exposedStatusInfoSched(i)
data["sched"] = getStatusInfoSched(i)
}
return data
}

func exposedStatusInfoSched(t Scheduler) map[string]ExposedStatusInfoSchedAction {
data := make(map[string]ExposedStatusInfoSchedAction)
func getStatusInfoSched(t Scheduler) map[string]StatusInfoSchedAction {
data := make(map[string]StatusInfoSchedAction)
for _, e := range t.Schedules() {
ad := ExposedStatusInfoSchedAction{
ad := StatusInfoSchedAction{
Last: e.LastRunAt,
}
data[e.Action] = ad
}
return data
}

func (exposedStatus ExposedStatus) DeepCopy() *ExposedStatus {
newValue := ExposedStatus{}
if b, err := json.Marshal(exposedStatus); err != nil {
return &ExposedStatus{}
func (rstat Status) DeepCopy() *Status {
newValue := Status{}
if b, err := json.Marshal(rstat); err != nil {
return &Status{}
} else if err := json.Unmarshal(b, &newValue); err == nil {
return &newValue
}
return &ExposedStatus{}
return &Status{}
}

func (t SCSIPersistentReservation) IsSCSIPersistentReservationPreemptAbortDisabled() bool {
Expand Down
2 changes: 1 addition & 1 deletion daemon/dns/main_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (t *dns) onInstanceStatusUpdated(c *msgbus.InstanceStatusUpdated) {
})

}
stageSRVs := func(r resource.ExposedStatus) {
stageSRVs := func(r resource.Status) {
i, ok := r.Info[exposeInfoKey]
if !ok {
return
Expand Down

0 comments on commit e1f4610

Please sign in to comment.