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

Convert volumes in [name:][host:]container[:access_mode] format #78

Merged
merged 2 commits into from
Aug 4, 2016

Conversation

janetkuo
Copy link
Member

@janetkuo janetkuo commented Aug 3, 2016

#75

@ngtuna
Copy link
Contributor

ngtuna commented Aug 3, 2016

@janetkuo did you test with compose v1 which doesn't include volume name ?

@janetkuo
Copy link
Member Author

janetkuo commented Aug 3, 2016

Yes, I tested against docker-gitlab.yml, and an example output is:

$ kompose convert -f docker-gitlab.yml -y 
file "postgresql-svc.yaml" created
file "redisio-svc.yaml" created
file "gitlab-svc.yaml" created
file "redisio-deployment.yaml" created
file "gitlab-deployment.yaml" created
file "postgresql-deployment.yaml" created

$ cat redisio-deployment.yaml 
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    service: redisio
  name: redisio
spec:
  replicas: 1
  selector:
    matchLabels:
      service: redisio
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        service: redisio
    spec:
      containers:
      - image: sameersbn/redis
        name: redisio
        ports:
        - containerPort: 6379
          protocol: TCP
        resources: {}
        volumeMounts:
        - mountPath: /var/lib/redis
          name: ls6k1hh2gdnyxxvi7hvs
      restartPolicy: Always
      volumes:
      - hostPath:
          path: /srv/docker/gitlab/redis
        name: ls6k1hh2gdnyxxvi7hvs
status: {}


volumesMount = append(volumesMount, api.VolumeMount{Name: volumeName, ReadOnly: readonly, MountPath: containerDir})
// volumeName = random string of 20 chars
if len(name) == 0 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't assume that volume name is specified (even for v2, volume name isn't required), and if it's not, just use the current random volume name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@janetkuo janetkuo force-pushed the volume-parse-conversion branch from aa3abb1 to 8d7be45 Compare August 3, 2016 20:12
@janetkuo
Copy link
Member Author

janetkuo commented Aug 3, 2016

Just rebased.

@janetkuo
Copy link
Member Author

janetkuo commented Aug 3, 2016

I added a unit test, tested locally with go test -tags experimental (how do we enable testing in travis?)

@ngtuna ngtuna added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 4, 2016
@janetkuo janetkuo merged commit 5902174 into kubernetes:master Aug 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. review needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants