Skip to content

Commit 4633884

Browse files
fix: plugin exposed flags default value (#6332)
* plugin creation fix * isExposed * boolean pointer * migrate
1 parent c2a9b20 commit 4633884

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

pkg/plugin/GlobalPluginService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ func (impl *GlobalPluginServiceImpl) MigratePluginDataToParentPluginMetadata(plu
19411941
continue
19421942
}
19431943
parentMetadata := repository.NewPluginParentMetadata()
1944-
parentMetadata.SetParentPluginMetadata(pluginMetadata).CreateAuditLog(bean.SystemUserId)
1944+
parentMetadata.SetParentPluginMetadata(pluginMetadata).CreateAuditLog(bean.SystemUserId).WithIsExposed(true)
19451945
parentMetadata.Identifier = identifier
19461946
parentMetadata, err = impl.globalPluginRepository.SavePluginParentMetadata(tx, parentMetadata)
19471947
if err != nil {

pkg/plugin/adaptor/adaptor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import (
88

99
func GetPluginParentMetadataDbObject(pluginDto *pluginBean.PluginParentMetadataDto, userId int32) *repository.PluginParentMetadata {
1010
return repository.NewPluginParentMetadata().CreateAuditLog(userId).
11-
WithBasicMetadata(pluginDto.Name, pluginDto.PluginIdentifier, pluginDto.Description, pluginDto.Icon, repository.PLUGIN_TYPE_SHARED)
11+
WithBasicMetadata(pluginDto.Name, pluginDto.PluginIdentifier, pluginDto.Description, pluginDto.Icon, repository.PLUGIN_TYPE_SHARED, pluginDto.IsExposed)
1212
}
1313

1414
func GetPluginVersionMetadataDbObject(pluginDto *pluginBean.PluginParentMetadataDto, userId int32) *repository.PluginMetadata {
1515
versionDto := pluginDto.Versions.DetailedPluginVersionData[0]
16-
return repository.NewPluginVersionMetadata().CreateAuditLog(userId).WithBasicMetadata(pluginDto.Name, versionDto.Description, versionDto.Version, versionDto.DocLink)
16+
return repository.NewPluginVersionMetadata().CreateAuditLog(userId).WithBasicMetadata(pluginDto.Name, versionDto.Description, versionDto.Version, versionDto.DocLink, versionDto.IsExposed)
1717
}
1818

1919
func GetPluginStepDbObject(pluginStepDto *pluginBean.PluginStepsDto, pluginVersionMetadataId int, userId int32) *repository.PluginStep {

pkg/plugin/bean/bean.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type PluginMetadataDto struct {
5454
PluginStage string `json:"pluginStage,omitempty"`
5555
PluginSteps []*PluginStepsDto `json:"pluginSteps,omitempty"`
5656
AreNewTagsPresent bool `json:"areNewTagsPresent,omitempty"`
57+
IsExposed *bool `json:"-"`
5758
}
5859

5960
type PluginMinDto struct {
@@ -127,6 +128,7 @@ type PluginParentMetadataDto struct {
127128
Icon string `json:"icon,omitempty"`
128129
PluginStageType string `json:"pluginStageType,omitempty"`
129130
Versions *PluginVersions `json:"pluginVersions"`
131+
IsExposed *bool `json:"-"`
130132
}
131133

132134
func NewPluginParentMetadataDto() *PluginParentMetadataDto {

pkg/plugin/repository/GlobalPluginRepository.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,24 @@ func (r *PluginParentMetadata) CreateAuditLog(userId int32) *PluginParentMetadat
129129
r.UpdatedOn = time.Now()
130130
return r
131131
}
132+
func (r *PluginParentMetadata) WithIsExposed(isExposed bool) *PluginParentMetadata {
133+
r.IsExposed = isExposed
134+
return r
135+
}
132136

133-
func (r *PluginParentMetadata) WithBasicMetadata(name, identifier, description, icon string, pluginType PluginType) *PluginParentMetadata {
137+
func (r *PluginParentMetadata) WithBasicMetadata(name, identifier, description, icon string, pluginType PluginType, isExposed *bool) *PluginParentMetadata {
134138
r.Name = name
135139
r.Identifier = identifier
136140
r.Description = description
137141
r.Icon = icon
138142
r.Type = pluginType
139143
r.Deleted = false
144+
if isExposed != nil {
145+
r.IsExposed = *isExposed
146+
} else {
147+
//default set true
148+
r.IsExposed = true
149+
}
140150
return r
141151
}
142152

@@ -189,13 +199,19 @@ func (r *PluginMetadata) CreateAuditLog(userId int32) *PluginMetadata {
189199
return r
190200
}
191201

192-
func (r *PluginMetadata) WithBasicMetadata(name, description, pluginVersion, docLink string) *PluginMetadata {
202+
func (r *PluginMetadata) WithBasicMetadata(name, description, pluginVersion, docLink string, isExposed *bool) *PluginMetadata {
193203
r.Name = name
194204
r.PluginVersion = pluginVersion
195205
r.Description = description
196206
r.DocLink = docLink
197207
r.Deleted = false
198208
r.IsDeprecated = false
209+
if isExposed != nil {
210+
r.IsExposed = *isExposed
211+
} else {
212+
//default value is true
213+
r.IsExposed = true
214+
}
199215
return r
200216
}
201217

0 commit comments

Comments
 (0)