package common import ( "context" "edge-infra.dev/pkg/edge/api/graph/model" "edge-infra.dev/pkg/lib/crypto" ) //go:generate mockgen -destination=../../../mocks/mock_activation_code_service.go -package=mocks edge-infra.dev/pkg/edge/api/services/edgenode/common ActivationCode type ActivationCode interface { // Fetch returns the activation code for the terminal from the database Fetch(ctx context.Context, terminalID string) (*string, error) // FetchFromSecret returns the activation code for the terminal from the secret value FetchFromSecret(ctx context.Context, terminalID string) (string, error) // Refresh generates a new activation code for the terminal, then calling Create Refresh(ctx context.Context, terminalID string) (string, error) // Create stores the activation code in the DB, and calls Sync Create(ctx context.Context, activationCode crypto.Credential, terminal *model.Terminal) error // SyncToStore creates the Secret on the cluster SyncToStore(ctx context.Context, terminalID string, cluster *model.Cluster, activationCode string) error // SyncAllToStore re-syncs the activation codes for all terminals in the cluster SyncAllToStore(ctx context.Context, clusterEdgeID string) error // MarkUsed clears the terminal's activation code in the DB and removes the Secret/ExternalSecret resources MarkUsed(ctx context.Context, terminalID string, cluster *model.Cluster, clusterInfra *model.Cluster) error // CleanupStore removes the following resources for each activation code of each respective terminal within the cluster: // - ExternalSecret/Secret on store // - IAMPolicyMember on cluster-infra // - SecretManagerSecret CleanupStore(ctx context.Context, cluster *model.Cluster) error // CleanupTerminal removes the following resources for the activation code of the terminal: // - ExternalSecret/Secret on store // - IAMPolicyMember on cluster-infra // - SecretManagerSecret CleanupTerminal(ctx context.Context, terminalID string, clusterEdgeID string) error }