MCPcopy Index your code
hub / github.com/google/go-github / runCreate

Function runCreate

example/auditlogstream/main.go:104–142  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

102}
103
104func runCreate(args []string) {
105 fs, enterprise := newFlagSet("create")
106 container := fs.String("container", "", "Azure Blob Storage container name (required).")
107 sasURL := fs.String("sas-url", "", "Plain-text Azure SAS URL to encrypt and submit (required).")
108 enabled := fs.Bool("enabled", true, "Whether the stream should be enabled immediately.")
109
110 ctx, client, ent := parseAndInit(fs, enterprise, args)
111 requireFlag("container", *container)
112 requireFlag("sas-url", *sasURL)
113
114 streamKey, _, err := client.Enterprise.GetAuditLogStreamKey(ctx, ent)
115 if err != nil {
116 log.Fatalf("Error fetching audit log stream key: %v", err)
117 }
118 fmt.Printf("Retrieved stream key ID: %v\n", streamKey.KeyID)
119
120 encryptedSASURL, err := encryptSecret(streamKey.Key, *sasURL)
121 if err != nil {
122 log.Fatalf("Error encrypting SAS URL: %v", err)
123 }
124 fmt.Println("SAS URL encrypted successfully.")
125
126 config := github.NewAzureBlobStreamConfig(*enabled, &github.AzureBlobConfig{
127 KeyID: streamKey.KeyID,
128 Container: *container,
129 EncryptedSASURL: encryptedSASURL,
130 })
131
132 stream, _, err := client.Enterprise.CreateAuditLogStream(ctx, ent, *config)
133 if err != nil {
134 log.Fatalf("Error creating audit log stream: %v", err)
135 }
136
137 fmt.Println("Successfully created audit log stream:")
138 fmt.Printf(" ID: %v\n", stream.ID)
139 fmt.Printf(" Type: %v\n", stream.StreamType)
140 fmt.Printf(" Enabled: %v\n", stream.Enabled)
141 fmt.Printf(" Created at: %v\n", stream.CreatedAt)
142}
143
144func runDelete(args []string) {
145 fs, enterprise := newFlagSet("delete")

Callers 1

mainFunction · 0.85

Calls 8

NewAzureBlobStreamConfigFunction · 0.92
newFlagSetFunction · 0.85
parseAndInitFunction · 0.85
requireFlagFunction · 0.85
encryptSecretFunction · 0.85
GetAuditLogStreamKeyMethod · 0.80
CreateAuditLogStreamMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…