Skip to content

Commit

Permalink
Merge pull request #132 from layer5io/kumarabd/feature/labs
Browse files Browse the repository at this point in the history
fixes for the adapter
  • Loading branch information
kumarabd authored Oct 14, 2020
2 parents 0f2ef9c + 57a0246 commit d95c2fe
Show file tree
Hide file tree
Showing 15 changed files with 9,923 additions and 109 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ FROM alpine
RUN apk --update add ca-certificates curl
RUN mkdir /lib64 && \
ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 && \
mkdir -p /root/.kube
mkdir -p /root/.kube && \
mkdir -p /tmp/istio
COPY --from=bd /meshery-istio /app/
COPY --from=bd /istio /app/istio
COPY --from=bd /istio.tar.gz /app/
COPY --from=bd //github.com/layer5io/meshery-istio/scripts /app/scripts/.
COPY --from=bd /etc/passwd /etc/passwd
ENV ISTIO_VERSION=istio-1.5.1
ENV ISTIO_VERSION=1.7.3
# USER appuser
WORKDIR /app
CMD ./meshery-istio
69 changes: 1 addition & 68 deletions istio/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,77 +132,10 @@ func monkeyPatchingToSupportInsecureConn(data []byte) []byte {
return data1
}

// Kubeconfig is structure of the kubeconfig file
type Kubeconfig struct {
APIVersion string `yaml:"apiVersion,omitempty" json:"apiVersion,omitempty"`
Clusters []struct {
Cluster struct {
CertificateAuthorityData string `yaml:"certificate-authority-data,omitempty" json:"certificate-authority-data,omitempty"`
Server string `yaml:"server,omitempty" json:"server,omitempty"`
} `yaml:"cluster,omitempty" json:"cluster,omitempty"`
Name string `yaml:"name,omitempty" json:"name,omitempty"`
} `yaml:"clusters,omitempty" json:"clusters,omitempty"`
Contexts []struct {
Context struct {
Cluster string `yaml:"cluster,omitempty" json:"cluster,omitempty"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
User string `yaml:"user,omitempty" json:"user,omitempty"`
} `yaml:"context,omitempty" json:"context,omitempty"`
Name string `yaml:"name,omitempty" json:"name,omitempty"`
} `yaml:"contexts,omitempty" json:"contexts,omitempty"`
CurrentContext string `yaml:"current-context,omitempty" json:"current-context,omitempty"`
Kind string `yaml:"kind,omitempty" json:"kind,omitempty"`
Preferences struct {
} `yaml:"preferences,omitempty" json:"preferences,omitempty"`
Users []struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
User struct {
Exec struct {
APIVersion string `yaml:"apiVersion,omitempty" json:"apiVersion,omitempty"`
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
Command string `yaml:"command,omitempty" json:"command,omitempty"`
Env []struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Value string `yaml:"value,omitempty" json:"value,omitempty"`
} `yaml:"env,omitempty" json:"env,omitempty"`
} `yaml:"exec,omitempty" json:"exec,omitempty"`
AuthProvider struct {
Config struct {
AccessToken string `yaml:"access-token,omitempty" json:"access-token,omitempty"`
CmdArgs string `yaml:"cmd-args,omitempty" json:"cmd-args,omitempty"`
CmdPath string `yaml:"cmd-path,omitempty" json:"cmd-path,omitempty"`
Expiry time.Time `yaml:"expiry,omitempty" json:"expiry,omitempty"`
ExpiryKey string `yaml:"expiry-key,omitempty" json:"expiry-key,omitempty"`
TokenKey string `yaml:"token-key,omitempty" json:"token-key,omitempty"`
} `yaml:"config,omitempty" json:"config,omitempty"`
Name string `yaml:"name,omitempty" json:"name,omitempty"`
} `yaml:"auth-provider,omitempty" json:"auth-provider,omitempty"`
ClientCertificateData string `yaml:"client-certificate-data,omitempty" json:"client-certificate-data,omitempty"`
ClientKeyData string `yaml:"client-key-data,omitempty" json:"client-key-data,omitempty"`
Token string `yaml:"token,omitempty" json:"token,omitempty"`
} `yaml:"user,omitempty,omitempty" json:"user,omitempty,omitempty"`
} `yaml:"users,omitempty" json:"users,omitempty"`
}

// writeKubeconfig creates kubeconfig in local container
func writeKubeconfig(kubeconfig []byte, contextName string, path string) error {

yamlConfig := Kubeconfig{}
err := yaml.Unmarshal(kubeconfig, &yamlConfig)
if err != nil {
return err
}

yamlConfig.CurrentContext = contextName
fmt.Printf("%+v\n", yamlConfig)

d, err := yaml.Marshal(yamlConfig)
if err != nil {
return err
}
fmt.Printf(string(d))

err = ioutil.WriteFile(path, d, 0600)
err := ioutil.WriteFile(path, kubeconfig, 0600)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit d95c2fe

Please sign in to comment.