Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Make State/Status/Resource More Readable #1181

Merged
merged 6 commits into from
Oct 17, 2022

Conversation

daniel-hutao
Copy link
Member

@daniel-hutao daniel-hutao commented Oct 17, 2022

Pre-Checklist

Note: please complete ALL items in the following checklist.

  • I have read through the CONTRIBUTING.md documentation.
  • My code has the necessary comments and documentation (if needed).
  • I have added relevant tests

Description

  1. Resource -> ResourceStatus in State
type ResourceStatus map[string]interface{}

// State is the single component's state.
type State struct {
	Name           string
	InstanceID     string
	DependsOn      []string
	Options        map[string]interface{}
	ResourceStatus ResourceStatus
}
  1. State -> ResourceStatusInState, Resource -> ResourceStatusFromRead in Status (outputs)

internal/pkg/show/status/output.go

type Status struct {
	// if ResourceStatusInState == ResourceStatusFromRead,
	// then InlineStatus is set to equals ResourceStatusInState and ResourceStatusFromRead.
	InlineStatus           statemanager.ResourceStatus `yaml:",inline,omitempty"`
	ResourceStatusInState  statemanager.ResourceStatus `yaml:"statusInState,omitempty"`
	ResourceStatusFromRead statemanager.ResourceStatus `yaml:"statusNow,omitempty"`
}
  1. GetStateOperation -> GetStatusOperation in plugininstaller

  2. Based on the above changes, all other needed adjustments were adjusted.

Related Issues

N/A

New Behavior (screenshots if needed)

Refactoring only

Signed-off-by: Daniel Hu <tao.hu@merico.dev>
Signed-off-by: Daniel Hu <tao.hu@merico.dev>
Signed-off-by: Daniel Hu <tao.hu@merico.dev>
@daniel-hutao daniel-hutao force-pushed the refactor-ht branch 3 times, most recently from e7f388e to f634070 Compare October 17, 2022 11:06
@daniel-hutao daniel-hutao marked this pull request as ready for review October 17, 2022 11:10
@daniel-hutao daniel-hutao requested review from IronCore864 and a team as code owners October 17, 2022 11:10
@daniel-hutao daniel-hutao changed the title Refactor: State/Status/Resource Refactoring Refactor: Make State/Status/Resource More Readable Oct 17, 2022
Signed-off-by: Daniel Hu <tao.hu@merico.dev>
Signed-off-by: Daniel Hu <tao.hu@merico.dev>
Copy link
Member

@aFlyBird0 aFlyBird0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resource -> resourcestatus

ci err:
image

code:

"test_key:\n name: %s\n instanceid: %s\n dependson: []\n options: {}\n resource: {}\n",

err:
image

code:
image

docs/core-concepts/core-concepts.zh.md Show resolved Hide resolved
Copy link
Contributor

@steinliber steinliber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Daniel Hu <tao.hu@merico.dev>
@daniel-hutao
Copy link
Member Author

The "link checker" error isn't raised by this pr.

@daniel-hutao daniel-hutao merged commit 0e3390f into devstream-io:main Oct 17, 2022
@daniel-hutao daniel-hutao deleted the refactor-ht branch October 17, 2022 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants