Giter Club home page Giter Club logo

Comments (9)

RandomFractals avatar RandomFractals commented on May 19, 2024

Kubernetes tools extension implements custom fs (filesystem) to load those documents on k8s tools explorer node clicks:

https://github.com/Azure/vscode-kubernetes-tools/blob/master/src/extension.ts#L740

async function loadKubernetes(explorerNode?: ClusterExplorerResourceNode) {
    if (explorerNode) {
        loadKubernetesCore(explorerNode.namespace, explorerNode.kindName);
    } else {
        const value = await promptKindName(kuberesources.commonKinds, "load", { nameOptional: true });
        if (value) {
            loadKubernetesCore(null, value);
        }
    }
}

The actual config document loading is done via kubefsUri() construction and standard vscode document open setup:

function loadKubernetesCore(namespace: string | null, value: string) {
    const outputFormat = config.getOutputFormat();
    const uri = kubefsUri(namespace, value, outputFormat);
    vscode.workspace.openTextDocument(uri).then((doc) => {
        if (doc) {
            vscode.window.showTextDocument(doc);
        }
    },
    (err) => vscode.window.showErrorMessage(`Error loading document: ${err}`));
}

We just need to construct the URI they use for those documents to have k8s tools extension open them for us in vscode Editor.

Here is where they construct their custom kubefs uri: https://github.com/Azure/vscode-kubernetes-tools/blob/master/src/kuberesources.virtualfs.ts#L19

export function kubefsUri(namespace: string | null | undefined /* TODO: rationalise null and undefined */, value: string, outputFormat: string, action?: string): Uri {
    const docname = `${value.replace('/', '-')}${outputFormat !== '' ? '.' + outputFormat : ''}`;
    const nonce = new Date().getTime();
    const nsquery = namespace ? `ns=${namespace}&` : '';
    const scheme = action === 'describe' ? K8S_RESOURCE_SCHEME_READONLY : K8S_RESOURCE_SCHEME;
    const authority = action === 'describe' ? KUBECTL_DESCRIBE_AUTHORITY : KUBECTL_RESOURCE_AUTHORITY;
    const uri = `${scheme}://${authority}/${docname}?${nsquery}value=${value}&_=${nonce}`;
    return Uri.parse(uri);
}

from vscode-gitops-tools.

RandomFractals avatar RandomFractals commented on May 19, 2024

Kustomization and Helm Release config views in vscode editor wired to those Deployment node clicks:

gitops-kustomization-yaml

gitops-helm-release-yaml

from vscode-gitops-tools.

RandomFractals avatar RandomFractals commented on May 19, 2024

Git/Helm repos and Bucket yaml config loading and display:

gitops-git-repo-yaml

gitops-helm-repo-yaml

gitops-bucket-yaml

from vscode-gitops-tools.

RandomFractals avatar RandomFractals commented on May 19, 2024

@usernamehw see if you can figure out why resource uri is not passed to the cluster context menu item. That's the only part left to close this ticket.

from vscode-gitops-tools.

usernamehw avatar usernamehw commented on May 19, 2024

@RandomFractals Kubernetes extension doesn't do anything when clicking on the cluster.

  1. You are passing cluster name in place of the first argument (namespace)
  2. As a second argument - a string namespace/${cluster.name} which doesn't make sense.

I don't know what's your goal in all this... What do you expect to open as a result of this?

this.resourceUri = kubernetesTools.getResourceUri(
cluster.name,
`${ResourceTypes.Namespace}/${cluster.name}`,
FileTypes.Yaml);

from vscode-gitops-tools.

usernamehw avatar usernamehw commented on May 19, 2024

Tree view icons now look weird:

Since we only need uri as an argument to command maybe it would be best to use any other name for that property (NOT the this.resourceUri that affects appearance).

from vscode-gitops-tools.

RandomFractals avatar RandomFractals commented on May 19, 2024

@usernamehw try opening default namespace node under namespaces in k8s tools explorer.

The goal here is to show configs for all of our tree nodes. We will be setting standard resourceUri on all of our tree view items to open config files via k8s tools api by default. That part was intentional.

I am pretty sure I have the correct params set for us to load that config document for a cluster.

The disconnect is in passing uri via viewItem in View Config menu item for a cluster.

Icons should show yaml for now vs nothing before. They will change to indicator icons later. Let's focus on getting all configs in editor first.

from vscode-gitops-tools.

RandomFractals avatar RandomFractals commented on May 19, 2024

@murillodigital just an fyi, the new flux-system namespace deployments show this config in vscode editor when you open them from the Clusters tree view:

gitops-flux-deployments

This is from changes in #36.

from vscode-gitops-tools.

RandomFractals avatar RandomFractals commented on May 19, 2024

This ticket handles open config for all of the node types we support, except for the cluster info.

This is what k8s tools does for the cluster info:

k8s-cluster-info

I suggest @murillodigital and @usernamehw review that functionality in k8s tools explorer and create new feature request or enhancement to do something similar for our cluster nodes.

from vscode-gitops-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.