MCPcopy Create free account
hub / github.com/bytebase/bytebase / UpdateLicense

Method UpdateLicense

backend/store/setting.go:125–147  ·  view source on GitHub ↗

UpdateLicense updates the license in SYSTEM setting.

(ctx context.Context, workspaceID string, license string)

Source from the content-addressed store, hash-verified

123
124// UpdateLicense updates the license in SYSTEM setting.
125func (s *Store) UpdateLicense(ctx context.Context, workspaceID string, license string) error {
126 setting, err := s.GetSetting(ctx, workspaceID, storepb.SettingName_SYSTEM)
127 if err != nil {
128 return errors.Wrap(err, "failed to get system setting")
129 }
130 if setting == nil {
131 return errors.Errorf("system setting not found")
132 }
133 systemSetting, ok := setting.Value.(*storepb.SystemSetting)
134 if !ok {
135 return errors.Errorf("invalid system setting value type for %s", storepb.SettingName_SYSTEM)
136 }
137
138 systemSetting.License = license
139 if _, err := s.UpsertSetting(ctx, &SettingMessage{
140 Name: storepb.SettingName_SYSTEM,
141 Workspace: setting.Workspace,
142 Value: systemSetting,
143 }); err != nil {
144 return errors.Wrap(err, "failed to upsert system setting")
145 }
146 return nil
147}
148
149// GetWorkspaceApprovalSetting gets the workspace approval setting.
150func (s *Store) GetWorkspaceApprovalSetting(ctx context.Context, workspaceID string) (*storepb.WorkspaceApprovalSetting, error) {

Callers 1

StoreLicenseMethod · 0.80

Calls 3

GetSettingMethod · 0.95
UpsertSettingMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected