Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8s client final release #453

Merged
merged 5 commits into from
Jul 28, 2023
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: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-gitops-tools",
"displayName": "GitOps Tools for Flux",
"description": "GitOps automation tools for continuous delivery of Kubernetes and Cloud Native applications",
"version": "0.24.3",
"version": "0.24.4-edge.0",
"author": "Kingdon Barrett <kingdon@weave.works>",
"contributors": [
"Kingdon Barrett <kingdon@weave.works>",
Expand Down Expand Up @@ -616,11 +616,11 @@
"ts-loader": "^9.2.8",
"tsconfig-paths-webpack-plugin": "^4.0.1",
"typescript": "^4.5.5",
"tough-cookie": ">=4.1.3",
"vite": ">=2.9.16",
"tough-cookie": ">=4.1.3",
"vite": ">=2.9.16",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2",
"word-wrap": ">=1.2.4"
"word-wrap": ">=1.2.4"
},
"dependencies": {
"@kubernetes/client-node": "^0.18.1",
Expand All @@ -637,12 +637,12 @@
"shell-escape-tag": "^2.0.2",
"shelljs": "^0.8.5",
"tinytim": "^0.1.1",
"tough-cookie": ">=4.1.3",
"tough-cookie": ">=4.1.3",
"uuid": "^9.0.0",
"vite": ">=2.9.16",
"vite": ">=2.9.16",
"vscode-kubernetes-tools-api": "^1.3.0",
"vscode-uri": "^3.0.7",
"word-wrap": ">=1.2.4"
"word-wrap": ">=1.2.4"
},
"activationEvents": [
"onDebug"
Expand Down
3 changes: 0 additions & 3 deletions src/commands/fluxReconcileSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { BucketNode } from 'ui/treeviews/nodes/source/bucketNode';
import { GitRepositoryNode } from 'ui/treeviews/nodes/source/gitRepositoryNode';
import { HelmRepositoryNode } from 'ui/treeviews/nodes/source/helmRepositoryNode';
import { OCIRepositoryNode } from 'ui/treeviews/nodes/source/ociRepositoryNode';
import { refreshSourcesTreeView } from 'ui/treeviews/treeViews';

/**
* Invoke flux reconcile of a specific source.
Expand All @@ -26,6 +25,4 @@ export async function fluxReconcileSourceCommand(source: GitRepositoryNode | OCI
}

await fluxTools.reconcile(sourceType, source.resource.metadata?.name || '', source.resource.metadata?.namespace || '');

refreshSourcesTreeView();
}
6 changes: 0 additions & 6 deletions src/commands/fluxReconcileWorkload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { FluxWorkload } from 'types/fluxCliTypes';
import { Kind } from 'types/kubernetes/kubernetesTypes';
import { HelmReleaseNode } from 'ui/treeviews/nodes/workload/helmReleaseNode';
import { KustomizationNode } from 'ui/treeviews/nodes/workload/kustomizationNode';
import { refreshSourcesTreeView, refreshWorkloadsTreeView } from 'ui/treeviews/treeViews';

/**
* Invoke flux reconcile of a specific workload.
Expand All @@ -24,11 +23,6 @@ export async function fluxReconcileWorkload(workload: KustomizationNode | HelmRe
}

await fluxTools.reconcile(workloadType, workload.resource.metadata?.name || '', workload.resource.metadata?.namespace || '', withSource);

refreshWorkloadsTreeView();
if(withSource) {
refreshSourcesTreeView();
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/ui/webviews/configureGitOps/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createConfigurationGeneric } from './lib/createGeneric';
import { exportConfigurationGeneric } from './lib/exportGeneric';


const isAzure = (data: ParamsDictionary) => data.clusterInfo.isAzure && data.source?.createFluxConfig;
const isAzure = (data: ParamsDictionary) => data.clusterInfo.isAzure && (data.source?.createFluxConfig || !data.source);

function removeAzureData(data: any) {
if(data.source) {
Expand Down
4 changes: 3 additions & 1 deletion src/ui/webviews/configureGitOps/lib/createAzure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ParamsDictionary } from 'utils/typeUtils';
import { refreshSourcesTreeView, refreshWorkloadsTreeView } from 'ui/treeviews/treeViews';
import { ClusterInfo } from 'types/kubernetes/clusterProvider';
import { kubeConfig } from 'cli/kubernetes/kubernetesConfig';
import { splitNamespacedFluxObject } from 'utils/namespacedFluxObject';

export async function createConfigurationAzure(data: ParamsDictionary) {
const clusterInfo = data.clusterInfo as ClusterInfo;
Expand All @@ -22,7 +23,8 @@ export async function createConfigurationAzure(data: ParamsDictionary) {
}

} else if(kustomization) {
azureTools.createKustomization(kustomization.name, kustomization.source, kustomization.path,
const gitRepositoryName = splitNamespacedFluxObject(kustomization.source).name;
azureTools.createKustomization(kustomization.name, gitRepositoryName, kustomization.path,
contextName, clusterInfo.clusterProvider as AzureClusterProvider, kustomization.dependsOn, kustomization.prune);
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/utils/namespacedFluxObject.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { FluxSourceObject, FluxWorkloadObject } from '../types/flux/object';



export function namespacedFluxObject(resource?: FluxSourceObject | FluxWorkloadObject): string | undefined {
if (resource) {
return `${resource.kind}/${resource.metadata?.name}.${resource.metadata?.namespace}`;
}
}

export function splitNamespacedFluxObject(fullname: string) {
const [kind, nameNs] = fullname.split('/');
const [name, namespace] = nameNs.split('.');
return { kind, name, namespace };
}
20 changes: 11 additions & 9 deletions webview-ui/configureGitOps/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const [createWorkload, setCreateWorkload] = createSignal(false);
export const [kustomization, setKustomization] = createStore({
name: 'podinfo',
namespace: 'flux-system',
source: '', // Ex: GitRepo/podinfo.flux-system
source: '', // Ex: GitRepository/podinfo.flux-system
path: '/kustomize',
targetNamespace: 'default',
serviceAccount: '',
Expand Down Expand Up @@ -135,12 +135,7 @@ createEffect(() => {

if(params.selectSourceTab) {
setCreateWorkload(true);

if(params.selectedSource && params.selectedSource !== '') {
setKustomization('source', params.selectedSource);
} else if(params.sources?.length > 0) {
setKustomization('source', namespacedSource(params.sources[0]));
}
updateSelectedSource();
}

if(params.set) {
Expand All @@ -162,8 +157,7 @@ createEffect(() => {
if(createSource()) {
setKustomization('source', `${source.kind}/${source.name}.${source.namespace}`);
} else {
const s = params.sources[0];
setKustomization('source', `${s.kind}/${s.name}.${s.namespace}`);
updateSelectedSource();
}
});

Expand Down Expand Up @@ -201,6 +195,14 @@ const setters: StoreMap = {
setKustomization,
};

export function updateSelectedSource() {
if (params.selectedSource && params.selectedSource !== '') {
setKustomization('source', params.selectedSource);
} else if (params.sources?.length > 0) {
setKustomization('source', namespacedSource(params.sources[0]));
}
}

export function storeAccessors(props: any) {
let get: ()=> any;
let set: (v: any)=> any;
Expand Down
Loading