service

package
v0.0.0-...-8d3f935 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeploymentAction

type DeploymentAction struct {
	Deployment *appsv1.Deployment
}

DeploymentAction represents a Deployment resource action.

func (DeploymentAction) Apply

func (d DeploymentAction) Apply(clientset kubernetes.Interface) (string, error)

func (DeploymentAction) Name

func (d DeploymentAction) Name() string

func (DeploymentAction) Rollback

func (d DeploymentAction) Rollback(clientset kubernetes.Interface) (string, error)

type DiscordService

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

DiscordService handles OAuth2 authentication and API calls

func MakeDiscordService

func MakeDiscordService() (*DiscordService, error)

MakeDiscordService creates a new Discord service

func (*DiscordService) ExchangeCodeForToken

func (c *DiscordService) ExchangeCodeForToken(code, origin string) (*DiscordTokenResponse, error)

ExchangeCodeForToken exchanges an authorization code for an access token

func (*DiscordService) GetUserInfo

func (c *DiscordService) GetUserInfo(accessToken string) (*UserResponse, error)

GetUserInfo retrieves the user's information using the access token

type DiscordTokenResponse

type DiscordTokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
}

DiscordTokenResponse represents Discord's token response

type KubernetesService

type KubernetesService interface {
	AddAction(action ResourceAction)
	ApplyResources() ([]string, error)
	GetActions() []ResourceAction
	GetClient() kubernetes.Interface
	GetClusterIp() (string, error)
	Rollback() ([]string, error)
	DoesPvcExist(name string) bool
	RemoveFinalizersAndDelete(name string) error
}

func MakeKubernetesService

func MakeKubernetesService(config *rest.Config) KubernetesService

MakeKubernetesService Creates a new kubernetes service object which intelligently loads configuration from either in-cluster or local if in-cluster fails.

type KubernetesServiceImpl

type KubernetesServiceImpl struct {
	Client          kubernetes.Interface
	ResourceActions []ResourceAction
}

func (*KubernetesServiceImpl) AddAction

func (k *KubernetesServiceImpl) AddAction(action ResourceAction)

func (*KubernetesServiceImpl) ApplyResources

func (k *KubernetesServiceImpl) ApplyResources() ([]string, error)

ApplyResources applies a list of resources and rolls them back on failure.

func (*KubernetesServiceImpl) DoesPvcExist

func (k *KubernetesServiceImpl) DoesPvcExist(name string) bool

DoesPvcExist Returns true if the pvc exists and false otherwise

func (*KubernetesServiceImpl) GetActions

func (k *KubernetesServiceImpl) GetActions() []ResourceAction

func (*KubernetesServiceImpl) GetClient

func (*KubernetesServiceImpl) GetClusterIp

func (k *KubernetesServiceImpl) GetClusterIp() (string, error)

GetClusterIp Returns the ipv4 WAN address for the cluster. This will be the address returned to users where they can point their Valheim client's to connect.

func (*KubernetesServiceImpl) RemoveFinalizersAndDelete

func (k *KubernetesServiceImpl) RemoveFinalizersAndDelete(name string) error

RemoveFinalizersAndDelete Removes a PVC's finalizers setting them to null and deletes the PVC.

func (*KubernetesServiceImpl) Rollback

func (k *KubernetesServiceImpl) Rollback() ([]string, error)

type Message

type Message struct {
	Type string `json:"type"`
	Body []byte `json:"content"`
}

type Mod

type Mod struct {
	Id        string `json:"mod_id"`
	Version   string `json:"version"`
	Updated   string `json:"updated_time"`
	Created   string `json:"created_time"`
	Name      string `json:"name"`
	Summary   string `json:"summary"`
	Image     string `json:"picture_url"`
	Downloads int64  `json:"mod_downloads"`
	Author    string `json:"author"`
}

type ModNexusService

type ModNexusService struct {
	Client *http.Client
	// contains filtered or unexported fields
}

func MakeModNexusService

func MakeModNexusService() *ModNexusService

func (*ModNexusService) GetMod

func (m *ModNexusService) GetMod(id string) (*Mod, error)

func (*ModNexusService) ModIdForPrefix

func (m *ModNexusService) ModIdForPrefix(prefix string) string

type PVCAction

type PVCAction struct {
	PVC *corev1.PersistentVolumeClaim
}

PVCAction represents a PersistentVolumeClaim resource action.

func (PVCAction) Apply

func (p PVCAction) Apply(clientset kubernetes.Interface) (string, error)

func (PVCAction) Name

func (p PVCAction) Name() string

func (PVCAction) Rollback

func (p PVCAction) Rollback(clientset kubernetes.Interface) (string, error)

type RabbitMqService

type RabbitMqService struct {
	Connection     *amqp.Connection
	ConsumeChannel *amqp.Channel
	PublishChannel *amqp.Channel
	Queue          *amqp.Queue
	// contains filtered or unexported fields
}

func MakeRabbitMQService

func MakeRabbitMQService(exchangeName, routingKey string) (*RabbitMqService, error)

func (*RabbitMqService) Close

func (r *RabbitMqService) Close()

func (*RabbitMqService) PublishMessage

func (r *RabbitMqService) PublishMessage(message *Message) error

func (*RabbitMqService) RegisterConsumer

func (r *RabbitMqService) RegisterConsumer(consumer func(message Message, db *gorm.DB), delay time.Duration, db *gorm.DB) error

type ResourceAction

type ResourceAction interface {
	Apply(clientset kubernetes.Interface) (string, error)
	Rollback(clientset kubernetes.Interface) (string, error)
	Name() string
}

ResourceAction defines an interface for applying and rolling back Kubernetes resources.

type S3Service

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

func MakeS3Service

func MakeS3Service(region string) (*S3Service, error)

MakeS3Service creates a new instance of S3Service

func (*S3Service) DeleteObject

func (s *S3Service) DeleteObject(ctx context.Context, key string) error

DeleteObject deletes an object from S3

func (*S3Service) DeleteObjectsWithPrefix

func (s *S3Service) DeleteObjectsWithPrefix(ctx context.Context, prefix string) error

DeleteObjectsWithPrefix deletes all objects with the given prefix

func (*S3Service) GeneratePutSignedUrl

func (s *S3Service) GeneratePutSignedUrl(prefix string, expiration time.Duration) (string, error)

GeneratePutSignedUrl Generates a signed url for uploading an object to S3

func (*S3Service) ListObjects

func (s *S3Service) ListObjects(prefix string) ([]SimpleS3Object, error)

ListObjects lists all objects in a bucket with given prefix

func (*S3Service) UploadObject

func (s *S3Service) UploadObject(ctx context.Context, key string) (*s3.PutObjectOutput, error)

UploadObject publishes an object to S3 under the given prefix

type SimpleS3Object

type SimpleS3Object struct {
	Key  string `json:"key"`
	Size int64  `json:"fileSize"`
}

type StripeService

type StripeService struct{}

func MakeStripeService

func MakeStripeService() *StripeService

func (*StripeService) GetActiveSubscription

func (s *StripeService) GetActiveSubscription(customerId string, subscriptionId string) (string, error)

GetActiveSubscription checks if a subscription is active for a given customer

func (*StripeService) GetSubscriptionLimits

func (s *StripeService) GetSubscriptionLimits(subscriptionId string) (*model.SubscriptionLimits, error)

type UserResponse

type UserResponse struct {
	ID            string `json:"id"`
	Username      string `json:"username"`
	Discriminator string `json:"discriminator"`
	Avatar        string `json:"avatar"`
	Email         string `json:"email"`
	Verified      bool   `json:"verified"`
}

UserResponse represents the Discord user information

type Wrapper

type Wrapper struct {
	DiscordService  *DiscordService
	S3Service       *S3Service
	StripeService   *StripeService
	CognitoService  service.CognitoService
	KubeService     KubernetesService
	RabbitMQService *RabbitMqService
	HearthhubDb     *gorm.DB
	ModNexusService *ModNexusService
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳