UpdateLicense updates the license in SYSTEM setting.
(ctx context.Context, workspaceID string, license string)
| 123 | |
| 124 | // UpdateLicense updates the license in SYSTEM setting. |
| 125 | func (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. |
| 150 | func (s *Store) GetWorkspaceApprovalSetting(ctx context.Context, workspaceID string) (*storepb.WorkspaceApprovalSetting, error) { |
no test coverage detected