portal

package
v0.26.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiKey added in v0.9.0

type ApiKey struct {
	KeyID        string    `json:"keyId"`
	Owner        string    `json:"owner"`
	Organization string    `json:"organization"`
	Role         string    `json:"role"`
	CreatedAt    time.Time `json:"createdAt"`
	ExpiresAt    time.Time `json:"expiresAt"`
	// Temp
	ApiKey string `json:"apiKey"`
}

type Artifact

type Artifact struct {
	Md5Sum   string `json:"md5sum"`
	Filename string `json:"filename"`
	Name     string `json:"name"`
}

type Build

type Build struct {
	Version   string     `json:"version"`
	Date      time.Time  `json:"date"`
	Hash      string     `json:"hash"`
	Artifacts []Artifact `json:"artifacts"`
	Internal  bool       `json:"internal"`
}

func (*Build) GetBuildForDownload

func (b *Build) GetBuildForDownload(filename string) (Build, error)

type Builds

type Builds struct {
	Builds []Build `json:"builds"`
}

type Http added in v0.17.0

type Http interface {
	Request(url string, method string, body io.Reader) (responseBody []byte, err error)
	Get(url string) (responseBody []byte, err error)
	Download(url string, file io.Writer, quiet bool) error
}

type HttpClient

type HttpClient interface {
	Do(*http.Request) (*http.Response, error)
}

type HttpWrapper added in v0.17.0

type HttpWrapper struct {
	HttpClient HttpClient
}

func NewHttpWrapper added in v0.17.0

func NewHttpWrapper() *HttpWrapper

func (*HttpWrapper) Download added in v0.17.0

func (c *HttpWrapper) Download(url string, file io.Writer, quiet bool) error

func (*HttpWrapper) Get added in v0.17.0

func (c *HttpWrapper) Get(url string) (responseBody []byte, err error)

func (*HttpWrapper) Request added in v0.17.0

func (c *HttpWrapper) Request(url string, method string, body io.Reader) (responseBody []byte, err error)

type MockHttp added in v0.17.0

type MockHttp struct {
	mock.Mock
}

MockHttp is an autogenerated mock type for the Http type

func NewMockHttp added in v0.17.0

func NewMockHttp(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockHttp

NewMockHttp creates a new instance of MockHttp. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockHttp) Download added in v0.17.0

func (_mock *MockHttp) Download(url string, file io.Writer, quiet bool) error

Download provides a mock function for the type MockHttp

func (*MockHttp) EXPECT added in v0.17.0

func (_m *MockHttp) EXPECT() *MockHttp_Expecter

func (*MockHttp) Get added in v0.17.0

func (_mock *MockHttp) Get(url string) ([]byte, error)

Get provides a mock function for the type MockHttp

func (*MockHttp) Request added in v0.17.0

func (_mock *MockHttp) Request(url string, method string, body io.Reader) ([]byte, error)

Request provides a mock function for the type MockHttp

type MockHttpClient

type MockHttpClient struct {
	mock.Mock
}

MockHttpClient is an autogenerated mock type for the HttpClient type

func NewMockHttpClient

func NewMockHttpClient(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockHttpClient

NewMockHttpClient creates a new instance of MockHttpClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockHttpClient) Do

func (_mock *MockHttpClient) Do(request *http.Request) (*http.Response, error)

Do provides a mock function for the type MockHttpClient

func (*MockHttpClient) EXPECT

type MockHttpClient_Do_Call

type MockHttpClient_Do_Call struct {
	*mock.Call
}

MockHttpClient_Do_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Do'

func (*MockHttpClient_Do_Call) Return

func (_c *MockHttpClient_Do_Call) Return(response *http.Response, err error) *MockHttpClient_Do_Call

func (*MockHttpClient_Do_Call) Run

func (_c *MockHttpClient_Do_Call) Run(run func(request *http.Request)) *MockHttpClient_Do_Call

func (*MockHttpClient_Do_Call) RunAndReturn

func (_c *MockHttpClient_Do_Call) RunAndReturn(run func(request *http.Request) (*http.Response, error)) *MockHttpClient_Do_Call

type MockHttpClient_Expecter

type MockHttpClient_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockHttpClient_Expecter) Do

func (_e *MockHttpClient_Expecter) Do(request interface{}) *MockHttpClient_Do_Call

Do is a helper method to define mock.On call

  • request *http.Request

type MockHttp_Download_Call added in v0.17.0

type MockHttp_Download_Call struct {
	*mock.Call
}

MockHttp_Download_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Download'

func (*MockHttp_Download_Call) Return added in v0.17.0

func (*MockHttp_Download_Call) Run added in v0.17.0

func (_c *MockHttp_Download_Call) Run(run func(url string, file io.Writer, quiet bool)) *MockHttp_Download_Call

func (*MockHttp_Download_Call) RunAndReturn added in v0.17.0

func (_c *MockHttp_Download_Call) RunAndReturn(run func(url string, file io.Writer, quiet bool) error) *MockHttp_Download_Call

type MockHttp_Expecter added in v0.17.0

type MockHttp_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockHttp_Expecter) Download added in v0.17.0

func (_e *MockHttp_Expecter) Download(url interface{}, file interface{}, quiet interface{}) *MockHttp_Download_Call

Download is a helper method to define mock.On call

  • url string
  • file io.Writer
  • quiet bool

func (*MockHttp_Expecter) Get added in v0.17.0

func (_e *MockHttp_Expecter) Get(url interface{}) *MockHttp_Get_Call

Get is a helper method to define mock.On call

  • url string

func (*MockHttp_Expecter) Request added in v0.17.0

func (_e *MockHttp_Expecter) Request(url interface{}, method interface{}, body interface{}) *MockHttp_Request_Call

Request is a helper method to define mock.On call

  • url string
  • method string
  • body io.Reader

type MockHttp_Get_Call added in v0.17.0

type MockHttp_Get_Call struct {
	*mock.Call
}

MockHttp_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'

func (*MockHttp_Get_Call) Return added in v0.17.0

func (_c *MockHttp_Get_Call) Return(responseBody []byte, err error) *MockHttp_Get_Call

func (*MockHttp_Get_Call) Run added in v0.17.0

func (_c *MockHttp_Get_Call) Run(run func(url string)) *MockHttp_Get_Call

func (*MockHttp_Get_Call) RunAndReturn added in v0.17.0

func (_c *MockHttp_Get_Call) RunAndReturn(run func(url string) ([]byte, error)) *MockHttp_Get_Call

type MockHttp_Request_Call added in v0.17.0

type MockHttp_Request_Call struct {
	*mock.Call
}

MockHttp_Request_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Request'

func (*MockHttp_Request_Call) Return added in v0.17.0

func (_c *MockHttp_Request_Call) Return(responseBody []byte, err error) *MockHttp_Request_Call

func (*MockHttp_Request_Call) Run added in v0.17.0

func (_c *MockHttp_Request_Call) Run(run func(url string, method string, body io.Reader)) *MockHttp_Request_Call

func (*MockHttp_Request_Call) RunAndReturn added in v0.17.0

func (_c *MockHttp_Request_Call) RunAndReturn(run func(url string, method string, body io.Reader) ([]byte, error)) *MockHttp_Request_Call

type MockPortal

type MockPortal struct {
	mock.Mock
}

MockPortal is an autogenerated mock type for the Portal type

func NewMockPortal

func NewMockPortal(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockPortal

NewMockPortal creates a new instance of MockPortal. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockPortal) DownloadBuildArtifact

func (_mock *MockPortal) DownloadBuildArtifact(product Product, build Build, file io.Writer, startByte int, quiet bool) error

DownloadBuildArtifact provides a mock function for the type MockPortal

func (*MockPortal) EXPECT

func (_m *MockPortal) EXPECT() *MockPortal_Expecter

func (*MockPortal) GetApiKeyId added in v0.17.1

func (_mock *MockPortal) GetApiKeyId(oldKey string) (string, error)

GetApiKeyId provides a mock function for the type MockPortal

func (*MockPortal) GetBuild

func (_mock *MockPortal) GetBuild(product Product, version string, hash string) (Build, error)

GetBuild provides a mock function for the type MockPortal

func (*MockPortal) ListAPIKeys added in v0.11.0

func (_mock *MockPortal) ListAPIKeys() ([]ApiKey, error)

ListAPIKeys provides a mock function for the type MockPortal

func (*MockPortal) ListBuilds

func (_mock *MockPortal) ListBuilds(product Product) (Builds, error)

ListBuilds provides a mock function for the type MockPortal

func (*MockPortal) RegisterAPIKey

func (_mock *MockPortal) RegisterAPIKey(owner string, organization string, role string, expiresAt time.Time) (*ApiKey, error)

RegisterAPIKey provides a mock function for the type MockPortal

func (*MockPortal) RevokeAPIKey

func (_mock *MockPortal) RevokeAPIKey(key string) error

RevokeAPIKey provides a mock function for the type MockPortal

func (*MockPortal) UpdateAPIKey added in v0.12.0

func (_mock *MockPortal) UpdateAPIKey(key string, expiresAt time.Time) error

UpdateAPIKey provides a mock function for the type MockPortal

func (*MockPortal) VerifyBuildArtifactDownload added in v0.18.0

func (_mock *MockPortal) VerifyBuildArtifactDownload(file io.Reader, download Build) error

VerifyBuildArtifactDownload provides a mock function for the type MockPortal

type MockPortal_DownloadBuildArtifact_Call

type MockPortal_DownloadBuildArtifact_Call struct {
	*mock.Call
}

MockPortal_DownloadBuildArtifact_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DownloadBuildArtifact'

func (*MockPortal_DownloadBuildArtifact_Call) Return

func (*MockPortal_DownloadBuildArtifact_Call) Run

func (_c *MockPortal_DownloadBuildArtifact_Call) Run(run func(product Product, build Build, file io.Writer, startByte int, quiet bool)) *MockPortal_DownloadBuildArtifact_Call

func (*MockPortal_DownloadBuildArtifact_Call) RunAndReturn

func (_c *MockPortal_DownloadBuildArtifact_Call) RunAndReturn(run func(product Product, build Build, file io.Writer, startByte int, quiet bool) error) *MockPortal_DownloadBuildArtifact_Call

type MockPortal_Expecter

type MockPortal_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockPortal_Expecter) DownloadBuildArtifact

func (_e *MockPortal_Expecter) DownloadBuildArtifact(product interface{}, build interface{}, file interface{}, startByte interface{}, quiet interface{}) *MockPortal_DownloadBuildArtifact_Call

DownloadBuildArtifact is a helper method to define mock.On call

  • product Product
  • build Build
  • file io.Writer
  • startByte int
  • quiet bool

func (*MockPortal_Expecter) GetApiKeyId added in v0.17.1

func (_e *MockPortal_Expecter) GetApiKeyId(oldKey interface{}) *MockPortal_GetApiKeyId_Call

GetApiKeyId is a helper method to define mock.On call

  • oldKey string

func (*MockPortal_Expecter) GetBuild

func (_e *MockPortal_Expecter) GetBuild(product interface{}, version interface{}, hash interface{}) *MockPortal_GetBuild_Call

GetBuild is a helper method to define mock.On call

  • product Product
  • version string
  • hash string

func (*MockPortal_Expecter) ListAPIKeys added in v0.11.0

ListAPIKeys is a helper method to define mock.On call

func (*MockPortal_Expecter) ListBuilds

func (_e *MockPortal_Expecter) ListBuilds(product interface{}) *MockPortal_ListBuilds_Call

ListBuilds is a helper method to define mock.On call

  • product Product

func (*MockPortal_Expecter) RegisterAPIKey

func (_e *MockPortal_Expecter) RegisterAPIKey(owner interface{}, organization interface{}, role interface{}, expiresAt interface{}) *MockPortal_RegisterAPIKey_Call

RegisterAPIKey is a helper method to define mock.On call

  • owner string
  • organization string
  • role string
  • expiresAt time.Time

func (*MockPortal_Expecter) RevokeAPIKey

func (_e *MockPortal_Expecter) RevokeAPIKey(key interface{}) *MockPortal_RevokeAPIKey_Call

RevokeAPIKey is a helper method to define mock.On call

  • key string

func (*MockPortal_Expecter) UpdateAPIKey added in v0.12.0

func (_e *MockPortal_Expecter) UpdateAPIKey(key interface{}, expiresAt interface{}) *MockPortal_UpdateAPIKey_Call

UpdateAPIKey is a helper method to define mock.On call

  • key string
  • expiresAt time.Time

func (*MockPortal_Expecter) VerifyBuildArtifactDownload added in v0.18.0

func (_e *MockPortal_Expecter) VerifyBuildArtifactDownload(file interface{}, download interface{}) *MockPortal_VerifyBuildArtifactDownload_Call

VerifyBuildArtifactDownload is a helper method to define mock.On call

  • file io.Reader
  • download Build

type MockPortal_GetApiKeyId_Call added in v0.17.1

type MockPortal_GetApiKeyId_Call struct {
	*mock.Call
}

MockPortal_GetApiKeyId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetApiKeyId'

func (*MockPortal_GetApiKeyId_Call) Return added in v0.17.1

func (*MockPortal_GetApiKeyId_Call) Run added in v0.17.1

func (*MockPortal_GetApiKeyId_Call) RunAndReturn added in v0.17.1

func (_c *MockPortal_GetApiKeyId_Call) RunAndReturn(run func(oldKey string) (string, error)) *MockPortal_GetApiKeyId_Call

type MockPortal_GetBuild_Call

type MockPortal_GetBuild_Call struct {
	*mock.Call
}

MockPortal_GetBuild_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBuild'

func (*MockPortal_GetBuild_Call) Return

func (*MockPortal_GetBuild_Call) Run

func (_c *MockPortal_GetBuild_Call) Run(run func(product Product, version string, hash string)) *MockPortal_GetBuild_Call

func (*MockPortal_GetBuild_Call) RunAndReturn

func (_c *MockPortal_GetBuild_Call) RunAndReturn(run func(product Product, version string, hash string) (Build, error)) *MockPortal_GetBuild_Call

type MockPortal_ListAPIKeys_Call added in v0.11.0

type MockPortal_ListAPIKeys_Call struct {
	*mock.Call
}

MockPortal_ListAPIKeys_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAPIKeys'

func (*MockPortal_ListAPIKeys_Call) Return added in v0.11.0

func (*MockPortal_ListAPIKeys_Call) Run added in v0.11.0

func (*MockPortal_ListAPIKeys_Call) RunAndReturn added in v0.11.0

func (_c *MockPortal_ListAPIKeys_Call) RunAndReturn(run func() ([]ApiKey, error)) *MockPortal_ListAPIKeys_Call

type MockPortal_ListBuilds_Call

type MockPortal_ListBuilds_Call struct {
	*mock.Call
}

MockPortal_ListBuilds_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListBuilds'

func (*MockPortal_ListBuilds_Call) Return

func (_c *MockPortal_ListBuilds_Call) Return(availablePackages Builds, err error) *MockPortal_ListBuilds_Call

func (*MockPortal_ListBuilds_Call) Run

func (*MockPortal_ListBuilds_Call) RunAndReturn

func (_c *MockPortal_ListBuilds_Call) RunAndReturn(run func(product Product) (Builds, error)) *MockPortal_ListBuilds_Call

type MockPortal_RegisterAPIKey_Call

type MockPortal_RegisterAPIKey_Call struct {
	*mock.Call
}

MockPortal_RegisterAPIKey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RegisterAPIKey'

func (*MockPortal_RegisterAPIKey_Call) Return

func (*MockPortal_RegisterAPIKey_Call) Run

func (_c *MockPortal_RegisterAPIKey_Call) Run(run func(owner string, organization string, role string, expiresAt time.Time)) *MockPortal_RegisterAPIKey_Call

func (*MockPortal_RegisterAPIKey_Call) RunAndReturn

func (_c *MockPortal_RegisterAPIKey_Call) RunAndReturn(run func(owner string, organization string, role string, expiresAt time.Time) (*ApiKey, error)) *MockPortal_RegisterAPIKey_Call

type MockPortal_RevokeAPIKey_Call

type MockPortal_RevokeAPIKey_Call struct {
	*mock.Call
}

MockPortal_RevokeAPIKey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RevokeAPIKey'

func (*MockPortal_RevokeAPIKey_Call) Return

func (*MockPortal_RevokeAPIKey_Call) Run

func (*MockPortal_RevokeAPIKey_Call) RunAndReturn

func (_c *MockPortal_RevokeAPIKey_Call) RunAndReturn(run func(key string) error) *MockPortal_RevokeAPIKey_Call

type MockPortal_UpdateAPIKey_Call added in v0.12.0

type MockPortal_UpdateAPIKey_Call struct {
	*mock.Call
}

MockPortal_UpdateAPIKey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateAPIKey'

func (*MockPortal_UpdateAPIKey_Call) Return added in v0.12.0

func (*MockPortal_UpdateAPIKey_Call) Run added in v0.12.0

func (_c *MockPortal_UpdateAPIKey_Call) Run(run func(key string, expiresAt time.Time)) *MockPortal_UpdateAPIKey_Call

func (*MockPortal_UpdateAPIKey_Call) RunAndReturn added in v0.12.0

func (_c *MockPortal_UpdateAPIKey_Call) RunAndReturn(run func(key string, expiresAt time.Time) error) *MockPortal_UpdateAPIKey_Call

type MockPortal_VerifyBuildArtifactDownload_Call added in v0.18.0

type MockPortal_VerifyBuildArtifactDownload_Call struct {
	*mock.Call
}

MockPortal_VerifyBuildArtifactDownload_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VerifyBuildArtifactDownload'

func (*MockPortal_VerifyBuildArtifactDownload_Call) Return added in v0.18.0

func (*MockPortal_VerifyBuildArtifactDownload_Call) Run added in v0.18.0

func (*MockPortal_VerifyBuildArtifactDownload_Call) RunAndReturn added in v0.18.0

type Portal

type Portal interface {
	ListBuilds(product Product) (availablePackages Builds, err error)
	GetBuild(product Product, version string, hash string) (Build, error)
	DownloadBuildArtifact(product Product, build Build, file io.Writer, startByte int, quiet bool) error
	VerifyBuildArtifactDownload(file io.Reader, download Build) error
	RegisterAPIKey(owner string, organization string, role string, expiresAt time.Time) (*ApiKey, error)
	RevokeAPIKey(key string) error
	UpdateAPIKey(key string, expiresAt time.Time) error
	ListAPIKeys() ([]ApiKey, error)
	GetApiKeyId(oldKey string) (string, error)
}

type PortalClient

type PortalClient struct {
	Env        env.Env
	HttpClient HttpClient
}

func NewPortalClient

func NewPortalClient() *PortalClient

func (*PortalClient) AuthorizedHttpRequest added in v0.16.0

func (c *PortalClient) AuthorizedHttpRequest(req *http.Request) (resp *http.Response, err error)

AuthorizedHttpRequest sends a HTTP request with the necessary authorization headers.

func (*PortalClient) DownloadBuildArtifact

func (c *PortalClient) DownloadBuildArtifact(product Product, build Build, file io.Writer, startByte int, quiet bool) error

DownloadBuildArtifact downloads the build artifact for the specified product and build.

func (*PortalClient) GetApiKeyId added in v0.17.1

func (c *PortalClient) GetApiKeyId(oldKey string) (string, error)

GetApiKeyId retrieves the key ID by sending the old key in the request header.

func (*PortalClient) GetBody

func (c *PortalClient) GetBody(path string) (body []byte, status int, err error)

GetBody sends a GET request to the specified path and returns the response body and status code.

func (*PortalClient) GetBuild

func (c *PortalClient) GetBuild(product Product, version string, hash string) (Build, error)

GetBuild retrieves a specific build for the given product, version, and hash.

func (*PortalClient) HttpRequest

func (c *PortalClient) HttpRequest(method string, path string, body []byte) (resp *http.Response, err error)

HttpRequest sends an unauthorized HTTP request to the portal API with the specified method, path, and body.

func (*PortalClient) ListAPIKeys added in v0.11.0

func (c *PortalClient) ListAPIKeys() ([]ApiKey, error)

ListAPIKeys retrieves the list of API keys.

func (*PortalClient) ListBuilds

func (c *PortalClient) ListBuilds(product Product) (availablePackages Builds, err error)

ListBuilds retrieves the list of available builds for the specified product.

func (*PortalClient) RegisterAPIKey

func (c *PortalClient) RegisterAPIKey(owner string, organization string, role string, expiresAt time.Time) (*ApiKey, error)

RegisterAPIKey registers a new API key with the specified parameters.

func (*PortalClient) RevokeAPIKey

func (c *PortalClient) RevokeAPIKey(keyId string) error

RevokeAPIKey revokes the API key with the specified key ID.

func (*PortalClient) UpdateAPIKey added in v0.12.0

func (c *PortalClient) UpdateAPIKey(key string, expiresAt time.Time) error

UpdateAPIKey updates the expiration date of the specified API key.

func (*PortalClient) VerifyBuildArtifactDownload added in v0.18.0

func (c *PortalClient) VerifyBuildArtifactDownload(file io.Reader, download Build) error

type Product

type Product string
const (
	CodesphereProduct Product = "codesphere"
	OmsProduct        Product = "oms"
)

type WriteCounter

type WriteCounter struct {
	Written    int64
	LastUpdate time.Time
	Writer     io.Writer
	// contains filtered or unexported fields
}

WriteCounter is a custom io.Writer that counts bytes written and logs progress.

func NewWriteCounter

func NewWriteCounter(writer io.Writer) *WriteCounter

NewWriteCounter creates a new WriteCounter.

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Write implements the io.Writer interface for WriteCounter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL