Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libs/cypress/fixtures/auth/organization.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { API_VERSION } from '../../support/constants';

const defaultOrg = {
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'Organization',
metadata: {
name: 'default',
Expand Down
9 changes: 5 additions & 4 deletions libs/cypress/fixtures/enrollmentRequests/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConditionStatus, ConditionType } from '@flightctl/types';
import { API_VERSION } from '../../support/constants';

const approvedErStatus = {
approval: {
Expand All @@ -22,7 +23,7 @@ const approvedErStatus = {
const getErList = (onlyPending: boolean) =>
[
{
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'EnrollmentRequest',
metadata: {
creationTimestamp: '2024-04-10T11:48:43Z',
Expand All @@ -35,7 +36,7 @@ const getErList = (onlyPending: boolean) =>
status: approvedErStatus,
},
{
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'EnrollmentRequest',
metadata: {
creationTimestamp: '2024-04-10T12:15:31Z',
Expand All @@ -48,7 +49,7 @@ const getErList = (onlyPending: boolean) =>
status: { conditions: [] },
},
{
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'EnrollmentRequest',
metadata: {
creationTimestamp: '2024-04-10T09:31:04Z',
Expand All @@ -61,7 +62,7 @@ const getErList = (onlyPending: boolean) =>
status: approvedErStatus,
},
{
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'EnrollmentRequest',
metadata: {
creationTimestamp: '2024-10-10T12:15:31Z',
Expand Down
9 changes: 5 additions & 4 deletions libs/cypress/fixtures/fleets/initialFleets.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Fleet } from '@flightctl/types';
import { API_VERSION } from '../../support/constants';

const basicFleets: Fleet[] = [
{
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'Fleet',
metadata: {
creationTimestamp: '2024-04-10T12:11:54Z',
Expand Down Expand Up @@ -48,11 +49,11 @@ const basicFleets: Fleet[] = [
applicationStatus: {},
summaryStatus: {},
updateStatus: {},
}
},
},
},
{
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'Fleet',
metadata: {
creationTimestamp: '2024-04-10T12:13:58Z',
Expand Down Expand Up @@ -106,7 +107,7 @@ const basicFleets: Fleet[] = [
applicationStatus: {},
summaryStatus: {},
updateStatus: {},
}
},
},
},
];
Expand Down
3 changes: 2 additions & 1 deletion libs/cypress/fixtures/repositories/initialRepositories.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ConditionStatus, ConditionType, RepoSpecType, Repository } from '@flightctl/types';
import { API_VERSION } from '../../support/constants';

const repoList: Repository[] = [
{
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'Repository',
metadata: {
creationTimestamp: '2024-04-30T14:05:53Z',
Expand Down
1 change: 1 addition & 0 deletions libs/cypress/support/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const API_VERSION = 'v1beta1';
3 changes: 2 additions & 1 deletion libs/cypress/support/interceptors/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defaultOrg } from '../../fixtures/auth/organization';
import { API_VERSION } from '../constants';

const loadInterceptors = () => {
cy.intercept('GET', '/api/login/info', (req) => {
Expand All @@ -18,7 +19,7 @@ const loadInterceptors = () => {
req.reply({
statusCode: 200,
body: {
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'OrganizationList',
metadata: {},
items: [defaultOrg],
Expand Down
3 changes: 2 additions & 1 deletion libs/cypress/support/interceptors/devices.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Device, PatchRequest } from '@flightctl/types';
import { API_VERSION } from '../constants';

const buildDevicesResponse = (devices: Device[]) => ({
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
items: devices,
kind: 'DeviceList',
metadata: {},
Expand Down
3 changes: 2 additions & 1 deletion libs/cypress/support/interceptors/enrollmentRequests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { getErList } from '../../fixtures';
import { EnrollmentRequest } from '@flightctl/types';
import { API_VERSION } from '../constants';

const buildErResponse = (enrollmentRequests: EnrollmentRequest[]) => ({
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
items: enrollmentRequests,
kind: 'EnrollmentRequestList',
metadata: {},
Expand Down
3 changes: 2 additions & 1 deletion libs/cypress/support/interceptors/fleets.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { basicFleets } from '../../fixtures/fleets';
import { Fleet } from '@flightctl/types';
import { API_VERSION } from '../constants';

const buildFleetResponse = (fleets: Fleet[]) => ({
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
items: fleets,
kind: 'FleetList',
metadata: {},
Expand Down
3 changes: 2 additions & 1 deletion libs/cypress/support/interceptors/repositories.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Repository } from '@flightctl/types';
import { repoList } from '../../fixtures';
import { API_VERSION } from '../constants';

const buildRepositoriesResponse = (repositories: Repository[]) => ({
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
items: repositories,
kind: 'RepositoryList',
metadata: {},
Expand Down
2 changes: 1 addition & 1 deletion libs/types/models/ImageApplicationProviderSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { ApplicationResources } from './ApplicationResources';
import type { ApplicationVolumeProviderSpec } from './ApplicationVolumeProviderSpec';
export type ImageApplicationProviderSpec = (ApplicationVolumeProviderSpec & {
/**
* Reference to the container image for the application package.
* Reference to the OCI image or artifact for the application package.
*/
image: string;
/**
Expand Down
2 changes: 1 addition & 1 deletion libs/types/scripts/openapi-typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const processJsonAPI = (jsonString) => {
};

async function main() {
const swaggerUrl = 'https://raw.githubusercontent.com/flightctl/flightctl/main/api/v1alpha1/openapi.yaml';
const swaggerUrl = 'https://raw.githubusercontent.com/flightctl/flightctl/main/api/v1beta1/openapi.yaml';
const output = path.resolve(__dirname, '../tmp-types');
const response = await fetch(swaggerUrl);
const data = await response.text();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from './types';
import { validKubernetesDnsSubdomain } from '../../form/validations';
import { DynamicAuthProviderSpec, ProviderType } from '../../../types/extraTypes';
import { API_VERSION } from '../../../constants';

export const getAssignmentTypeLabel = (
type: AuthOrganizationAssignment['type'] | AuthRoleAssignment['type'] | undefined,
Expand Down Expand Up @@ -316,7 +317,7 @@ export const getAuthProvider = (values: AuthProviderFormValues): AuthProvider =>
}

return {
apiVersion: 'v1alpha1',
apiVersion: API_VERSION,
kind: 'AuthProvider',
metadata: {
name: values.name,
Expand Down
2 changes: 1 addition & 1 deletion libs/ui-components/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const APP_TITLE = 'Edge Manager';
const API_VERSION = 'v1alpha1';
const API_VERSION = 'v1beta1';
const PAGE_SIZE = 15;
const EVENT_PAGE_SIZE = 200; // It's 500 in OCP console

Expand Down
4 changes: 2 additions & 2 deletions proxy/auth/aap.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/flightctl/flightctl-ui/bridge"
"github.com/flightctl/flightctl-ui/config"
"github.com/flightctl/flightctl-ui/log"
"github.com/flightctl/flightctl/api/v1alpha1"
"github.com/flightctl/flightctl/api/v1beta1"
"github.com/openshift/osincli"
)

Expand Down Expand Up @@ -50,7 +50,7 @@ func (c *AAPRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return resp, nil
}

func getAAPAuthHandler(provider *v1alpha1.AuthProvider, aapSpec *v1alpha1.AapProviderSpec) (*AAPAuthHandler, error) {
func getAAPAuthHandler(provider *v1beta1.AuthProvider, aapSpec *v1beta1.AapProviderSpec) (*AAPAuthHandler, error) {
providerName := extractProviderName(provider)

// Validate required fields
Expand Down
14 changes: 7 additions & 7 deletions proxy/auth/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (

"github.com/flightctl/flightctl-ui/config"
"github.com/flightctl/flightctl-ui/log"
"github.com/flightctl/flightctl/api/v1alpha1"
"github.com/flightctl/flightctl/api/v1beta1"
)

// k8s service account prefix
const k8sServiceAccountPrefix = "system:serviceaccount:"

// exchangeTokenWithApiServer allows us to perform the token exchange through the Flight Control API
func exchangeTokenWithApiServer(apiTlsConfig *tls.Config, providerName string, tokenReq *v1alpha1.TokenRequest) (*v1alpha1.TokenResponse, error) {
func exchangeTokenWithApiServer(apiTlsConfig *tls.Config, providerName string, tokenReq *v1beta1.TokenRequest) (*v1beta1.TokenResponse, error) {
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: apiTlsConfig,
Expand Down Expand Up @@ -68,7 +68,7 @@ func exchangeTokenWithApiServer(apiTlsConfig *tls.Config, providerName string, t

if resp.StatusCode != http.StatusOK {
// Try to parse as JSON first (OAuth2 errors are usually JSON)
var tokenResp v1alpha1.TokenResponse
var tokenResp v1beta1.TokenResponse
if err := json.Unmarshal(body, &tokenResp); err == nil {
// Successfully parsed as JSON, check for OAuth2 error fields
if tokenResp.Error != nil {
Expand All @@ -85,7 +85,7 @@ func exchangeTokenWithApiServer(apiTlsConfig *tls.Config, providerName string, t
}

// Status is OK, parse as JSON
var tokenResp v1alpha1.TokenResponse
var tokenResp v1beta1.TokenResponse
if err := json.Unmarshal(body, &tokenResp); err != nil {
return nil, fmt.Errorf("failed to parse API server token response: %w (body: %s)", err, string(body))
}
Expand Down Expand Up @@ -154,7 +154,7 @@ func getUserInfoFromApiServer(apiTlsConfig *tls.Config, token string) (string, e

if resp.StatusCode != http.StatusOK {
// Try to parse as JSON first
var userInfoResp v1alpha1.UserInfoResponse
var userInfoResp v1beta1.UserInfoResponse
if err := json.Unmarshal(body, &userInfoResp); err == nil {
// Successfully parsed as JSON, check for error field
if userInfoResp.Error != nil {
Expand All @@ -167,7 +167,7 @@ func getUserInfoFromApiServer(apiTlsConfig *tls.Config, token string) (string, e
}

// Status is OK, parse as JSON
var userInfoResp v1alpha1.UserInfoResponse
var userInfoResp v1beta1.UserInfoResponse
if err := json.Unmarshal(body, &userInfoResp); err != nil {
return "", fmt.Errorf("failed to parse userinfo response: %w (body: %s)", err, string(body))
}
Expand All @@ -191,7 +191,7 @@ func getUserInfoFromApiServer(apiTlsConfig *tls.Config, token string) (string, e
}

// convertTokenResponseToTokenData converts TokenResponse to proxy TokenData
func convertTokenResponseToTokenData(tokenResp *v1alpha1.TokenResponse, providerName string) (TokenData, *int64) {
func convertTokenResponseToTokenData(tokenResp *v1beta1.TokenResponse, providerName string) (TokenData, *int64) {
tokenData := TokenData{
Provider: providerName,
}
Expand Down
28 changes: 14 additions & 14 deletions proxy/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/flightctl/flightctl-ui/config"
"github.com/flightctl/flightctl-ui/log"
"github.com/flightctl/flightctl/api/v1alpha1"
"github.com/flightctl/flightctl/api/v1beta1"
)

type ExpiresInResp struct {
Expand All @@ -27,7 +27,7 @@ type RedirectResponse struct {
type AuthHandler struct {
provider AuthProvider
apiTlsConfig *tls.Config
authConfigData *v1alpha1.AuthConfig
authConfigData *v1beta1.AuthConfig
}

func NewAuth(apiTlsConfig *tls.Config) (*AuthHandler, error) {
Expand All @@ -51,7 +51,7 @@ func NewAuth(apiTlsConfig *tls.Config) (*AuthHandler, error) {
}

// findProviderConfig finds a provider config by name from the auth config
func findProviderConfig(authConfig *v1alpha1.AuthConfig, providerName string) (*v1alpha1.AuthProvider, error) {
func findProviderConfig(authConfig *v1beta1.AuthConfig, providerName string) (*v1beta1.AuthProvider, error) {
if authConfig == nil || authConfig.Providers == nil {
return nil, fmt.Errorf("no providers configured")
}
Expand All @@ -67,7 +67,7 @@ func findProviderConfig(authConfig *v1alpha1.AuthConfig, providerName string) (*

// getProviderInstance creates a provider instance by fetching the latest auth config
// Returns both the provider instance and the provider config to avoid duplicate API calls
func (a *AuthHandler) getProviderInstance(providerName string) (AuthProvider, *v1alpha1.AuthProvider, error) {
func (a *AuthHandler) getProviderInstance(providerName string) (AuthProvider, *v1beta1.AuthProvider, error) {
authConfig, err := getAuthInfo(a.apiTlsConfig)
if err != nil {
return nil, nil, fmt.Errorf("failed to get auth config: %w", err)
Expand Down Expand Up @@ -146,7 +146,7 @@ func (a *AuthHandler) getProviderInstance(providerName string) (AuthProvider, *v
}

// getClientIdFromProviderConfig extracts the client_id from a provider config
func getClientIdFromProviderConfig(providerConfig *v1alpha1.AuthProvider) (string, error) {
func getClientIdFromProviderConfig(providerConfig *v1beta1.AuthProvider) (string, error) {
providerTypeStr, err := providerConfig.Spec.Discriminator()
if err != nil {
return "", fmt.Errorf("failed to determine provider type: %w", err)
Expand Down Expand Up @@ -270,7 +270,7 @@ func (a AuthHandler) Login(w http.ResponseWriter, r *http.Request) {
return
}

var providerConfig *v1alpha1.AuthProvider
var providerConfig *v1beta1.AuthProvider
provider, providerConfig, err = a.getProviderInstance(providerName)
if err != nil {
log.GetLogger().WithError(err).Warnf("Could not find provider: %s", providerName)
Expand Down Expand Up @@ -373,8 +373,8 @@ func (a AuthHandler) Login(w http.ResponseWriter, r *http.Request) {
}

redirectURI := config.BaseUiUrl + "/callback"
tokenReq := &v1alpha1.TokenRequest{
GrantType: v1alpha1.AuthorizationCode,
tokenReq := &v1beta1.TokenRequest{
GrantType: v1beta1.AuthorizationCode,
ClientId: clientId,
Code: &loginParams.Code,
CodeVerifier: &loginParams.CodeVerifier,
Expand Down Expand Up @@ -413,7 +413,7 @@ func (a AuthHandler) Refresh(w http.ResponseWriter, r *http.Request) {
}

// Get provider to determine routing
var providerConfig *v1alpha1.AuthProvider
var providerConfig *v1beta1.AuthProvider
provider, providerConfig, err := a.getProviderInstance(tokenData.Provider)
if err != nil {
log.GetLogger().WithError(err).Warnf("Failed to get provider: %s", tokenData.Provider)
Expand All @@ -440,8 +440,8 @@ func (a AuthHandler) Refresh(w http.ResponseWriter, r *http.Request) {
return
}

tokenReq := &v1alpha1.TokenRequest{
GrantType: v1alpha1.RefreshToken,
tokenReq := &v1beta1.TokenRequest{
GrantType: v1beta1.RefreshToken,
ClientId: clientId,
RefreshToken: &tokenData.RefreshToken,
}
Expand All @@ -459,7 +459,7 @@ func (a AuthHandler) Refresh(w http.ResponseWriter, r *http.Request) {
}

// handleOAuthErrorResponse handles OAuth2 error responses from token exchange/refresh
func handleOAuthErrorResponse(w http.ResponseWriter, tokenResp *v1alpha1.TokenResponse, defaultMessage string) {
func handleOAuthErrorResponse(w http.ResponseWriter, tokenResp *v1beta1.TokenResponse, defaultMessage string) {
if tokenResp != nil && tokenResp.Error != nil {
errorDesc := ""
if tokenResp.ErrorDescription != nil {
Expand Down Expand Up @@ -607,7 +607,7 @@ func (a AuthHandler) Logout(w http.ResponseWriter, r *http.Request) {
}
}

func getAuthInfo(apiTlsConfig *tls.Config) (*v1alpha1.AuthConfig, error) {
func getAuthInfo(apiTlsConfig *tls.Config) (*v1beta1.AuthConfig, error) {
client := &http.Client{Transport: &http.Transport{
TLSClientConfig: apiTlsConfig,
}}
Expand Down Expand Up @@ -636,7 +636,7 @@ func getAuthInfo(apiTlsConfig *tls.Config) (*v1alpha1.AuthConfig, error) {
return nil, err
}

authConfig := &v1alpha1.AuthConfig{}
authConfig := &v1beta1.AuthConfig{}
err = json.Unmarshal(body, authConfig)
if err != nil {
log.GetLogger().WithError(err).Warn("Failed to unmarshal auth config")
Expand Down
Loading