Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
DeanHnter committed Feb 6, 2024
2 parents ebdf4a1 + 585fe26 commit da271b4
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 11 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ name: Go
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

permissions:
contents: write
actions: read

jobs:

Expand All @@ -28,15 +30,18 @@ jobs:
- name: Execute Task
run: task build

# If you want to create a release and upload the binary to that release:
- name: Generate Unique Tag
id: uniquetag
run: echo "RELEASE_TAG=$(date +'%Y%m%d%H%M%S')-$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
tag_name: ${{ env.RELEASE_TAG }}
release_name: Release ${{ env.RELEASE_TAG }}
draft: false
prerelease: false

Expand All @@ -47,12 +52,11 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Client/docker
asset_name: docker-binary
asset_name: docker
asset_content_type: application/octet-stream

# If you want to just upload the binary as a workflow artifact:
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: docker-binary
name: docker
path: ./Client/docker
64 changes: 62 additions & 2 deletions Client/cmd/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package cmd

import (
"github.com/spf13/cobra"
shared "github.com/CoreViewInc/CoreNiko/shared"
shared "github.com/CoreViewInc/CoreNiko/shared"
"fmt"
)

var (
Expand Down Expand Up @@ -66,15 +67,74 @@ var loginCmd = &cobra.Command {
Run: func(cmd *cobra.Command, args []string) { DockerCLI.Service.Login(args, username, password) },
}

var pullCmd = &cobra.Command{
Use: "pull NAME[:TAG]",
Short: "Pull an image or a repository from a registry",
Long: `This command is used to pull an image or a repository from a Docker registry.`,
Args: cobra.ExactArgs(1), // Expect exactly one argument, the name of the image
Run: func(cmd *cobra.Command, args []string) {
imageName := args[0]
DockerCLI.Service.PullImage(imageName)
},
}

var inspectCmd = &cobra.Command{
Use: "inspect [OPTIONS] NAME|ID [NAME|ID...]",
Short: "Return low-level information on Docker objects",
Long: `Return low-level information on Docker objects, including containers, images, volumes, nodes, networks, services, and more.
By default, docker inspect will render all results in a JSON array. This command is capable of inspecting multiple targets at a time.`,
// Allowing for a variable number of arguments
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// Retrieve flags. This example assumes necessary flags are added to this Cobra command elsewhere in the code.
format, _ := cmd.Flags().GetString("format")
size, _ := cmd.Flags().GetBool("size")
targetType, _ := cmd.Flags().GetString("type")

infoArgs := []string{}

// Adding type flag to arguments if specified
if targetType != "" {
infoArgs = append(infoArgs, "--type="+targetType)
}

// Adding format flag to arguments if specified
if format != "" {
infoArgs = append(infoArgs, "--format="+format)
}

// Adding size flag to arguments if specified
if size {
infoArgs = append(infoArgs, "--size")
}

// Adding the actual object names or IDs to inspect
infoArgs = append(infoArgs, args...)

// Executing inspection with the collected arguments
result, err := DockerCLI.Service.InspectImage(infoArgs)
if err != nil {
return err
}

// Printing result
fmt.Println(result)
return nil
},
}

func init() {
RootCmd.AddCommand(buildCmd)
RootCmd.AddCommand(tagCmd)
RootCmd.AddCommand(pushCmd)
RootCmd.AddCommand(loginCmd)
RootCmd.AddCommand(pullCmd)
RootCmd.AddCommand(inspectCmd)
buildCmd.Flags().StringArrayVarP(&buildOptions.Tags, "tag", "t", []string{}, "Name and optionally a tag in the 'name:tag' format")
buildCmd.Flags().StringP("file", "f", "Dockerfile", "Name of the Dockerfile")
loginCmd.Flags().StringVarP(&username, "username", "u", "", "Username for registry authentication")
loginCmd.Flags().StringVarP(&password, "password", "p", "", "Password for registry authentication")

inspectCmd.Flags().StringP("type", "", "", "Specify the type of object to inspect (container, image, etc.)")
inspectCmd.Flags().StringP("format", "f", "", "Format the output using the given Go template")
inspectCmd.Flags().BoolP("size", "s", false, "Display total file sizes if the type is container")
}
12 changes: 11 additions & 1 deletion Client/kaniko/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,14 @@ func (kd *KanikoDocker) Login(args []string,username string,password string) {
dockerauth = auth.NewUserPassAuth(username, password)
}
dockerauth.CreateDockerConfigJSON()
}
}

func (kd *KanikoDocker) InspectImage(args []string) (string, error){
return "",nil
}


func (kd *KanikoDocker) PullImage(imageName string) error {
return nil
}

2 changes: 2 additions & 0 deletions Client/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type DockerBuilder interface {
TagImage(args []string)
PushImage(args []string)
Login(args []string,username string,password string)
PullImage(imageName string) error
InspectImage(args []string) (string, error)
}

// Definition for executor, in this case kaniko is the only provided execution provider.
Expand Down

0 comments on commit da271b4

Please sign in to comment.